31 August 2017
Colours, colours, colours in Tableau. I had a client who wanted something very specific. He wanted a stepped colour scale, but with a visual alert, colour or otherwise, when the value went above a certain threshold. He gave an example of a box going red (on an otherwise white to blue colour scale). I thought that was something I could work with.Let's say, for example, I wanted to look at the number of different product containers used by month over the years 2010 - 2013. Let's say anything over 5 different product levels is critical and needs to be highlighted using a loud colour (screaming red). Anything up to 5 could be coloured from white to deepening shades of blue.First, I made sure my variable was continuous.Then I dragged it onto colour.[caption id='attachment_117' align='aligncenter' width='231']
Continuous field on colour[/caption]Next, I chose a diverging colour palette using Tableau’s colour options and made a note of 3 hex codes: One each for the two ends of the spectrum of colour that I wanted to diverge between (in this case white and dark blue), and the third one the colour that I wanted as my “alert” colour (red).Following that, I opened up my preferences.tps file (which I found in the “My Tableau Repository” folder) in a text editor, found the most suitably-named colour palette to use as a template ('ordered diverging' in this case) and created a new colour palette with these three hexcodes. I chose a name for the new colour palette that matched the name of the project.[caption id='attachment_118' align='aligncenter' width='663']
New colour palette for my preferences.tps file[/caption]Going back into Tableau, I selected my newly-created colour palette to use as the colour range for my variable. (Closing and re-opening Tableau might be necessary at this stage.)I made sure the “Stepped Colour” and “Use Full Colour Range” boxes were ticked and opened up the Advanced options by clicking on the “Advanced >>” button.From there, it was a matter of adjusting the start, end, and centre points, as well as the number of steps to get exactly the right effect I had in mind.[caption id='attachment_119' align='aligncenter' width='300']
New colour palette settings[/caption]Finally, I dragged the same continuous field onto labels and changed my mark type to Square to create a heatmap/highlight chart effect and also so that I could check that the values and colours were matching my expectations. (In this case, white to blue for values between 1 and 5, and red for values above 5).[caption id='attachment_122' align='aligncenter' width='300']
The Final Result[/caption]by Rachel Phang(also posted on my personal blog: https://vizteriousgirl.wordpress.com/)



