Forum Discussion
Chart Colors: How to keep the initial theme colors on each chart
Hi,
first time vistor here and a 2 week user of Power BI desktop.
Background:
I have a dataset from the UN FAO which lists crops grown by crop types in different countries. There are over 150 individual crops but they summarize up into 11 Basic groups {Cereals, Sugar, Oilcrops, Fruits, Vegetables etc.}.
So the schema looks like 'Crop Group' -'Crop List' -'Crop Fact table with year, country, crop and production'.
First Visual is easy which is just the sum by Crop Group. I then want to create a visual for each of the crop groups with breakout by crop type - so for cereals there is {maize, rice, wheat etc}, Vegetables {Onions, Carrots, etc).
Each visual can have a filter applied to it by crop group which works fine and shows all the crops.
The problem arising is that the color of each crop seems to be based on a color assigned within the total crop list rather than within the filtered visual. With over 150 individual crops this gives some pretty horrendous colors. So if i dont apply a crop group filter and showed all 150 individuals the color is the same as when filtered.
Is there a way for each visual to apply the themecolor scheme starting at themecolor#1 ?
I've tried various methods of constructing the underlying datasets for each visual (which has helped me to learn some DAX so not entirely wasted effort) but have yet to find a method which does what I want.
best regards
Mark
1 Reply
- paul-maessenResolver I
Hi Mark,
You could have a look at the Color Utils that are available for Custom Visual Development: https://docs.microsoft.com/en-us/power-bi/developer/visuals/utils-color
To access the 8 defined colors in the Theme you can also use the getColor()-method from the IColorPalette-interface. You can get this colorPalette from your IVisualHost.
let colorPalette: IColorPalette = options.host.colorPalette; // host: IVisualHost let color1 = colorPalette.getColor("0") // First Theme Color let color2 = colorPalette.getColor("1") // Second Theme Color ...I hope this will help you to get further with your visual.
Regards
Paul
Paul