Sometimes you just have to have fun with Tableau, and given I was too preoccupied to participate in the Music themed IronViz qualifier, I had to create something music-based, and I saw this and thought, I just had to try. So in this tutorial, we are going to create Neon Bar Charts in Tableau.
Note: This is an alternative type of data visualisation, and sometimes pushed for by clients. Please always look at best practices for data visualisations before deploying this into production.
Data
Load the following data into Tableau Desktop / Tableau Public.
Bar,Value
A,2
B,4
C,8
D,5
E,6
G,7
I,4
J,3
Once your data is copied 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
100,-1
0,-1
100,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 four records for each Bar 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 Calculated Fields and Bins:
Create Path (bin)
- Right-click on Path, go to Create and select Bins…
- In the Edit Bins dialogue window:
- Set New field name to Path (bin).
- Set Size of bins to 10.
- Click Ok.
Position (bin)
- Right-click on Position, go to Create and select Bins…
- In the Edit Bins dialogue window:
- Set New field name to Position (bin).
- Set Size of bins to 0.01.
- Click Ok.
TC_Value
WINDOW_MAX(MAX([Value]))
Index
IF INDEX() <= [TC_Value] THEN
INDEX()
ELSE
NULL
END
Index Columns
INDEX()-1
TC_Position
WINDOW_MAX(MAX([Position]))
Columns
[Index Columns]
Worksheet
We will now build our first worksheet:
- Change the Mark Type to Density.
- Drag Bar onto Columns.
- Drag Path (bin) onto Columns.
- Right-click on the object, and ensure that Show Missing Values is selected.
- Drag this object onto the Details Mark.
- Drag Position (bin) onto Columns.
- Right-click on the object, and ensure that Show Missing Values is selected.
- Drag this object onto the Details Mark.
- Drag Columns onto Columns.
- Right-click on this object, go to Compute Using and select Position (bin).
- Drag Index onto Rows.
- Right-click on this object, go to Compute Using and select Path (bin).
If all goes well, you should see the following:
We now need to modify the Table Calculations for Index.
- Right-click on Index and select Edit Table Calculations.
- In Nested Calculations select TC_Value:
- Ensure that Path (bin) and Position (bin) are checked.
- This will help you densify your data.
You should now see the following:
Now that we have the basics of the visualisation, we will now adjust the cosmetics.
- Click on the >10k nulls and select Filter data.
- Hide the Index Header.
- Hide the Columns Header.
- Hide the Bar Label.
- Set the Column Divider to None.
- Set the Row Divider to None.
- Set the Grid Line to None.
- Set the Zero Line to None.
- Set the Background Color to Black.
We now want to end up with the following:
Now, unfortunately, Tableau does not allow you to set multiple colours for the Density Mark Type, so if we want multiple colours, we will have to create multiple worksheets and align them.
and boom, we are done, you can find my data visualisation on Tableau Public at https://public.tableau.com/profile/toan.hoang#!/vizhome/TableauArtNeonBarChart/TableauArtILoveMusic
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 Visualisation, and as always, please leave a comment below or reach out to me on Twitter @Tableau_Magic.
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:
- Patreon: https://www.patreon.com/tableaumagic
Also, do be sure to check out our various courses:
- Creating Bespoke Data Visualizations (Udemy)
- Introduction to Tableau (Online Instructor-Led)
- Advanced Calculations (Online Instructor-Led)
- Creating Bespoke Data Visualizations (Online Instructor-Led)