Semi-Circle / Curved Line Chart in Tableau

At the end of last year, I’ve heard someone talking about their resume done in Tableau. I was intrigued. How is it done? What does it look like? The interactivity achieved with filters, tooltips and highlighters must be awesome! It wasn’t until a few weeks ago when I saw a colleague of mine liking someone’s post on LinkedIn about their resume on Tableau Public. Thanks, Alex*, for liking the post and thanks to Priscila Santana, whose resume was my inspiration.

*Alex is a really cool guy who’s a fan of Data Science, Machine Learning, Big Data, cloud and all those things that are big right now. Follow him on LinkedIn if that’s your kind of thing. 🙂

I already have my CV in a PDF. I also have a reasonably good LinkedIn profile, I’d say. So why to create another one? Well, to try something new.

I decided to follow the design of the PDF version: deep dark shades of grey (oh-la-la!) with a Star Wars-y yellow. (They’re not real Star Wars colours, but I like to think this dark grey & mustard yellow combination gives you the feeling.)

Makepoint() & makeline() spatial functions

Anyway, back to the point. Part of my Tableau resume is a timeline. I saw lots of bar charts, very neat dots sitting on a zero line, but I wanted to do something different. With a timeline, I associate a line chart. But my education/working timeline is just partially continuous. Each experience has a start and an end. A bit like when you travel from point A to point B. How about using makepoint() and makeline() on a custom background image with a simple line? Longitude and latitude are nothing else than just X and Y coordinates. I tried. I tried hard. Only after reading how and when makeline() creates the curvature – the longer the distance, the curvier the line – I realised it wouldn’t work. Simply because the points sit on the same latitude. Imagine drawing a line from one point on the red equator line to another. Yes, it’s curved because the Earth is not flat (wait, what?) but it’s curved towards you, and as long as you don’t have a 3D monitor, you wouldn’t be able to see it. Therefore it’s flat against the line.

Image source

Am I going to show you my makeline() fail? No. I overwrote it before saving it. But I created some dummy data to showcase the curvature. It’s showing how I moved from my small village to Prague, Munich, Düsseldorf, Prague, Sydney, Melbourne, and back to Sydney.

See this Tableau’s post on makeline() function that mentions that ‘MakeLine generates geodesic lines, which will display as curved when connecting locations that are far apart on the earth.’

Trigonometry, here I come

Because my idea to makeline() failed, it was time to search a bit more and bend something else for my needs. I would like to mention here that I was terrible at maths at school and that’s why I studied marketing & PR, so I don’t have to deal with that stuff anymore. Fast forward, here I am, diving into trigonometry on Sunday evening for fun. To be honest, I didn’t have to do it all by myself. First, I got help from the YouTube tutorial below, second, Jirka was kind enough to explain what I need to change, how and why.

First of all, I found this YouTube tutorial for creating curved line chart, which I followed to the t. It did almost everything I needed – except for the length of the semi-circle. In this tutorial, the range is per year, and each year is the same length. In my case, each line needs to be of a length corresponding to the experience.

YouTube link

I’ll try to explain how it works as straightforwardly as I can, so you don’t just blindly follow the steps. The tutorial takes only the year of the order dates. YEAR() function in Tableau returns an integer; therefore the axis is no longer based on dates but numbers. The line’s top point is in the middle, and the middle is the max year. The start and end point are offset accordingly by ‘half a year’ to create a full year. (Because they all show an entire year, it doesn’t really matter what the diameter is, it’s always the same length.)

Curved line chart step-by-step

Step 1: Date prep

First of all, I had to prep my data. To make my life easier, I decided to start and end all my experience on first of the month as I want my date line to be on month and year only. Each row has a start date and an end date in a Tableau friendly format: yyyy-mm-dd. Depending on the locale, computer/server setting and the current Moon phase, date format can be dd/mm/yyyy or mm/dd/yyyy which can make your first of month into a very busy January.

For each date, I calculated its decimal counterpart, decimal midpoint and decimal distance between the start and end.

The idea behind dividing by 12 is a number of months in one year. Diving by 2 is to have an equal distance from the midpoint. Simple.

  • Start_dec/End_dec formula: year + (month / 12)
  • Mid_dec formula: (Start_dec + End_dec) / 2
  • Distance formula: (End_dec – Start_dec) / 2

Step 2: Path sheet

Create a new sheet in your Excel (or use a clipboard solution as in the YouTube tutorial) for the path calculation.

Step 3: Join your table with the Path sheet

Create an inner join and join the tables on a calculated field (see below).

Step 4: Create new calculated fields

  1. Path (bin)
    • Right-click on field Path > Create > Bins… and set bin size to 1.
  2. Index (path)
    • INDEX()
      • computed along table (across)
  3. TC_Height
    • WINDOW_SUM(SUM(1)) / 2
      • computed along table (across)
      • 1 can be replaced by a field or an if statement as in my case: 1 for Work, .5 for Project, .2 for Blog and -.5 for Internship and Education
  4. TC_MidPoint
    • WINDOW_MAX(MAX([Mid_dec]))
      • computed along table (across)
  5. X
    • COS(RADIANS([Index (path)])) * WINDOW_MAX(MAX([Distance])) + [TC_MidPoint]
      • computed along ID – this is one of the main changes from the tutorial
  6. Y
    • SIN(RADIANS([Index (path)])) * [TC_Height]

Step 5: Bring in the fields

  • Change mark type to line
  • Drag Path (bin) to Path
  • Drag X to columns
    • Right click > Compute Using > Path (bin)
  • Drag Y to rows
    • Right click > Compute Using > Path (bin)

Step 5: Formatting

This last step is up to your preferences. I made the lines thin, coloured them by type (work, project, blog, education and internship), changed and formatted the axis (especially to show that I have a few ongoing things), got rid of all the lines… I played around with the tooltip and annotation for some insight. Feel free to download this workbook from my Tableau Public profile.

Leave a Reply

Your email address will not be published. Required fields are marked *