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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Anonymous
Not applicable

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.