Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 18013

Custom Bar Chart - Data Point Colours

$
0
0

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.

 

Viewing all articles
Browse latest Browse all 18013

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>