Why curved line
Let’s look at a picture, which one do you prefer?
I guess you will more likely pick the left one. In fact, scientific studies have shown that this affection for curves isn’t just a matter of personal taste; it’s hard-wired into the brain. Humans prefer curved visual objects because they signal a lack of threat.
Anyway, this is just a fun fact to indicate that sometimes we can use curved lines to make a viz more attractive.
How to make a curved line in Tableau
This blog will present a quick solution on how to build a Curved Line Chart in Tableau.
The sample data is simple, and we aim to show the accumulative total value across the segment.
Before getting started, we need to think through the task. Firstly, to make the line between two point looks curved, we have to create more points between them. That can be achieved by using self union and create bins to generate more points. Then we need to calculate the Y-axis for the points and make the line curved smoothly. At last, we will edit table calculations to make sure we calculate at the right level.
Alright, let’s get started!
1. Self Union Sheet Entry.
2. Create Calculated Field Path. The number 49 is chosen so that the curve has enough points to be drawn smoothly, and at the same time, not too much to cause performance issues.
3. Create bins from Path, set New field name to Path (bin), set Size of bins to 1. Drag it to the Rows to see what’s going on.
4. Create Calculated Field Point_X. This gives Point_X values from -6 to 6.
5. Create Calculated Field Max_Value. This step aims to create the max value for each Segment.
6. Create Calculated Field Start.
7. Create Calculated Field Sigmoid. A sigmoid function is a mathematical function having a characteristic “S”-shaped curve or sigmoid curve.
8. Create Calculated Field Point_Y based on the Sigmoid function.
9. Drag these fields into a crosstab to make sure we are on the right track.
10. Create the curved line chart.
We are almost there. What’s left is adjusting the cosmetics:
- Set Zero Lines, Grid Line, Axis Ruler, Row Divider Pane, Column Divider Pane to None.
- Set X-Axis to fixed range from -6 to 6.
- Hide all Column Headers.
- Adjust the Size.
- Control-Drag Point_Y from the Rows to Color.
Now you should see this:
Congratulations, you made it! Now you can try to use this trick to play with your data. Also, you can find my viz on Tableau Public.