Working with Themes – Part 1

Background

What is the purpose of Themes in Power BI? Is it just a way to make ‘prettier’ reports or to see how many different colors we can put on a report? While I believe that many people believe that and have never given themes a second thought since the day they first started using Power BI, that is not their purpose.

Themes provide a way to provide customization of colors, fonts, and other aspects of Power BI that can be automatically applied across all the visualizations in a report to create a common look and feel not just within the visualizations of your current report, but all Power BI reports created by everyone at your organization. Most organizations have a ‘preferred’ color set that brands their documents to their organization. Obvious, each organization has its own color schema preference. They may even have a preferred font style. (Hopefully, it isn’t Comic Sans Serif.) Trying to get all Power BI users within an organization to use the same exact colors for the same features consistently would be a challenge unless your preferred color and font schema was the Power BI default settings. Themes help make that type of consistency possible.

When themes were first introduced to Power BI, you had a fixed set of themes from which to select which basically changed the colors used for the various visualizations that came with Power BI. As more third-party visualization developers got on board with the use of themes, the color changes soon began to also update the colors of their visualizations as well. Typically, themes consisted of an array of 8 colors that were used for any visualization that had multiple data series to display so that each series could be identified with a different color. Why limit the number of colors to eight? I’m not really sure, but I suspect that it may have something to do with the fact that after more than about 8 different colors in one visualization, the human eye for most people may have difficulties identifying which color corresponded to which data series. The problem is, if you attempted to have more than eight data series in a visualization, rather than generating an error because no 9th color was defined, the decision apparently was made to just repeat the color sequence.

Now I for one believe that using more than 8 data series in one visualization, whether that visualization is a line chart or a bar/column chart, an area chart or a pie chart should be avoided. Perhaps after the first seven data series, the rest of the data should be aggregated into a single 8th data series called ‘Other’. This is especially relevant if the order of the data series is already sequenced from the largest to the smallest. Think of all the pie charts you may have seen with 20-50 segments. Typically, after the first five or so, the rest because relatively small and in some cases may even be hard to display. So why not just lump them together as ‘Other’.

Preview of our Destination

The next step was to allow users and developers to create their own themes through the use of a markup language similar to XML to define their own themes. Typical themes at this time include a name, a set of 8 data colors associated with the element: dataColors

{

“name”: “Plum”,

“dataColors”: [“#653745”, “#634B67”, “#4E647F”, “#2E7C85”, “#329077”, “#649F5E”, “#A1A849”, “#E2A84E”],

}

Listing 1

Note first that a theme must begin and end with a square bracket. In this example as in all JSON theme files, the second line defines the name of this theme which in this case is: Plum. In theory, a theme only needs to have the name element to be a valid encoded JSON theme. But that would be kind of boring in that it would change nothing. Therefore, this listing added the element dataColors that consists of an array of eight colors using RGB notation with each color separated by a comma all enclosed in a set of brackets to indicate that these values form an array for the element dataColors.

However, you can specify any number of colors for the element dataColors, not just eight as in Listing 1. For example, if you wanted to just change the first color to red, you could use the following JSON file.

{

“name”: “RedOne”,

“dataColors”: [“#aa0000”]

}

Listing 2

Picking Colors

How might you determine the RGB values of different colors? Obviously, you would not want to try different RGB values by trial and error. One very useful website is the following;

https://www.w3schools.com/colors/colors_picker.asp

In the following image, you can see that you start by picking a color. One way to do this is to select a color from the hexagon. However, you can also enter a common color name or the HTML5 of a color by selecting the Hue, Saturation, and Lightness using easy to manipulate sliders.

After picking a color, you can use the Lighter/Darker feature on the right side to potentially create a family of eight colors you can use for a theme taking the guesswork out of selecting colors.

Image of the home page of the Color Picker referenced in the prior URL.

Caption 1: Color Picker

After you set the data colors with a JSON file such as the one in Listing 1, you can check the color palette in any visualization of the current report and see the colors have been changed from the default palette to the new palette. You can use these new theme-based colors when coloring other elements.

Example of how the color palette picks up the colors from a new theme.

Caption 2: Theme’s Effect on the Color Palette

I’ll come back to creating your own custom JSON file later in this series, but I wanted to show you how themes look so you will understand some of the other options and why they are easier.

Built-in Themes

Power Bi provides several built-in themes that you available directly from the Power BI menu system (VIEW à THEMES) as shown in the following figure.

Built-in themes in Power BI as of the December 2019 update.

Caption 3: Built-in Themes

These themes have the following names as you move left to right, top to bottom:

  • Default
  • Bloom
  • City Park
  • Classic
  • Classroom
  • Colorblind Safe
  • Divergent
  • Electric
  • Executive
  • Frontier
  • High Contrast
  • Highrise
  • Innovate
  • Solar
  • Storm
  • Sunset
  • Temperature
  • Tidal
  • Twilight

To use one of the built-in themes, all you need to do is click on the picture of one of the theme colors.

I will continue this discussion on themes in my next post. Until then, please experiment with what you have learned so far. Next time we will take these techniques to the next level.