In Part 1 of this series, you learned how to use some of Power BI’s built-in.
In Part 2 you learned about Microsoft’s Theme Gallery.
In Part 3, you learned how to use the new Customize the Current Theme.
In Part 4, you learned how to export your customized theme and to use it in your future Power BI report projects.
In Part 5, you learned how to create a simple JSON theme file for your future Power BI report projects.
In part 6, you learned about a few of the more common attributes used to customize the color of elements in the most commonly downloaded visualizations.
In part 7, you learned about a few more generic classes that define the colors for conditional formatting and KPIs.
By now you have seen several cases where the colors of some elements would change ‘magically’ when you apply a new theme to your reports. This is part of the artificial intelligence behind Power BI that looks at the color changes that have been applied by a theme and attempts to ‘adjust’ colors of other elements that have not been specified by the theme to something that should be compatible. If you remember, I touched on the fact that background colors appeared to change with some themes that defined only the dataColors array, but then was able to modify the background color by specifically using the background class. However, supplying a background class color also appeared to change the colors of other elements. I will not pretend to understand how that is done by Power BI so I am going to remind everyone of Arthur C. Clarke’s quote from “Profiles of the Future”: “Any sufficiently advanced technology is indistinguishable from magic.” However, if you can wrap your head around a hierarchy of color elements in which Power BI generates default values only if you do not define the color of those elements directly, you are on the right track to understanding how to control your theme colors.
That being said, as we dive further into the capabilities of JSON defined themes, we find additional ways to define those deeper elements which previously Power BI generated colors for when we did not specify them in our themes.
This week, I want to look at what Microsoft calls structural colors. Every visualization has some sort of structural element. These are typically elements outside of the typical data elements that are being displayed. They have been divided into first through fourth level elements. There is also a class for general background and for secondary background colors as well as Table Accent colors which is basically the grid outline.
Here is the problem, or challenge depending on how you look at it. How do you remember which structural elements appear in which of these 7 color classes? Honestly, I have not found an easy answer to this question other than to keep handy the table supplied by Microsoft (found in the How to Create a Theme link at the bottom of the ViewàThemes dropdown menu) and displayed below.
When you look at the table, notice that several class names have (deprecated) after the name. This does not mean that the entire class has been deprecated. Rather only an old name for the class has been deprecated. For example, the class name ‘foreground’ has been deprecated and is now known as ‘firstLevelElements’. Perhaps a comma between the new and old class names would have helped clarify that. Therefore, in my table below, I’ve added those commas. I’ve also added commas in the right column to help clarify what structural elements each color class formats.
As mentioned above, you should also note that we have seen three of these color classes before when we used the class names: background, foreground, and tableAccent. In fact, these three color classes appear in many of the themes that you can download from the Theme Gallery. They are used to provide compatible colors for many of the structure elements when using these themes. However, the class ‘foreground’ is being deprecated and should be replaced going forward with ‘firstLevelElements’. While both class names will work at the time of this writing, it is something that you should be aware of because someday the ‘foreground’ class will no longer be accepted when loading a theme. I am hoping that this will not affect older reports that previously applied themes with the deprecated class names. However, I have no secret insight on that question.
In the following table, you can see 7 color classes
Color class | What it formats |
firstLevelElements,
foreground (deprecated) |
Labels background color (when outside data points), Trend line color, Textbox default color, Table and matrix values and totals font colors, Data bars axis color, Card data labels, Gauge callout value color, KPI goal color, KPI text color, Slicer item color (when in focus mode), Slicer dropdown item font color, Slicer numeric input font color, Slicer header font color, Scatter chart ratio line color, Line chart forecast line color, Map leader line color, Filter pane and card text color, |
secondLevelElements,
foregroundNeutralSecondary (deprecated) |
“light” secondary text classes, Label colors, Legend label color, Axis label color, Table and matrix header font color, Gauge target and target leader line color, KPI trend axis color, Slicer slider color, Slicer item font color, Slicer outline color, Line chart hover color, Multi-row card title color, Ribbon chart stroke color, Shape map border color, Button text font color, Button icon line color, Button outline color, |
thirdLevelElements,
backgroundLight (deprecated) |
Axis gridline color, Table and matrix grid color, Slicer header background color (when in focus mode), Multi-row card outline color, Shape fill color, Gauge arc background color, Applied filter card background color, |
fourthLevelElements,
foregroundNeutralTertiary (deprecated) |
legend dimmed color, Card category label color, Multi-row card category labels color, Mulit-row card bar color, Funnel chart conversion rate stroke color, |
Background | Labels background color (when inside data points), Slicer dropdown items background color, Donut chart stroke color, Treemap stroke color, Combo chart background color, Button fill color, Filter pane and available filter card background color, |
secondaryBackground,
backgroundNeutral (deprecated) |
Table and matrix grid outline color, Shape map default color, Ribbon chart ribbon fill color (when match series option is turned off), |
tableAccent | Overrides table and matrix grid outline color when present |
So, suppose we created the following theme. Yes, this is still a theme even though we did not define values for the dataColors array element.
If you did not get what you wanted or expected when you applied this theme, maybe you need to combine everything we learned so far into a more complete theme definition such as:
Anyway, I leave you to ‘play’ with what you have learned so far to see what new themes you can come up. In any case, we have not reached the bottom of this deep dive into themes yet. Stay tuned. Next time I will show you how to manipulate text families, colors, and sizes.
This Saturday, I will be speaking at SQL Saturday, Tampa on this theme, so to speak. If you are planning on attending, stop by my afternoon session or look for me to say, “Hi!”