Sparkbars in tooltips

You may have read my post on the bar-chart tooltip, or seen it on the Tableau Knowledge Base. That was always something I was proud of. When Tableau released v6, and with it Table Calculations, I suspected there was a way to extend it. Once I had my Tableau European Conference tooltip session approved, I knew it was time to go the extra mile and see what table calcs could do to enhance the tooltip charts.

What could make them better? Tooltip sparkbars showing the month-by-month sales of each product type:

[Why is there no Tableau Public embedded view here? Because my solution, inspired by Chandoo’s excellent Excel blog post, uses custom fonts. These need to be installed on the client machine, so it’s unlikely it’ll work for you without them]

Download the example workbook here. You also need some custom fonts installed. These can be downloaded from Fontstruct.com (bargraph, bargraphs lifted and bargraph2)

The sparkbar tooltip is a way of breaking the detail of one mark (for example, annual sales by state) into the monthly trend. This is a free way of drilling down into the data without requiring another view on the screen simultarneously. The same technique can be used to create a single worksheet view with multiple sparkbars in it. This would be very useful if you are printing executive dashboards, for example:

Want to do this yourself? I’m going to describe my solution. I am not sure my table calculations are the optimal way of doing this, and there are some issues with this technique. If you know a way of improving the technique, please let me know.

We need a calculation the returns a value  for each month’s sales value, normalised so that the highest value is 9 (the highest bar) and the lowest is 0. Sounds simple, sure, but the table calculation is far from pretty:

Ouch. And you need a separate calculation for each member of your Dimension!

