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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jagvdelsen
Frequent Visitor

Color Palette not working as expected.

Hi,

In several custom visuals we created, we are using the color palette provided by the IVisualHost to assign colors to categorical item. We run into a problem that in case a filter is applied, the initial colors that were assigned to a particular categorical item will shift in case the filter get's removed. This of course is unwanted behavior since the colors that were initially 'reserved' by the palette for a particular item get re-assigned. So for example: I have a "region" category mapped in my report having the values: "east", "west", "north", "south". I apply a filter by filtering out "north" and I save my report. When reopening the report, "east", "west" and "south" will get the first 3 colors of the palette (which is the expected behavior). When clearing the filter I would like to ensure that "east", "west" and "south" would still have the colors they got initially assigned, but since I retrieve new Data, the color palette seems to be 'reset' and the previous assigned colors will be handed out as being available palette colors.

Even in other situations I would like a particular color to be assigned to a particular item (and I don't want this to change). Is there any way to achieve this without having to hold an internal administrattion ourselves?

Thanks in advance!
Jelle.

2 REPLIES 2
Anonymous
Not applicable

Hi  @jagvdelsen ,

 

This is the related document, you can view this content:

Re: Synchronize color palette between Custom & Nat... - Microsoft Fabric Community

PowerBI-visuals/Tutorial/ColorPalette.md at master · PowerBi-Projects/PowerBI-visuals · GitHub

Add colors to your Power BI custom visuals - Power BI | Microsoft Learn

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous,

Thanks for your reply. I have read and understand the links you've sent and we indeed use the this.host.colorPalette.getColor(category) method to retrieve the colors. The problem is that the color palette is 'reset' between two update-calls (during the initial load of the report) which results in the fact that when clearing the filter, the first color will be handed out again as if the colors were not (already) assigned. Is there anyone available who I could contact to explain the problem to or who could help me with this problem?

Thanks!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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