Toan Hoang

Creating Gradient Backgrounds in Tableau

When I created my Cryptocurrency Dashboard, I decided to have some fun with gradient backgrounds. When combined with animations, this creates a very cool effect, so here you go, a nice and simple tutorial on creating gradient backgrounds in Tableau.

Data

We will start by loading the following data into Tableau.

Color
Blue
Orange
Green
Red
Purple
Grey

Once your data is loaded into Tableau, right-click on the data source and click on Edit Data Source… with the Data Source Editor open, paste the following:

Path,Position
360,0
0,0
360,1
0,1

Note: If you are using Tableau 2020.2 or great i.e. have access to new Relationship Model, you will need to double-click on the originally pasted data source to open up before pasting in the Path Data.

You should get an error as there is no joining column, however, click on Add new join clause, go to Create Join Calculation, type 1 and click OK. Do this for the right-hand side as well. Ensure that you have Inner join selected and you should see the following:

Note: we need additional records as we are going to be drawing lines and using densification to get more points on our canvas. For more information, check out our article on Data Densification.

Calculated Fields

With our data set loaded into Tableau, we are going to create the following Bins and Calculated Fields:

Path (bin)

Position (bin)

Index

INDEX()-1

Distance

INDEX()-1

X

[Index]

Y

[Position]

X (Circle)

SIN(RADIANS([Index]))*[Distance]

Y (Circle)

COS(RADIANS([Index]))*[Distance]

Gradient Color (Bar)

WINDOW_MAX(MAX([Color]))+STR([Index])

Gradient Color (Circle)

WINDOW_MAX(MAX([Color]))+STR([Distance])

Gradient Color (Circle Reversed)

WINDOW_MAX(MAX([Color]))+STR(100-[Distance])

With this done, let us start creating our data visualisation.

Worksheet

We will now build our Horizontal and Vertical backgrounds:

If all goes well, you should now see the following:

Now, we will need to add the gradient:

You should be able to see the following:

Now we will edit the cosmetics:

You should now be able to see the following:

or if you reverse the Rows and Columns, you will see the following:

Note: we can connect this to our actual data (see our Cryptocurrency Dashboard Full Tutorial).

We will now build our circular Gradient Background.

You should now see the following:

We will now adjust the Table Calculations:

You should see the following:

We will now make some adjustments:

If all goes well, you should now see the following:

Like in the previous example, click on the Color Mark and Edit the Colors; as such, you want to end up with the following:

We will not adjust the cosmetics:

You will now have the following:

Now, if we can repeat this with the Gradient Color (Circle Reversed) and we will have the following:

and boom, we are done! I hope you enjoyed creating this data visualization and learned some cool techniques as well. As always, you can find this data visualisation on Tableau Public at https://public.tableau.com/profile/toan.hoang#!/vizhome/GradientBackgrounds/GradientBackgrounds

Summary

I hope you all enjoyed this article as much as I enjoyed writing it and as always do share the love. Do let me know if you experienced any issues recreating this Visualization, and as always, please leave a comment below or reach out to me on Twitter @Tableau_Magic. Do also remember to tag me in your work if you use this tutorial.

If you like our work, do consider supporting us on Patreon, and for supporting us, we will give you early access to tutorials, exclusive videos, as well as access to current and future courses on Udemy:

Also, do be sure to check out our various courses:

Exit mobile version