Creating gradient charts is not new on Tableau. One example will be Ludovic Tavernier on Greatified - "How to build a Curved Gradient Area Chart in Tableau Software". The Flerlage Twins have also done it not once but twice in "Using Gradient Colors in Tableau" and "Gradient Gradient Area Chart Challenge". Toan Hoang shows his methods in 4 tutorials for pie charts, bar charts, radial bar charts, and half-circle charts.
I do not expect my method to be better than theirs, but it taps on Excel on doing most of the work instead of Tableau. With my method, I am able to create at least 6 different types of charts as has been pictured in the opening of this post. I have used the method for my Iron Viz submission. You can check it out here.
Step 1: Prepare Data in Excel
- Notice there is a "File" and "File ID" column, you can ignore it as I combined several files using PowerPivot for my Iron Viz submission
- Create "Type ID" and "Concat ID" to give each row a unique ID for easy reference.
- Split the value into units good for visualisation as seen in "Value(10)", as a few thousand units is going to likely cause a lag on Tableau. For example, 3800 becomes 38. It will mean that there will be 38 steps of colours for the chart visualising this data later.
- Round up the value using the Excel formula - "=ROUND(I2,0)"
- Use VBA formula to multiple the rows based on the number in "Value (Round)". I borrowed the VBA code from Mr Excel. To know how to run VBA code quickly, you can refer to a post here on Ablebits. Reproduced below for easy reference:
Sub TryThis()Dim i As Integer, n As Integer, m As Long, currentCell As RangeSet currentCell = ActiveCellDo While Not IsEmpty(currentCell)n = currentCell.Value - 1m = currentCell.RowIf n > 0 ThenRows(m + 1 & ":" & m + n).InsertSet currentCell = currentCell.Offset(n + 1, 0)ElseSet currentCell = currentCell.Offset(1, 0)End IfLoopEnd Sub
- Choose the top cell of "Value (Round)". This is because the code refers to "currentCell".
- Run the code. Watch the rows multiply.
- Highlight the blank cells you just multiplied then equate the cell to above and press Ctrl+Enter to populate the cells with data of the row on top of them.
- Create a column called "Gradient", then create unique a list of numbers starting from 1 for each unit. Referencing back to the unique ID created, enter the formula "=IF(A2=A1,K1+1,1)". I have used "A1" and "A2" because that is my unique ID column and "K1" is a reference to the cell on top of "K2".
- Fill in the formula for the rest of the rows in the column.
Step 2: Drag and Drop in Excel
- For Lollipop Chart:
- Note that "File" and "Type" are the reference for the unit or "Dimension" I am visualising. They may be the same since you may have not combined any files.
- Notice that I have used "Density" under Marks for the circle on the lollipop unlike the usual "Circle".
- You can download my Tableau Workbook from Tableau Public if you need to see where I drag and drop each pill for each chart.