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
mroot
Frequent Visitor

assigning colors to points from colorPalette object issue

 I am just trying to be consistent with synchronizing the colors of data points from my custom visual with the other 'out of the box' pbi visuals.  I am using the code snippet from the documentation to assign colors to my data points:

 

let colorPalette: IColorPalette = host.colorPalette; // host: IVisualHost
for (let i = 0, len = Math.max(category.values.length, dataValue.values.length); i < len; i++) {
    barChartDataPoints.push({
        category: category.values[i],
        value: dataValue.values[i],
        color: colorPalette.getColor(category.values[i]).value,
    });
}

Some of the time the data points from my visual are the same as other visuals and other times they are not.

 

My question is, does all the visuals in the pbi dashboard pull from the same host.colorPalette object? If so what determines which hex color gets assigned to each data point in the object?  Why are the colors assigned to my data points in the colorPalette object different from other visuals that are displaying the same data points. Is there a way from your data points to always get assigned the same colors as others visuals. I have read the documentation https://microsoft.github.io/PowerBI-visuals/docs/how-to-guide/adding-colors-to-your-visual/

 

Thanks!

 

Matt

1 REPLY 1
saikirann
Frequent Visitor

Even I am having the same issue. When increasing the data with slicer the colors are getting repeated. 

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.