Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
paramjit_s
Frequent Visitor

Custom Bar Chart - Data Point Colours

I am creating a custom bar chart using sampleBarChart to show duration of my tests, in addition in need to show passed and failed tests using different colours for each bar. 

 

These are my data roles in capabilities.json . The Legend data role will contain the result for each test.  

 

    "dataRoles": [
        {
            "displayName": "Category Data",
            "name": "category",
            "kind": "Grouping"
        },
        {
            "displayName": "Measure Data",
            "name": "measure",
            "kind": "Measure"
        }, 
        {
            "displayName": "Legend", 
            "name": "series", 
            "kind": "Grouping"
        }
    ],

 

Current data view mapping. 

 

 "dataViewMappings": [
        {
            "conditions": [
                {
                    "category": {
                        "max": 1
                    },
                    "measure": {
                        "max": 1
                    }
                }
            ],
            "categorical": {
                "categories": {
                    "for": {
                        "in": "category"
                    }
                },
                "values": {
                    "group": {
                        "by": "series", 
                        "select": [
                            { "for": {
                                "in": "measure"
                            }}
                        ]
                    }
                
                }
            }
        }
    ],

 

Current code doesn't plot any bars on the chart.  However in the dataview of the custom visual online this is what it shows. 

 dataview.png

Under categories each test ID is shown seperately and under values it groups the durations into two groups passed and failed.

 

I have not made any other changes to the code. If someone could please help me show the duration of each test and set colour of each bar according to whether that particular test has passed or failed. I have been able to achieve this in the native column chart of Power Bi but I need to be able to do the same in this custom visual because i need to make more changes to this chart.

 
11 REPLIES 11

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.