Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi everyone,
I'm requesting your help. I'm currently developping a custom visual using Plotly.JS library.
Basically, it's a line chart but with a few more customized features.
My aim is to fit the color between my custom visual and the native line chart visuel integrated into PowerBI.
To do that, I use the color palette as described in the official documentation: Add colors to your Power BI custom visuals - Power BI | Microsoft Learn
The results are good: in the custom visual, colors for each catory are assigned in the order of the colors in the palette.
I'm using this code to assign a color to a category:
var category_color = this.host.colorPalette.getColor(category)
BUT, you're guessing that if I'm writing this message right now it's because I have a problem.
When filtering with slicers, categories are not associated/mapped with a color in the same way between a default visual and a custom visual.
Example of my resultats:
What I understand I that:
In native/default visual: all categories are mapped to a color, and the color's mapping remains fixed even if the page filters change
In my custom visual:I associate each category I come across with a color, regardless of its appearance order, in order of the palette colors.
Result: I get different colors when the filters change
Can anyone explain the color assignment phenomenon for categories used in PowerBI captions? Also, is there any way I can get this color assignment to match the colors of my objects/legends in my custom visuals?
Of course, if what I've written today is too incomprehensible, please let me know and I'll add more graphic examples to explain this color problem in my captions.
Thank you in advance for taking the time to reply.
Best regards
@DallasBaba
That is precisely what I do under my code, using the getColor() method from the colorPalette of the IVisualHost interface.
Here is an example:
I created a simple dataset: 4 different legends & 4 values.
On the left the native PBI bar chart and on the right a custom one (from the AppSource, I get the same behave when I develop my own)
The color assigned for the different categories are not the same.
Furthemore, if I select a legend on the left chart, the filtering on the other chart clearly show that the color attribution is not synchronized:
My opinion is that the customs are using the colorPalette and the getColor() method but that the native are using an other method to assign the color to the categories.
I hope I'm wrong, but I see this behavior between every native/custom that I'm using...
Thank you for your help !
@Anonymous Have you been able to solve the issue.
I have also gone through the same issue. When I click on any bar of the Barchart, initial color is populated on the custom visual.
Thank You!
Hello @SKYViz
Unfortunatly, even though I manage to have selectors, even though I use the colorPalette and even though I use the colorHelper I still have the problem of "color synchronization"
@Anonymous you can try the following steps:
This should ensure that the colors are consistent between the native line chart visual and your custom visual, even when filtering with slicers.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |