Can you build a radar chart with map layers?

For this week’s community challenge, we’re recreating radar charts using fellow Tableau Ambassador and Visionary, Johan de Groot‘s, map layers technique, which he has blogged about here.

Modelling the data

I provided 3 sets of data in one excel workbook

  • Gridlines : a basic template to help build the radial gridlines
  • Engagement Survey Data – Filled : for use with the filled area chart radar display
  • Engagement Survey Data – Line: for use with the non-filled line chart radar display

The Engagement Survey Data – Line data contains an extra ‘Dummy’ theme which has values that exactly match the values associated to Theme ID 1. This helps ensure the lines ‘join up’ once plotted.

Each Engagement Survey Data needs to be related to the Gridlines data by a custom calculation of 1 = 1

Building the Filled Area Radar Chart

Model the data as described above using the Engagement Survey Data – Filled data set.

Create a new parameter

pArea

string parameter, which can be populated as a list using the Add values from option, and then removing the Whole Company and Benchmark options. Default to Finance

Create the following fields

Angle

([Theme ID]-1) * (2 * PI())
/ ({FIXED: COUNTD([Theme ID])}) + (PI() / 2)

Radius

[Value]

X

[Radius] * COS([Angle])

Y

[Radius] * SIN([Angle])

Point

MAKEPOINT([X],[Y])

Drag Point to the Detail shelf. Change the mark type to Polygon and add Theme ID to the Path shelf.

Set opacity on Colour to 30% and add a black border. Set the the Background Layers (Maps > Background Layers) to show nothing: untick all options. Also remove all map options ( (Maps > Map Options -> uncheck all options.) Remove row/column dividers.

Create a new field

Area to Display

IF Area = ‘Benchmark’ OR [Area] = ‘Whole Company’ OR [Area] = [pArea] THEN [Area] END

and add to Colour. Exclude the Null option that display (right click -> exclude; this will automatically add the pill to the Filter shelf). Adjust colours as required.

Create a new field

Spokes

MAKELINE(
MAKEPOINT(0,0),MAKEPOINT(AVG(COS([Angle])),AVG(SIN([Angle]
)))
)

Add this to the view as a new marks layer (drag onto canvas and drop when you get the option displayed)

This will create a new marks card – add Theme ID to the Detail shelf.

Adjust the size and colour of the spokes as required.

Create a new field

Outer Points

MAKEPOINT(cos([Angle]), Sin([Angle]))

Add this as another marks layer. Change the mark type to circle. Reduce the opacity to 0% and size to as small as possible. Add Themes to the Label shelf.

(If you wish, you can format the text to wrap a bit, by creating

Label – Theme formatted

REPLACE([Themes],” “, “
“)

and putting this on the Label shelf instead

You can adjust the labels using the label alignment options, but you may need to manually move the labels to get them positioned in an acceptable place.

Create a new field

Radar Labels

IF [Theme ID]= 1 AND [Position] <=10 THEN
MAKEPOINT(cos([Angle])*[Position], Sin([Angle]) * [Position]/10)
END

and add as another marks layer and change mark type to circle. Again reduce opacity to 0% and size as small as possible.

Create a new field

Value Axis

IF [Position]%2 = 0 THEN
[Position] * 10 END

and add to the Label field of the Radar Labels marks card as a Continuous dimension (unaggregated green pill)

To add gridlines, create

Grid Lines

IF [Position]<=10 THEN
MAKEPOINT(COS([Angle])*[Position]/10, SIN([Angle]) * [Position]/10)
END

and add as another marks layer. Change the mark type to polygon, and add Position to Detail and Theme ID to Path. Set the colour to pale grey at 5% opacity and add a darker grey border.

Finally add Value to the Tooltip of the original Point map layer marks card and adjust tooltip. Then make all the other may layers ‘disabled’ so the can’t be clicked on.

Show the pArea parameter and change the values to see the areas change. This is now the core ‘filled’ radar, which you can add to a dashboard.

My published instance of this version is here.

Building the bonus radar chart

If you duplicate the sheet for the radar chart you’ve just made, and change the original Points marks card from Polygon to Line, you will find that the lines don’t join up. This is why we need to adjust the source data to introduce a ‘Dummy’ theme with the values that match the first theme.

Model the data as described above using the Engagement Survey Data – Line data set.

Create all the same fields as detailed above, but some are adjusted as follows :

Angle

([Theme ID]-1) * (2 * PI())
/ ({FIXED: COUNTD([Theme ID])}-1) + (PI() / 2)

There is a slight difference here, in that 1 is subtracted from the count of themes, as we don’t want to be counting the ‘Dummy’ theme, otherwise we get an extra ‘spoke’.

Label – Theme Formatted

IF [Theme ID]<> 10 THEN
REPLACE([Themes],” “, “
“)
END

adjusted to only return labels that aren’t related to the Dummy theme.

When you add the Point field as the first map layer, change the mark type to line instead of polygon to get the display below.

Then continue to build as described above. Adjust the colourings and amount of opacity as you see fit.

My published instance is here.

Happy vizzin’!

Donna

Can you create breadcrumbs for filters?

Lorna set the challenge this week to display ‘breadcrumbs’ related to the filter selections.

Start by building out the basic viz :

  • Category and Sub-Category on Rows
  • Segment and Sales on Columns
  • Order Date (at the Year level), Ship Mode and Region all set to ‘All’ on Filter
  • Profit on Colour.
  • Show the filters on the display
  • Name the sheet Viz or similar

For the breadcrumbs, we need to understand how many of the options in each filter have been selected

Count Ship Modes

COUNTD([Ship Mode])

Count Regions

COUNTD([Region])

Count Years

COUNTD(YEAR([Order Date]))

and then we need to determine what to display based on the counts

BC – Ship Mode

IF [Count Ship Modes] = 1 THEN MIN([Ship Mode]) + ‘ (‘ + STR([Count Ship Modes]) + ‘)’
ELSEIF ([Count Ship Modes]) = SUM({FIXED:COUNTD([Ship Mode])}) THEN ‘All Ship Modes (‘ + STR([Count Ship Modes]) + ‘)’
ELSE ‘Multiple Ship Modes (‘ + STR([Count Ship Modes]) + ‘)’
END

BC – Regions

IF [Count Regions] = 1 THEN MIN([Region]) + ‘ (‘ + STR([Count Regions]) + ‘)’
ELSEIF ([Count Regions]) = SUM({FIXED:COUNTD([Region])}) THEN ‘All Regions (‘ + STR([Count Regions]) + ‘)’
ELSE ‘Multiple Regions (‘ + STR([Count Regions]) + ‘)’
END

BC – Years

IF [Count Years] = 1 THEN STR(MIN(YEAR([Order Date]))) + ‘ (‘ + STR([Count Years]) + ‘)’
ELSEIF ([Count Years]) = SUM({FIXED:COUNTD(YEAR([Order Date]))}) THEN ‘All Years (‘ + STR([Count Years]) + ‘)’
ELSE ‘Multiple Years (‘ + STR([Count Years]) + ‘)’
END

On a new sheet, double click into the section beneath the marks card and create an ad-hoc dimension called ‘dummy’. Add BC-Region, BC- Ship Modes and BC – Years to the Detail shelf. From the Viz sheet you built the chart on, select each filter and set to Apply to Worksheets and select the new sheet. Show all the filters.

Change the mark type to polygon which will make the displayed mark disappear. Then update the sheet title referencing the breadcrumb fields we created. Test the functionality by changing the filter values. Name the sheet BC or similar.

On a dashboard, use a Vertical layout container and add a text field for the title, the BC sheet underneath (set to fit entire view), then add a horizontal layout container and move/add the filters into it. Then add the Viz sheet below, also set to fit entire view.

Format the horizontal container with a grey background then select the option to add hide/show button to it. The button will automatically be a floating object, so move it to where you want it to be. And then that should be it.

My published viz is here.

Happy vizzin’!

Donna

Can you filter a donut without highlighting the pie?

For this week’s challenge, Kyle looked to solve a problem that he’s seen discussed within another blog – how to solve a highlighting problem when filtering donut charts.

I’ve been away on a little holiday abroad for a family wedding, so am on catch up this week. So I’m going to make this as brief as I can as time is limited.

Building the donut charts

Use the steps described in this blog post I wrote for my company to build a donut chart using the dual axis method.

For the Category donut chart, you will need Category on Colour and Sales on Angle of the outer Pie Chart. For the inner circle, you will need to add Sales to Text. Adjust the text as required. Sales needs to be formatted to $ with 0 dp.

For the Sub-Category donut chart, you will need to add Category to Colour. Then add Sub-Category to Detail and click on the 3 dots to the left of the Sub-Category pill and change to also add to Colour.

To adjust the colours, edit the colour legend, select all the options within the same Category. Select a sequential colour palette that matches the core colour for the category, then select Assign Palette. The colours should change to a range of that colour.

Create a new field

# Products

COUNTD([Product ID])

and add this to the Angle shelf. Add Sales to the Tooltip shelf and adjust the tooltip.

For the inner circle, add #Products to Text. Adjust the text as required

Filtering the donut

Add the two sheets to a dashboard. Add a dashboard filter action

Filter Cat

On select of the Category donut, target the Sub-Category donut chart passing in all fields. Keep filtered values when selection cleared.

Stopping the Category donut from being highlighted

Create new fields

True

TRUE

False

FALSE

and add these to the Detail shelf on the All Marks card of the Category donut sheet.

Then create a dashboard filter action

Unhighlight

On select of the Category donut on the dashboard, target the Category donut sheet itself, passing in the fields Tue = False. Show all values when selection cleared.

Now when the Category donut is clicked on, the other segments won’t fade. However, the selection is still visible – the edges of the pie are displayed.

Stop showing the selected section of the pie

For this we employ a trick mentioned in the blog post referenced in the challenge. Create a new field

Dummy

‘Dummy’

and add this the Detail shelf of a new sheet. Change the mark type to polygon so nothing is visible.

Add this to the dashboard as a floating object – make it small and place somewhere inconspicuous

Whilst the selections will still be visible when testing on Desktop, once published to Tableau Public, the presence of the polygon forces the whole dashboard to be rendered server side rather than client side. This reduces the amount of interactivity, and consequently the pie chart segments don’t display when clicked.

My published viz is here.

Happy vizzin’!

Donna