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

How to change the bar color/axis label color in custom visuals

$
0
0

Hi,

 

I want to change the bar color and axis label color. How can I change the color. I write the same code which is downloaded from the github.

 

This is my sample code to set the color in VisualTransform method

 

let defaultColor: Fill = {
                solid: {
                    color: colorPalette.getColor(category.values[i] + '').value
                }
            }

            barChartDataPoints.push({
                category: <string>category.values[i],
                value: <number>dataValue.values[i],
                color: getCategoricalObjectValue<Fill>(category, i, 'colorSelector', 'fill', defaultColor).solid.color,
                selectionId: host.createSelectionIdBuilder()
                    .withCategory(category, i)
                    .createSelectionId()
            });

 

And This is the code in enumerateObjectInstances method

 

case 'colorSelector':
                    for(let barDataPoint of this.barDataPoints) {
                        objectEnumeration.push({
                            objectName: objectName,
                            displayName: barDataPoint.category,
                            properties: {
                                fill: {
                                    solid: {
                                        color: barDataPoint.color
                                    }
                                },
                            },
                            selector: barDataPoint.selectionId
                        });
                    }
                    break;

 

But it is not working. It will remain the same color as set it by default. It is not updating the bar color.

 

If I write

 

selector: barDataPoint.selectionId.getSelection()

 

then I got the following error.

 Property 'getSelection' does not exist on type 'ISelectionId'.

 

Can you please help me.


Viewing all articles
Browse latest Browse all 17884

Trending Articles



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