Dynamic Color Branding in Tableau Dashboard
“We need a dashboard which has custom color-branding depending on the client’s color scheme”.
“Color customization should be automatic with minimum input from the user”.
“User should be able to choose colors in real-time and view the dashboard in chosen colors”.
In order to satisfy these requirements, we devised a functionality which enables dynamic color branding in tableau dashboards. As the name suggests, the charts present in the dashboard will be refurbished with brand colors in real-time.
Most BI tools including Tableau only allow selection from a predefined color combination which puts a constraint on the formatting options available to the user. The aforementioned solution looks to overcome this small yet significant limitation and enable users to create more responsive and robust visualizations.
THE TECHNOLOGY BEHIND IT:
A functionality in Tableau allows users to manipulate the dashboard output by varying the filter values being passed in the Dashboard’s URL.
For example, if a dashboard contains advertiser field as a filter value then instead of selecting a value from tableau’s drop-down filter, we can load the dashboard for that value by passing it in the URL. It will look something like this:
https://tableau-server.com/t/Site/views/WorkbookName/Dashboard?advertiser=12345
In this example, we are loading the dashboard for advertiser = 12345 value. This is what we are leveraging to enable dynamic color branding.
Now consider a tableau dashboard which incorporates multiple charts each including both positive and negative values. If one wishes to assign different colors for different values, a traditional tableau dashboard might not be able to accomplish this. But here is how our custom solution comes to the rescue:
1. Tableau has a Preferences.tps file where custom color palettes can be created. This location seats all possible color combinations possible and enables users to create their own palettes. RGB coding structure allows more than 16.7 million possibilities but keeping computational efficiency in mind a 5-point increment scale was agreed upon. For example:
a. First color will be RGB (0,0,0) — hex code #000000
b. Second color will be RGB (0,0,5) — hex code #000005
c. Third color will be RGB (0,0,10) — hex code #00000A
d. Going by the same logic, the last color will be RGB (255,255,255) — hex code #FFFFFF
In this way, we have created a color database with all possible colors.
2. New parameters in tableau desktop had to be created to fetch R, G, B encoding for the different features in question. In the above-mentioned case, since there were two distinct features — Positive and Negative, 6 parameters were required. They will look something like this:
a. nr (R-value of -ve color)
b. ng (G-value of -ve color)
c. nb (B-value of -ve color)
d. pr (R-value of +ve color)
e. pg (G-value of +ve color)
f. pb (B-value of +ve color)
3. Values for each of R, G, B parameters were required to come up with an integer value which when translated to a hex code pointed at the color to be retrieved from the custom color palette. The calculation in tableau appeared in the following manner:
As the use-case required 2 colors, 2 conditions were maintained in the calculated fields (one for negative values and the other corresponding to the positive values). The number generated here was used to determine the color that had to be fetched from the custom palette.
4. The calculated field was then added to the color mark to use the custom color palette generated.
5. Once these changes were committed on the tableau dashboard side, 2 color pickers were generated on the web-page which could be used to apply the brand colors to the visualizations. For example, if a user selects the following colors:
a. #2f312d hex code: for -ve value — RGB (47, 49, 45)
b. #e73a8c hex code: for +ve value — RGB (231, 58, 140)
This is how the URL looked like:
https://tableau-server.com/t/Site/views/WorkbookName/Dashboard?nr=47&ng=49&nb=45&pr=231&pg=58&pb=140
Notice all the 6 RGB values are being passed as URL parameters in the above-mentioned URL. Now the dashboard will load with these colors.
HOW IT LOOKS:
Users could select the colors in the following way:
The encircled portions represent the user-control which was used to select the colors to be applied in the dashboard. Once selected these parameters would appear in the dashboard’s URL.
Here is a look at our refurbished dashboard. Neat, elegant and more importantly in line with the brand.
Another example is as follows:
HOW IS IT HELPING CLIENTS?
This offering offers brands and advertisers the ability to effortlessly personalize visualizations in their dashboards keeping them in line with their respective brand guidelines without having to write code or spending time in recreating these graphs. This also highlights the next step in MiQ’s quest to create robust and adaptable solutions which can be used across multiple use cases in an effortless manner.
Author: Abhimanyu Garg