It’s got 12 rows, one for each month. The LOOKUP() calc finds the Sales value from the first row in the partition (January) and normalises it by comparing it to the maximum sales value for all months. The STR(ZN(ROUND… stuff tidies things up for display. The end result is a value from 0-9 for each month of the year, if there are 12 values. One big flaw of this calculation is that if some months had no sales, they are not returned as zero: they are simply not there, and your string does not have 12 characters. This could lead to misleading sparkbars. It’s also the reason that the last few rows of the calculation have the if not(isnull(… additional steps.

Once you’ve got there, all you need to do is drop the Measure onto the worksheet, and format it using the bargraph fonts. You’ll notice that they don’t appear in the font list. That’s okay – Tableau only lists the fonts it thinks are useful to you. But sometimes we know better than Tableau, so just type the name of the font instead of picking it from the drop list, and you’ll be fine.

Okay, this is great – are you free to go forth and put this in all your vizzes? Well, not quite. The tooltips will work only if the fonts are installed on the client machine. This applies to Tableau Public, Server, Desktop and Reader. Putting them into the view itself will not work on Tableau Server or Public, but it will work in Desktop and Reader, again only if the fonts are installed locally. These are pretty major caveats. However, if you’re in the business of printing dashboards for people via PDFs, this is a great way to pack a huge amount of into in a tiny space.

Is there an alternative way? Possibly. Alex Kerin (www.datadrivenconsulting.com) has been enhancing his rather excellent twitter sparkbar generator to work in Tableau. This uses Unicode block characters. He’ll be blogging about this soon, so keep an eye on his blog. His method can be used on any machine, but the sparkbars aren’t as pretty as my method. There are trade-offs either way. Here’s a comparison of the methods:

Please let me know what you think – can you see any ways to do this differently or more efficiently?

Keep up with my Tableau updates via my twitter feed (@acotgreave)

Simple v simplistic: if McCandless reworked Minard:

There has been much interesting debate about David McCandless’ Information Is Beautiful this week, initiated by a well written critical piece by Stephen Few. I am pleased he has challenged the orthodox view that McCandless is the answer to the data visualisation industry’s problems.

On both FlowingData and Stephen’s own blog, there is debate about the difference between “simple” and “simplistic” graphics. This is a hard point to describe, and there are two comments on Stephen’s blog (by DR, and Stephen himself) that made me realise that a picture would emphasise the difference. I wondered how McCandless, if the accusation of simplicity is correct, would rework what’s often claimed to be one of the greatest data visualisations.

Consider the classic work by Charles Minard showing Napoleon’s disastrous 1812 march on Moscow. This graphic, I believe, fits Stephen’s definition of simple. Sure, there are many dimensions being displayed (soldier numbers, temperature, location, etc) but once the viewer understands that, the powerful anti-war message is unavoidable. The waste of life is brutally clear and well contextualised by the time location and temperature:

Minard's march on Moscow (from Wikipedia)#

(image from Wikipedia: http://en.wikipedia.org/wiki/File:Minard.png)

If McCandless is to be accused of simplicity, how might a simplistic version look? I think it would be like this:

Why? The simplistic approach tries to strip away as much data as it can. Minard’s main point was the loss of life. The version above shows just that and no more. One could argue that therefore it is more effective. But it isn’t. Minard’s simple graph gives much more context without any fluff and that, to me, is the difference between “simple” and “simplistic”.

Update: Fixed the spelling of David McCandless’ name – sorry about the typos

The journey is the destination

Unlike any other tool I’ve used before, Tableau invites exploration. One can start with a blank canvas and end up who knows where. That’s what makes Tableau fun to use. However strange that word looks when used in a work context, it’s true.

I had a challenge. I needed to produce a handout that compared survey data on two suppliers. We had twenty questions that were asked across 17 different functional areas by a bunch of people. That’s a lot of info.

Back in the old days, I’d have ended up with a gloriously dull pivot table made in Excel. It would have either summarised the data to death, ending up with a one page table that aggregated away any meaning. Or maybe I’d have produced pages and pages of charts that showed the trees but not the forest.

Instead, I connect the data to Tableau and go on a trip.The end results is the trellis above (click it to see the full size version). So why did this particular chart get me excited enough to write a post about it?

Was it because 2,194 marks are being displayed on one page? Partly.

Was it because every single question and answer can be viewed on one page? Sure.

Was it because you can look down a whole row or across a whole column and see exactly where one supplier outperformed another? Kinda.

Was it because it is very quickly clear that the supplier with the black line largely outperforms the grey supplier? Definitely.

Or was it because my client took one look at it and almost fell over because it was exactly what they wanted? For sure.

Actually, the main reason was more than just the above. It was the fact that when I connected to the data, I had no idea what my end result was going to be. I knew it was going to printed out, so had to find a way to keep the page count down. How did I design the trellis? I didn’t – I just had an inkling of what might work, dropped Dimensions and Measures around as seemed relevant, and the end result emerged almost on its own.

And that’s why Tableau works: you don’t need to know where you’re going, just set off and you’ll end up somewhere pretty damn cool.

3D pie charts in Tableau

Earlier today, I posted on the Tableau Forum, suggesting it would be great if Tableau did 3D pie charts. Well, I didn’t think it would be possible, but using some data pre-processing techniques, and hacking the preferences.tps, I’ve worked out a way of doing 3d pie charts in Tableau:

I knew those developers in Seattle would implement this fantastic visualisation technique eventually. Well done Tableau for letting the community take advantage of good quality graphics. I’ll explain how to do it in a subsequent post.

Don’t forget to follow me on twitter to keep up with all the new techniques I discover!

Dynamically choose a chart type

Ujval Gandhi commented on my post about dual axis formatting. He asked if you could use dual axes/parameters to choose between showing a bar and a line chart. Turns out that, yes, you can:

It’s quite a simple trick:

1. Create a Boolean parameter. I called my “Bar or Line”

2. For each measure you are displaying, create 2 calculated fields: one for the bar and one for the line. Here’s the Sales field for the bar:

3. Drop both calculated fields onto the Rows shelf, choose Dual Axes, and Synchronise them.

4. Change the Marks card to show Multiple Mark Types:

5. Set one mark to Bar and one to Line

6. Show the parameter control.

You’re done!

This is quite a nice trick, but I’m not sure why you’d want to do it. I can’t see a way it could be extended to cover other functionality. There are other ways to allow users to show multiple chart types; for example, Alan Smithee has an excellent example of this here. It’s possible that with lots of parameters and calculated fields, you could give the end user more control over what they show.

Dual axes: nice formatting

You’ve built a nice chart using synchronised dual axes (maybe it’s a lollipop chart – as described in my previous posts!). It looks great, but you’re just left with a niggling little design flaw: those dual axis sure take up a lot of space, at the top and the bottom of your viz:

What can we do about this? The first thing I thought of was to format all the Tick Marks and Titles away from the top axis:

That’s no good – there’s a huge useless white banner of dead space at the top of the chart now.

Instead, why not just format each axis to show one of the important parts: one to show the title and one to show the tick marks? This is the end result:

Now I have the best of both worlds – the user’s not aware of any dead space, and nothing gets repeated. To format the axis, right-click anywhere on the axis on the worksheet and choose Edit axis…

On the top axis, leave the Title as it is, and show just the Minor tick marks, making sure they are the same interval as the Major tick marks on the bottom axis:

:

On the bottom axis, leave the tick marks, and delete the Title:

Job done! You’ve maximised your available space and made your users’ lives a bit easier.

Lollipops and page history

In my original Lollipop Chart post, Austin Dahl commented that lollipops are a way of adding page history to a bar-type display. When I tried this in v6.0.2 it crashed my workbook. However, I’ve upgraded to 6.0.5 and it now works. At least, it works in that it doesn’t crash Tableau. Below is a snapshot of my lollipop chart with a page history on Month/Year of Order Date.

And below is David Catley’s implementation using Corruption data:

What do you think? On my example, I think it adds too much noise. However, on David’s, if you scroll to the most recent year, the reduction in the Corruption Index in Italy is very clear. I’ll soon be showing another way you can show historical data more effectively on a ranked bar-style chart.

Lollipop charts: part two

In my previous post, I explained how I stumbled across the lollipop chart as a way of displaying data when the values are all very high. This post reveals how I did it. Those of you who are savvy with the new features in v6 will probably have immediately guessed it was using dual axes. Here’s what my lollipop chart looks like:

What’s the trick? It revolves around duplicating your measure on the columns shelf, as follows:

You need to make sure it’s dual axis. Right-click on the second Measure pill and choose “Dual Axis” to draw each AVG(Satisfaction) on the same pane. Then right-click on one of the axes and choose “Synchronise axis” to make sure they match completely. This step is important because if you add labels to one of the measures, Tableau might stretch one axis to fit the text of the label in.

The next step is to define multiple marks. This feature might be new to you, and doesn’t exactly jump out at you in the user interface. Click on the little drop-down arrow at the right of the Marks shelf and choose “Multiple Mark Types”:

The Mark shelf now has a new row: it will say “All” and have left/right arrows. With the multiple mark feature, you can format all measures at once, or each one individually. What we need to do is set one mark to be a bar (a very thin one) and the other to be a circle, as shown below:

In my example, I have also added colour to emphasise the Customer Segment dimension. You’ll see that each Mark uses a different Dimension. While experimenting with the lollipops, I discovered that if the connecting line is the same intensity as the circle, it overwhelms the circle. By using a lighter palette on the line, things look nicer. I achieved this by duplicating the Dimension, and assigning lighter colours of the same hue to its members.

To label the min/max I turned on labels for just the Circle mark.

That’s about all you need to do. I added some shading and subtle row divider lines to highlight the different states. Finally, I formatted the axes so they were pretty much hidden.

I’ve started using this technique regularly as it engages users, and improves the data-ink ratio without sacrificing interpretation. What do you think?

Lollipop charts: the search for the perfect mark (part one)

Here’s the problem: I am visualising satisfaction rates over multiple dimensions. In almost all cases, satisfaction rates are high (between 70% and 100%). I want a visualisation that allows comparison over multiple dimensions that is also nice on the eye. Below is the result: a lollipop chart. Although I stumbled across this design by trial and error in Tableau, it is a chart type found elsewhere, eg on Chandoo’s excellent Excel blog. What I thought I would do in this post is explain why I think it’s a great chart in this situation and how to do it in Tableau. Note: in this post, I’m using the Superstore data, not my real dataset. In my next post, I’ll explain how to build a lollipop in Tableau. If you can’t wait that long, you could try it yourself as your homework 🙂


To me, it’s a great way to reduce the data-ink ratio while retaining readability. What do you think? Here’s how I arrived at this design.

Tableau’s default visualisation is the bar. What’s the problem with this? Well, when the bars are all very long (as is the case with my data), there’s just too much ink, and it creates an unpleasant Moire effect:

How can we solve this? Well, we can reduce the bars to wafer thin ones, but this looks, well, flakey:

Maybe we should push the size slider to the max (and add a border). This is what I would normally do in this situation. It removes the Moire effect, and isn’t too bad, but boy, there’s now a lot of ink being used:

Given there’s too much ink, maybe the bar itself is the problem. So how does a circle work? Well, the problem is that the circle is a long long way away from the label. When we try and foist this kind of thing on our users, they tell us it’s too hard to relate the circle to the name, even using shaded lines:

We can get round this distance problem in a couple of ways. One is to fix the axis so that it’s range is only as wide as the min/max values:

But we all know that an axis that doesn’t start at zero is a bad thing, right? Well, sometimes it isn’t a bad thing, but it sure makes the states at the bottom of the list look like poor performers, even though they’re actually only 0.6% lower than the top of the list. Best in this case to keep the axis starting at zero. Maybe we could label the circle directly instead:

This still isn’t right: all that white space at the left of the chart seems wrong.

And this was when I had my brainwave. Thick bars are no good and lonely circles are no good. How about making a combination of them both? And that’s how I came up with a lollipop.I think it has the following benefits:

  1. Can be used when all dimension members have high values (i.e. long/tall bars in a bar chart)
  2. Greatly reduces the data-ink ratio while maintaining a clear link to axis labels
  3. All the users I’ve shown it to so far have really engaged with it – they think it’s both pretty and easy to read

I also like the fact that it works if you add more dimensions to make small multiples:

Next time we’ll look at how to build it in Tableau. In the meantime, let me know your thoughts.





Oxford Geek Night: Pie charts

(scroll down to see the slides)

ognI gave a presentation at Oxford Geek Night #20 on Feb 9th. If you were there and have visited the blog because of that session, welcome and thanks for having a look around. If you are new to the blog, you can follow me on twitter (@acotgreave) to keep up with Tableau and Data Viz related things. Or you can subscribe to the blog’s RSS feed.

My session, Pie charts: good or evil, was intended to show people how poor pie charts are at represensting anything other than at-a-glance information. One could argue they fail even for that. This post is a collection of resources I used for the session, in case you want to do some further reading.

I didn’t get to cover some important points in the session. One common rebuttal to the argument is that you could add labels to the pie, showing the percentage. Well, yes, but that’s like admitting defeat. That is an acceptance that the chart alone does not convey the information correctly. If you need to label the slices, then surely you don’t even need the chart itself? And if that’s the case, then you’ve just proven to yourself that a ranked table of text is a better way to display the data, as shown below:

Wikipedia’s pie chart page now has a prominent section describing why the pie is bad.

I also recommend Jorge Camoes’ great blog. He eloquently describes the problems in at least two posts (this one, and this one, for starters).

For more on the specifics of the problems with Google Analytics, visit Coda Hale’s blog.pie v bar

Stephen Few provides some in-depth analysis of the problems with all things circular (pdf). He also describes the significant problem with comparing relative sizes of pies, something I didn’t have time to touch upon in my session. There is a really great description of why size/area of circle is a poor choice at Contrast’s blog.

If you want to find some bad examples of pies, well, that’s like shooting fish in a barrel. Here’s just a few:

The Breakdown of the blogosphere. Six variations on the pie chart. None of them any use. EagerEyes features this infographic in his excellent March Chart Madness post.

I did mention there are some reasons a pie might be a good option. There are at least a couple. If you specifcally need to compare several dimension members against other dimension members, a bar chart doesn’t make that easy. If your pie chart is going to seen for a short period of time, such as during a presentation, and it only has a 3 or fewer slices, then a pie can make a point quickly. In this latter case, don’t put the pie in the handouts – give the user more info with a table or bar chart.

Finally, here are my slides. I’m not sure how useful they are without my words, mind: