My no-code way to label any radial in Tableau
Although it may seem like a small thing, nicely designed labels can greatly improve the appearance of a chart, especially if that chart is a radial one. Arranging labels in a circle and designing them is not an easy task in Tableau, but it is doable. In this post, I will share my way of doing it.
We will discuss how to make radial labels in two cases: when we need to label segments of a given size and when we need to label points with given degrees.
The segmented graph we’ll label is a radial heatmap of average monthly temperatures in European cities in 2019. It was created using Tableau Visionary Will Sutton’s heatmap generator:
The point graph we’ll label is a radial bar chart of the scatter of average daily temperatures in European cities in 2019. You can learn more about how to create this type of graph from Tableau Visionary Kevin Fleurlage’s tutorial:
Please follow the GitHub repo if you want to download a Tableau Public notebook with the finished graphs or the underlying datasets (I obtained the initial temperature data for them from Kaggle).
To label a radial in Tableau, we will need:
- the Ladataviz.com website for generating labels;
- the open-source vector graphics editor Inkscape for designing them.
Creating labels on Ladataviz.com
Heatmap labels
We can’t create a radial heatmap on Ladataviz.com, but we can create a radial chord diagram whose labels will be automatically placed at the centers of its segments at the appropriate angles. The idea is that we’ll create labels for a chord diagram and then substitute them into the heatmap.
Find the Chord Diagram Generator within Tools > AdvViz > Chord
. This type of diagram divides a circle into segments based on their percentages and shows the flows from one segment to another. The size of each segment equals the sum of its incoming and outgoing flows. The segments are plotted clockwise, starting with ‘12 Midnight’:
To build the diagram, we need to upload a dataset to the site. If you click the question mark above the Choose File
button, a pop-up window will describe what this dataset should look like: it should have a source column, a target column, and a value column.
Here we are not interested in flows, but in the ratio between segments to allocate their labels correctly. The sizes of the Black
, Blonde
, Brown
, and Red
segments of the above chord diagram (i.e., the sums of their incoming and outgoing flows) are 29 630
, 20 230
, 40 290
, and 9 850
, respectively. To achieve an identical arrangement of the chord segments and their labels, it is enough to specify each segment as both a source and a target of a single flow and indicate its size:
Below is a chord diagram created from this dataset. The absolute size of each segment has doubled (as it is both the source and target of a sector-sized flow in our table), but since this happened to all segments, their percentages and locations are unchanged from the original diagram:
Thus, to place labels around a segmented radial graph, we only need to know how the sizes of its sectors (intended for labeling) relate to each other. In our case, the heatmap consists of 37 equal-width segments, corresponding to the number of European cities in our dataset:
We can specify the size of each segment simply as 1
. Or as 100 — the main thing is that the value should be the same for all segments. This is what our label dataset should look like (the full version is available on GitHub):
Upload the label dataset to the Ladataviz Chord Generator. Set the Width
and Height
to 700
and the Margin
to 85
. Reduce the Padding
between segments to 0
. Now all the labels are equally spaced and fit on the canvas:
Download the resulting chart in SVG format.
Bar chart labels
We know that the labels appear exactly in the centers of the chord segments. But what if we want to label several points located at certain degrees? For example, to build a radial bar chart, I calculated the angle in degrees for each bar to place it correctly. This angle is all I have now to calculate the label placement:
Here, another property of the chord comes in handy: even if the segment size is 0, the label is displayed. This means that we can label not only the segment centers but also the gaps between the segments. We will ‘fill’ the distances between our points with segments of the appropriate size. Then we’ll insert a zero-size segment into each gap and create a label for it.
Here’s how it looks with our default chord diagram. The labels should appear next to four points located at angles of 73°, 198°, 288°, and 342°:
We need to arrange the chord segments so that the gaps between them are at the specified degrees. That is, create something like this:
How do we achieve this? First of all, since a chord is 100%, let’s take 360 degrees as 100%; that is, the sum of our segment sizes should be 360.
Imagine that we have a 360° dial with four hands that we need to move from zero to certain degrees. We will move them by inserting chord segments in front of them.
- The first hand,
Brown
, should be located at an angle of 73°. To move our hands from zero to this position, we add asegment of size 73
in front of them. Now all our hands point to 73°, where theBrown
label is located. - The second hand,
Black
, should point to 198°. We leave theBrown
hand at 73° and move all the others to 198°; that is, add asegment of size 198–73=125
in front of them. Now one of our hands points toBrown
73° and three toBlack
198°. - The third hand,
Blonde
, should point to 288°. We leave theBlack
one at 198° and add asegment of size 288–198=90
in front of the remaining two. Now one hand points toBrown
73°, one toBlack
198°, and two toBlonde
288°. - To position the fourth hand,
Red
, at the desired angle, we leave theBlonde
hand at 288° and add a segment ofsize 342–288=54
in front of the remaining hand. Now one hand points toBrown
73°, one toBlack
198°, one toBlonde
288°, and one toRed
342°. - But that’s not the end! Now the sum of our segments is
73+125+90+54=342
, while the full dial should be 360°. Therefore, we add another segment after theRed
hand, the size of which will make up the missing difference:360–342=18
.
Now all our arrows point exactly in the right direction.
How to apply this to our chord?
The chord will consist of two types of segments:
Radius
segments with given degrees. We will set their size in thevalue
column as0
. Such segments will not be visible on the chord diagram, but their labels will be;Gap
segments with calculated sizes. With their help, we will place our radii at the desired angles.
The table below shows how we calculate the Gap
segment sizes based on the degrees specified for the Radius
segments. It essentially follows the five-step algorithm described above:
After calculating the Gap
segment sizes, we place the Radius
segments between them. This is what the final table for Ladataviz.com looks like:
After uploading this type of dataset to the site, it is important to select None
in the Sort
drop-down menu in the Nodes
section. After adjusting the margin and padding, we get a graph similar to the one below. Each of its segments — both the full-size Gap
and the zero-size Radius
— has its own label. During further processing, we should keep only the labels of the Radius
segments and get rid of the rest:
Let’s apply this method to label our radial bar chart:
Its labels should be identical to those of the heatmap, but now we know not the sizes of the segments but the angles of the points that need to be labeled:
All points are equidistant from each other. The only exception is the arc between the last (Zurich) and the first (Amsterdam) one; it is divided into two parts by the 0°/360° point. Therefore, we need to create two segments: one will be located between 0° and the first point, and the second between the last point and 360°.
This is what the label table for Ladataviz.com looks like (the angle_degrees
column is optional). Each Gap
segment is followed by a corresponding Radius
segment; the last Gap
segment brings the sum to 360:
Upload this label dataset to the Ladataviz Chord Generator. Set the Width
and Height
to 700
and the Margin
to 85
. Reduce the Padding
between segments to 0
. Finally, in the Nodes
section, in the Sort
drop-down menu, select None
. The segments are now sorted in the same order as in our dataset, with the Gap
segment followed by the Radius
segment:
We only care about how our Radius
labels are placed on the canvas; we will get rid of the Gap
labels in the next step of graph processing.
Download the resulting chart in SVG format.
Designing labels in Inkscape
Heatmap labels
Let’s open the heatmap SVG file in Inkscape. Below, you can see what the interface looks like. The graph will be displayed on the left side of the screen, and on the right, there will be an editing panel. At the top of this panel, click the Layers and Objects
tab. Inside, you will see two folders:
Inkscape automatically splits SVG files into layers and elements; it also groups elements of the same type into folders. There is just a nuance with the Ladataviz.com chord diagram: Inkscape reads the labels along with the black polygons and places them in one folder, and the purple paths in another. Check the contents of both folders: in one, the elements will alternate as text-path-text-path; in the other, there will be only path elements. Delete this last folder as it is not needed. All the purple insides of the diagram should disappear:
Open the second folder, where the text-type elements are. Click on any element; it will automatically be selected on the graph. If you delete it from the folder, it will disappear from the graph as well.
Select and delete all path elements from the folder, leaving only the text ones:
The elements in the folder are arranged from bottom to top in ascending order; that is, at the very bottom of the folder is the first label clockwise from ‘12 Midnight’ (Amsterdam).
Bar chart labels
The only difference between processing bar chart labels and heatmap labels is that when designing the former, we need to get rid of all Gap
labels:
So after you remove all the path elements, select all the text Gap
elements (in my case, these are all odd numbers), and delete them. The result should be identical to that of the heatmap:
Changing the font
Further processing is the same for all radials, so I will use a heatmap as an example.
Let’s change the font of the labels. Select all the text items in the folder. To do this in Windows, hold down the Shift key and select the first and last folder items. One of the tabs next to Layers and Objects
should be Text and Font
; open it and its Font
sub-tab. In the Font family
window, you’ll find all the fonts available on your computer. If you want to add a font — for example, one of the Google Fonts — install it on your computer and restart Inkscape. The font should then appear in the Font family
window. I chose Bebas Neue
.
In the Style
window, you can choose the font style — regular
, semi-bold
, bold
, etc. — if you installed different versions of the font on your computer. At the bottom, choose the Font size
— I chose 16
. The text with the selected settings should appear in the demo panel below. Click Apply
and see how our labels look now:
Changing the font color and stroke
Go to the Fill and Stroke
tab. There are three sub-tabs in the tab: Fill
, Stroke paint
, and Stroke style
. If Fill
is empty and says Paint is undefined
, click on the filled (Flat color
) square; after that, a color wheel should appear in the tab. In the RGBA
field, change the eight-digit HEX code from 000000ff
to 484848ff
(the last two letters indicate the transparency level; so ff
is 0% transparency).
Be careful; when you click the commands, the currently selected text will be processed. Before changing the color, check if all the labels are selected:
In the Stroke paint
sub-tab, we can add a stroke to the text. I want to outline the names of two cities: the one with the recorded minimum average monthly temperature (Moscow) and the one with the maximum (Madrid). In the heatmap, I use the Viridis
palette, so I will take the extreme colors of its spectrum: yellow #fde725
for Madrid, and purple #440154
for Moscow.
In the Layers and Objects
tab, select Madrid (in my case, it is text56). Next, go to the Fill and Stroke
tab and the Stroke paint
subtab. Click on the filled Flat color
square. In the RGBA
field, insert fde725ff
. A yellow outline should appear around the label ‘Madrid’ on the canvas. We can make it thinner or thicker. To do this, go to the Stroke style
subtab and set the width of the outline in the Width
field. I set it to 0.5px
. We do the same with Moscow, outlining its label with the color 440154ff
:
Export of ready-made labels
Our labels are ready to be transferred to the dashboard. To do this, we export them as a PNG image.
In Inkscape, an object is exported using the File > Export
command. Once clicked, the export options will appear in the right panel.
You need to be careful here, as Inkscape will export the currently selected object and everything on it. To export our 700 x 700 canvas and its contents, deselect the labels by clicking on the canvas. If the labels remain selected, they will not be exported within the 700 x 700 boundaries but within their own xmin, ymin, xmax, ymax
boundaries. You can also place a rectangle under some of the content, select this rectangle, and export it along with the content inside it.
The current selection is displayed in the right panel. You can make it larger or smaller by changing the DPI
. You can also set the Background color
or leave it transparent. At the bottom, specify the file path
and format
, and then click Export
:
I also recommend saving the SVG file itself as you work using File > Save
. That way, you can reopen the SVG in Inkscape later and continue working on it.
Adding labels to the Tableau dashboard
In Tableau, we can overlay the graph on an image with labels either on the dashboard or on the graph sheet.
The simplest way is to do this on the dashboard. Just select Image
in the Objects
section and place it as you need, then place your graph on top of it. That is, I created a 700 x 700
dashboard, and then, when importing my label image, I specified Fit Image
and Center Image
. Then in the Layout
section, I reduced the Outer Padding
of the image and of the dashboard from 4
to 0
and from 8
to 0
, respectively.
In fact, my label image became the background image for the entire dashboard. On the top of it, I placed my graph in floating mode; its parameters are 516 x 516
, and the left and top paddings
are 92
:
The second way is to add a background image directly to the chart. This method is more complicated, but it might be useful if you want to make the chart and its background change when changing the filter.
Go to the chart sheet. First, let’s increase the chart canvas size so that the labels also fit. Our heatmap’s xmin
and ymin
are -1
; xmax
and ymax
are 1
. Right-click on Longitude
on the Columns Shelf
and check Show Header
. Right-click on the axis that appears, then Edit Axis > General > Custom
, and set the Fixed Start
to -1.4
and the Fixed End
to 1.4
:
Do the same with Latitude
.
Next, go to Map > Background Images
and select your dataset. In the window that appears, click Add Image
, then Browse
and find your label image. Set the image’s xmin
and ymin
to -1.4
and xmax
and ymax
to 1.4
.
In the same menu, in the Options
tab, select Always Show Entire Image
. Click OK
.
The labels should now surround the heatmap right on the chart sheet:
On the 700 x 700 dashboard, simply specify the chart parameters as 700 x 700
and set all the paddings
to 0
:
I just described my method for labeling self-created radials. If you want to label one of Ladataviz.com’s radial graphs, you can download the SVG with labels in addition to the CSV or Tableau Public file, process it in Inkscape in the described way, and then upload to Tableau.
Let me also recommend a couple of useful resources on the topic:
- A video tutorial on how to export PNG files from Inkscape goes into more detail about different export parameters.
- A tutorial on how to switch an image with a selection in a Tableau Dashboard will be of help in case you want to create switchable labels.
Happy viz creating!