Making the Kraken. Part 2: In Tableau

kraken finished

This is the second part of the story about how I made the Kraken, the winning entry in Tableau’s internal art competition. In part 1, we got the tools to make circle charts, and a fantastic Kraken image. In this part, we’ll look at how I took the data and made the final image. We’re going to learn about the internals of a Tableau file (XML), how to hack those internals, and some of the limitations to the way Tableau works.

First tries

Here’s the data, alongside the final image I used. I must have made 15 or 20 different configurations of the kraken image before I was happy.

My packed circle Kraken data source

From there, you might imagine it was simply a case of connecting and creating a scatter plot in Tableau, right? Wrong. First off I had to create a calculation to calculate the area of the circle. Below is the first sight of my data:

The first look at the data in Tableau

Not bad, eh? But far from what I wanted. There are many problems to solve.


I have colour in my data source and I need to encode each circle according to the colour value in the data. This was my first sinking moment – Tableau can’t do that. But I do have something of a reputation as someone who’s not afraid to break open a TWB file and edit the XML directly. It was time to crack open the text editors.

Hacking the TWB files is fun but do it at your own risk! Tableau don’t specify the format of the TWB files, so you are on your own when attempting to hack it directly. That said, the structure’s pretty easy to work for most things. In this case, I created a file that set some custom Colours on a dimension, saved it, and opened it in a text editor. Here’s what I saw:

How Tableau encodes custom colours with XML

Every colour can be encoded with a simple XML pattern. Excel is my friend, along with some data and the ever trusty CONCATENATE function:

Using Excel to quickly encode 5,000+ colours

That XML column can be copied directly into the TWB file. Save it, open it up in Tableau and now put Colour onto the Colour shelf. Progress:

The Kraken takes shape!


Take a look at the circles above. They don’t scale quite as you’d expect. Getting this bit right was the hardest and made me realise there’s something unusual going on when you do circles on a scatterplot. Surely, if I’ve calculated Area based on [Radius], then Tableau should size the circle according to that value?

Well, not quite. It’s also influenced by the slider:


And the size ranges dialog:


And the available space on the screen.

In fact, getting this bit right was the most manual process. In the end, I had to put the view onto a fixed sized dashboard, and tinker until it felt right. One thing I discovered is that it’s simply not possible to get Tableau to scale the circles “accurately” by the area calculation. My image was never going to have no overlaps in the way the Percolator output does. But you know what? Tableau’s wacky drawing algorithms was creating a different kind of aesthetic that I found equally appealing.

Finally, I am getting really close. My Kraken is looking pretty good:

Almost there – just sorting the circles to go

Finishing touches: the z-order of the circles.

What’s wrong in the picture above? Well, the eye’s aren’t visible, and there’re lots of blue circles overlayed on top of the Kraken’s tentacles and the submarine. Tableau doesn’t will draw circles in a scatterplot in the order that they are sorted. But here I have 5,000 of the damn things. I’m not going to battle Tableau’s manual sort dialog box:


That way lies madness! Instead, it was back to the XML editor. I selected the circles I wanted bought forward, exported the data, and created some XML to encode the sort order inside the TWB file. It was a similar process to the colour encoding, outlined above.

It’s done! Kraken image ready for entry

At some stage, I knew I’d done enough sorting of the circles. Maybe it was when the clock struck 3am. And I was done. I’d gone from a PC Viz Challenge, and grown the seed of an idea into a fully matured final picture. I was really pleased when I sent the entry for our internal art competition. And overjoyed to hear I won!

This process was great fun. What should you take away from it? Doing something like this will teach you more about Tableau. Knowing how it works under the hood, or discovering how packed circles behave will help you make better pictures. Hunting around the web will also inspire you to make new contacts and discover new ways of seeing data.

I hope you’ve been inspired by these posts – if you’re going to make some art out of Tableau, let me know on twitter (@acotgreave)


JISC: how an offensive tweet helped the data viz revolution

Back in November, JISC InfoNet published the results of its survey of BI solutions in Higher- and Further- education. A snaphot is below.

Being someone who is passionate about good quality visualisations, I rattled off a couple of less than complimentary tweets about this. Here’s one:

JISC got in touch with me privately and they were rather upset at my offensive comments. I apologised on twitter the following day, but behind the scenes, we explained why 3-D exploded pies are not a good idea, pointed them to some books (Stephen Few, Tufte, etc) and suggested that Tableau could achieve better, cleaner results. That cleared the air, and was the last I heard about it.

Until a couple of days ago.

JISC got back in touch to say they are now using Tableau for their visualisations (click here to see their first workbooks) I am absolutely delighted about this result. They have come up with some great visualisations, and have even blogged about the experience here. I feel totally relieved, too, that what started with a dodgy tweet has ended up with more converts to the ways of better data visualisation!

Text-labelled bars: beyond the default

By default, Tableau won’t label a bar. The axis is enough for viewers. However, a lot of our users say to us, “We like the bar, but we want to see the numbers as well“. Rather than reproduce a bar chart as a table, labelling the bars is the obvious way to go. Tableau provides an obvious way to do this, but this viz below shows 3 other ways you can label the bars.

Example one in the above viz is the default – just copy the Measure that’s on the Columns shelf to the Text shelf of the Marks card:

Default text

In Example two, I’ve added Color to the Marks shelf to get a stacked bar chart. By default, the Text marks would now appear in each segment. If you still want the total label visible, you need to add a Reference Line. Right-click on the axis and choose Add Reference Line…

You then need to add a Line with the following settings:

Totals Reference Line

That’s cool – you’ve done some labelling that is outside of Tableau’s default behaviour. What if you want to add some allowable bling to your chart, ie do something visually attractive, but stick to the principles of good visualisation? Well, you can put the text label inside the bar.

The third example, with the white text inside the right-hand edge of the bar, is also acheived with a Reference Line. To do this, create a reference line with the same settings as the previous example.  Now select the Reference Line and choose Format…

Format Reference Line

On the Format panel, set the Reference Line Label Alignment to Left-Align (horizontal) and centrally aligned (vertical). Change the Shading to 0% and the Font to white. Bingo! Your text is now inside the right-hand edge of the bar.

The fourth example, aligning the text at the left-hand edge of the bar, next to the category label, was something of a quest for me after seeing that it can be done relatively simply in Excel. To achieve this, we need to twist some of Tableau’s other functionality to suit our needs!

The first step is to remove the Measure mark from the Columns shelf, and put it onto the Text shelf. Yes, that means we have just created a table, not a chart. Stick with me, we’ll get there. Now put a copy of the same Measure onto the Size shelf. Still looking a bit wacky? Ok, the final step is to change the Mark type from Automatic to Bar:

Left-aligned text in a bar

You should now have your left-aligned labelled bar.

The techniques for examples 3 and 4 can enhance your Tableau charts. There are some restrictions to these two though:

  • They only work on horizontal bars
  • If one value is very low, the label may not appear correctly
  • For the left-aligned text (example 4), it works best with a big range of values.

You may also have noticed that I have hidden the axes on all of the charts above. I believe that if you are going to put text-labels on the bars, it’s bad practice to also show an axis.

To get a better idea of how to do this, download the workbook to see how I built it all up.