© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
A. BoxIntroducing Charticulator for Power BIhttps://doi.org/10.1007/978-1-4842-8076-8_14

14. Plotting Multiple Measures

Alison Box1  
(1)
Billingshurst, West Sussex, UK
 

So far in this book, you’ve yet to learn how to tackle the scenario of plotting more than one numerical value in a visualization so that you can compare and contrast their values, for example, compare sales in the current year to sales in the previous year or compare a target value against an actual. In this chapter, we will now fill this gap in your knowledge.

Using Charticulator, there are three alternative approaches you can take if you want to represent multiple measures in your visuals:
  1. 1.

    Create separate scales for each measure by binding data to different attributes of the same or different marks.

     
  2. 2.

    Create one scale by binding each measure to the same attribute of multiple marks. This requires managing Charticulator’s automatic scaling of the glyph.

     
  3. 3.

    Use Charticulator’s data axis.

     

In this chapter, we will explore all three of these approaches.

Typically, such data would be represented in Power BI in a stacked or a clustered bar chart or variations on such charts. In a Power BI visual, plotting a number of metrics is straightforward; you just ply the “Values” bucket with all your measures and leave the visual to do the rest. It will even create the corresponding legend for you. You may not be surprised to learn that in Charticulator things are not quite so easy, and this is for two reasons.

Firstly, the method that Charticulator uses to scale the glyph to fit the 2D region plot segment is particularly problematic if the glyph comprises multiple rectangles. We explored this aspect of Charticulator in Chapter 9.

Secondly, and interlinked with the first reason, you can’t plot marks against a numerical axis (well, you can but they will be plotted according to the center point of the mark). We have to use attributes such as Height and Width to drive the plotting of the rectangles.

However, even before we consider how to overcome these problems, we need to step back and think about the conceptual difference between designing visuals where we need to plot just one numerical value and visuals where we need to plot many, in other words the difference between the two types of data schemas, so let this be our starting point.

Data Schemas

When considering the shape of the data that requires plotting on a chart, we can divide the data schemas into two types: “narrow” data and “wide” data. One of the biggest differences between these types of schema is how Charticulator generates legends, so let’s now consider these two schemas and how they will influence the design of our visual.

Narrow Data

Throughout this book up until now, we’ve always built visuals that comprise narrow data; this is where the data contains a single numerical field and one or multiple categories. With narrow data, the glyphs represent categories, not measures. An example of narrow data is shown in Figure 14-1.
Figure 14-1

Narrow data

As we already know, to represent narrow data in a clustered column chart in Charticulator, the numerical field is bound to the Height attribute of the rectangle mark, creating a scale that drives the plotting of the data; see Figure 14-2.
Figure 14-2

Narrow data is plotted by using the Height attribute that generates a single scale

This single numerical value can be represented by binding it to a number of other attributes of a shape or a symbol such as Fill, Width, or Size, and this will determine how the data is visualized. Each time you bind the value to a different attribute of the same shape, a separate scale will be generated. We’ve generated many such charts using multiple scales in earlier chapters.

When building visuals on top of narrow data, we add a categorical legend (known as a column values legend) that maps colors to categories accordingly.

Wide Data

In this chapter, we turn our attention to wide data, that is, data that comprises multiple measures and one or more categories. You can see an example of wide data in Figure 14-3, and this is the data for which we’ll be designing visuals in the examples that follow. You can see that we have one categorical field, “Salespeople,” and three measures, “Previous Yr,” “Current Yr,” and “Current Target.” These measures were created using DAX and were designed to respond to date filters. With wide data, the glyphs represent measures, not categories.
Figure 14-3

Wide data

The assumption is that these metrics can be plotted against the same value axis because they share the same unit of measurement. However, with wide data the measures need not comprise the same unit. For example, you may want to plot sales against quantity. We looked at resolving this scenario in Chapter 9 where we generated new scales using the SHIFT key, or we could use a secondary line plot segment as we will do in Chapter 16. However, in this chapter, we will be considering only data that includes metrics that share the same measurement.

When building visuals that contain wide data, the legend will map a color to the rectangle or symbol representing each measure, known as a column names legend.

Now that we understand the conceptual difference between plotting narrow and wide data, we can move forward and explore the three different ways, as outlined earlier, in which we can represent wide data.

Using Separate Scales

To plot wide data, we could, for instance, bind each measure to different attributes of a mark or symbol generating separate scales. For example, in Figure 14-4 we have bound the following data:
  • “Current Yr” to the Height attribute

  • “Previous Yr” to the Fill attribute

  • “Current Target” bound to the size of a symbol

Figure 14-4

Binding measures to different attributes of a mark and symbol creates separate scales

However, there are two problems with this approach. Firstly, we’re restricted to binding each measure to different attributes, and we quickly run out of attributes. Secondly, it’s not a good representation of the data because it’s not easy to understand the values being plotted.

So let’s look at an alternative way to represent these metrics.

Using the Same Scale

A more conventional approach would be to use a clustered or stacked column or bar chart or any variation on the same idea. Such a chart requires a glyph comprising a different rectangle to represent each measure. Each measure can then be bound to the Height or Width attribute of each mark, creating just a single scale.

In Chapter 9, we learned that if we bind different measures to the same attribute of different rectangles, Charticulator uses the values in the first measure that you bind to generate the scale that is then applied to the other rectangles. All the rectangles will therefore share the same scale. Armed with this knowledge, we can now tackle rendering a clustered column and bar chart using Charticulator to visualize a number of metrics.

Creating a Clustered Column Chart

For this, we will work through the building of the chart in Figure 14-5. What we need to note in this visual is that each measure maps to a different rectangle, and we have two legends: a numerical legend on the left to show the sales values and a legend at the top to map the colors to the rectangles representing the measures.
Figure 14-5

Creating a clustered column chart plotting three measures

As we have learned when exploring scales in Chapter 9, the first step in building this chart is to identify the measure that will determine the scale to be used by all the rectangles. This must be the measure that holds the maximum value, and we will bind this first to the Height attribute of a rectangle. We can see in Figure 14-6 that the “Previous Yr” value for salesperson “Abel” is the largest, so we need to bind “Previous Yr” to the Height attribute before we bind the others.
Figure 14-6

Finding the measure to bind first to the Height attribute

We can now start to construct the chart. Starting with a new chart and the data in Figure 14-6, the first step is to bind the “Salespeople” field to the x-axis.

We now need to assemble the glyph that will comprise three rectangles, one for each measure. These rectangles must be anchored to guides in the Glyph pane. To do this, it’s best to use a Guide X coordinator that will render three vertical guides. Now draw the rectangle that will represent the measure with the maximum value; in our data, that is the “Previous Yr” measure. Draw this inside the vertical guide, changing the Fill attribute as required, and then bind the measure to the Height attribute.
Figure 14-7

Draw the rectangles that comprise the glyph and bind the data

Now draw the second rectangle inside the guides of the guide coordinator. The most important point here is to ensure that the rectangle starts above the top guide of the glyph. The rule is that the rectangle must not be anchored to the top guide. You can then bind your second measure to the Height attribute of this rectangle and change the fill color. You can then repeat for the third rectangle; see Figure 14-7.

What’s lacking now is of course the numerical legend on the left of the chart that will imitate a value axis. You can use the Legend button on the toolbar and select the measure that determines the scale. In our example, we inserted a legend for “Previous Yr.” The legend is limited by being an adjunct of the scale, and as a consequence, although you can change the starting value of the legend using the Domain attribute of the scale, you can’t control at what value the legend ends. You can format the legend by editing the Tick Format attribute using a format expression as described in Chapter 8.

To add the legend that maps the fill colors to the measures, see the section on “Creating a Legend for Multiple Measures” below.

Creating the Stacked Column Chart

Working with the same fields we used in the preceding clustered column chart, we will now look at how we could use a stacked column chart to visualize this data instead; see Figure 14-8.
Figure 14-8

Using a stacked column chart to plot the multiple measures

To generate the stacked column chart, first bind the “Salespeople” field to the x-axis. To compose the glyph, draw three rectangle shapes in the Glyph pane, one on top of the other. The size of the rectangles doesn’t matter, but keep them inside the guides of the Glyph pane. Ensure that the first and third rectangles are anchored to the bottom horizontal and top horizontal guides in the Glyph pane, respectively, but don’t anchor the middle rectangle to the middle horizontal guide; see Figure 14-9.
Figure 14-9

Draw the rectangles inside the guides of the Glyph pane, but their height doesn’t matter

Change the fill colors so you can distinguish the marks. Now bind the measure that represents the maximum value (in our data, that’s the “Previous Yr” measure) to the Height attribute of the rectangle that you want to represent it. Remember that this will determine the scale that will be used by the other two rectangles. Now bind the other measures to the Height attribute of their respective rectangles.

To finish the chart, you could add text marks to show the values being plotted. To add the legend at the top that maps the color to the measures, see the section on “Creating a Legend for Multiple Measures” below.

With both the clustered column chart and stacked column chart, the question has to be asked, why don’t you just use Power BI to create these visuals? You’ve got no issue there with the scaling of the glyphs or the generation of a value axis, so wouldn’t this be an easier option? One reason to use Charticulator might be to use the skills you have learned so far to give these charts a “makeover” (see Figure 14-10), but they are still, at the end of the day, just column and bar charts.
Figure 14-10

A clustered chart and stacked chart given a Charticulator “makeover”

Despite the makeover, the problem still persists that we must work within the confines of Charticulator’s scales. Must we always have to search our data to find the maximum value so we can set Charticulator’s scales? This seems, if nothing else, just awkward. You’ll be glad to know that help is at hand. There is another approach to visualizing and comparing measures that doesn’t involve any scale. This approach means it’s not only much simpler to achieve the visual you require but provides you with greater flexibility in the design of the visual too. I’m referring to the use of Charticulator’s data axis.

Using a Data Axis

Consider the chart in Figure 14-11. Can you spot the difference between this chart and the one in Figure 14-5? No? You’re quite right; there is no difference in the design. However, there was a considerable difference in the way they were generated.
Figure 14-11

A clustered column chart generated with a data axis

The chart in Figure 14-11 was created using a data axis. A data axis is a numerical scale that is put into the Glyph pane and on which you can generate data points by plotting an example of each measure onto the axis. You can then align the marks that comprise the glyph to these data points. This is quite a verbose description of something that is relatively simple to work with.

What you will also discover is that if you use a data axis, you can go far beyond simple clustered column charts and design truly engaging and insightful visuals that are very easy to piece together. However, for the moment, let’s concentrate on the job in hand and see how we used a data axis to build the chart in Figure 14-11.

Starting with a new chart, first we will add a data axis to the Glyph pane. Drag and drop the Data Axis button from the toolbar into the Glyph pane (Figure 14-12).
Figure 14-12

Adding a data axis to the Glyph pane

Now drag each measure onto the data axis, and the measure will then be plotted on the axis using the values that represent the first row in the data. For instance, in our data these are the values for salesperson “Abel.”

Tip

Use the zoom button on the bottom right of the Glyph pane if the first row of the data contains very small values in relation to other values; otherwise, it’ll be very difficult to see where the small value has been plotted on the data axis.

Next, add a Guide X coordinator, anchoring it to the bottom guide in the Glyph pane. You can now draw the three rectangles that will represent each value, anchoring them to the data points on the data axis and the guides; see Figure 14-13.
Figure 14-13

Ensure the rectangles are aligned to the data points on the data axis

You’ll find that as you plot the rectangles on the data axis, the rectangles are scaled accordingly, and a chart is generated automatically along with an instance of the data axis on the left, providing a numerical y-axis on the chart itself.

The data axis shares many of the same attributes as a numerical x- or y-axis with regard to editing the start and end values and formatting the tick labels (see Chapter 7). If you need to edit or remove the measures used by the data axis, use the Data Expressions attribute at the bottom of the data axis Attributes pane.

Note

If you edit the Range “from” and “to” attributes of the data axis, remember to turn off the tick boxes for the Data Axis export properties in the Attributes pane of the data axis to ensure the range doesn’t change on save.

However, there is a difference between a numerical axis and a data axis. The data axis is associated with the glyph, whereas a numerical axis is associated with the plot segment . We can see this more clearly if we change the Visible On attribute of the data axis to “All.” The data axis is now visible in the chart for every instance of the glyph; see Figure 14-14.
Figure 14-14

The data axis is associated with the glyph

Because you usually set the Visible On attribute to either first or last, you only ever see an instance of the glyph that represents the first or last row of the data, and this is how it can be used as a value axis.

Note that the Scales pane does not show a scale for the height of the rectangle because the height is driven by the data axis, not by binding the measures to the Height attribute of the rectangles.

It would seem that we are yet again using Charticulator to create charts that don’t require the trouble of using Charticulator! But if I told you that now you know that the data axis exists in Charticulator, you can design a variety of bullet charts, dumbbell charts, tornado charts, box and whisker charts, and many more, would that get you more interested? Well, these are the types of visualizations that you can use Charticulator’s data axis to render, and so let’s now have a go at doing so. These are the charts we will be generating:
  • Cartesian bullet chart

  • Polar bullet chart

  • Dumbbell

  • Box and whisker

  • Tornado

Cartesian Bullet Chart

The bullet chart (Figure 14-15) uses a categorical y-axis with the “Salespeople” bound to it and a horizontal data axis.
Figure 14-15

A cartesian bullet chart

In the Glyph pane, to create a horizontal data axis, you must draw the data axis along the bottom guide of the glyph. In the Attributes pane of the data axis, change the Visible On attribute to “last” and move the axis to Opposite using the Position attribute.

This chart uses a Guide Y coordinator drawn down the left guide of the glyph. The rectangles for the “Previous Yr” and “Current Yr” measures were then drawn inside the guides accordingly; see Figure 14-16.
Figure 14-16

The glyph used in the bullet chart

The “Target” measure is represented by a line mark, with the Stroke attribute set to black and the Line width set to 5.

Polar Bullet Chart

You can use a data axis with a polar scaffold, and this is how you can generate numerical axes for polar plot segments. Remember, you can’t use a numerical radial axis because we are using rectangle marks. Using the polar scaffold allows you to design an alternative bullet chart; see Figure 14-17.
Figure 14-17

Start with a cartesian bullet chart and then apply a polar scaffold

Figure 14-17 shows you how you can start with a cartesian vertical style bullet chart and then simply apply a polar scaffold to the plot segment. Then change the angle of the plot segment so it lies from 270o to 450o. If you think the ellipse shape works better to represent “Previous Yr” and “Current Yr,” you can change that too.

Dumbbell Chart

The dumbbell chart is a great visual to compare just two metrics, in our case “Previous Yr” and “Current Yr”; see Figure 14-18. Here, we can quickly spot the reverse dumbbells to see when sales were worse for our salespeople in the current year. In fact, only “Charron” and “Reyer” are improving their performance!
Figure 14-18

A dumbbell chart

This chart is particularly easy to produce using Charticulator. You can see the design of the glyph in Figure 14-19. It comprises two symbols aligned to the two measures on the data axis. A line mark then joins the two symbols, anchoring the line to the center of the symbols.
Figure 14-19

The glyph used to create the dumbbell chart using a data axis

You can use the Layers pane to ensure that the line sits behind the symbols by changing the order the elements are listed.

Box and Whisker

The data axis makes the generation of a box and whisker chart very straightforward as long as the data presents itself as wide data; see Figure 14-20.
Figure 14-20

Wide data used in the box and whisker chart

In other words, each of the calculations involved in the box and whisker chart should present itself as a measure in the Fields pane. You can see in Figure 14-21 the box and whisker chart we have built on top of this data.
Figure 14-21

Box and whisker chart

Here, we are displaying our salespeople’s performance across all five years by showing the distribution of their sales, salesperson “Blanchet” having the most evenly distributed sales values.

Using a data axis, in Figure 14-22 you can see the glyph that was constructed to render the box and whisker chart.
Figure 14-22

Glyph used in the box and whisker chart

Once the measures were plotted onto the data axis, it was then only a matter of adding the appropriate marks to build the glyph: a horizontal line for “max,” “min,” and “median” and a vertical line drawn between the “max” and “min.” A symbol was used for the “average” and a rectangle drawn for the box.

Tornado Chart

The last example of using a data axis will be to generate a tornado chart. Because the sales data we’ve been using in our examples doesn’t lend itself to being plotted on a tornado chart, we will use instead data comprising a set of competition scores to compare male and female contestants in different age groups; see Figure 14-23.
Figure 14-23

Data for the tornado chart

The tornado chart is a great example of using two horizontal data axes that diverge from the center of the glyph where the zero point for both axes starts; see Figure 14-24. This will allow us to plot and compare the male and female scores in each age group.
Figure 14-24

A tornado chart

Using a data axis, this chart was straightforward to build, despite its looks. The “Age” field was bound to the y-axis. In the Glyph pane, the two data axes were drawn by anchoring each data axis to the center guide of the glyph, dragging outward to anchor one to the left guide and the other to the right guide; see Figure 14-25.
Figure 14-25

The glyph used in the tornado chart uses two diverging data axes

To ensure that the data axes were visible only on the first instance of the glyph, the Visible On attribute was edited accordingly, and the right-hand data axes were moved to the opposite side. All that remained was to plot the two measures “F” and “M” on the axes and draw the rectangle marks accordingly.

Creating a Legend for Multiple Measures

You will have noticed that a number of our charts have included a legend that maps the color that is used to represent each measure. Charticulator generates legends for wide data differently from narrow data and uses two separate legend types accordingly. The column values legend is used for narrow data and the column names legend used for wide data. We learned how to create a column names legend in Chapter 9. However, to recap on how this is done, use the Legend button on the toolbar as normal, but this time select column names as the Legend type and select your columns using the CTRL key. Notice that there is now a scale in the Scales pane that maps the colors to the measures. However, unlike the other scales in the Scales pane, you can’t click the scale to edit the colors. You must select the Legend in the Layers pane and then use the Attributes pane, clicking on Edit scale colors; see Figure 14-26.
Figure 14-26

Generating and editing a legend for wide data

Reminding ourselves how to insert a legend to describe wide data ends this chapter that explored the different methods to visualize data comprising multiple numerical values.

You have learned that you are limited in the number of different numerical attributes to which you can bind such data and that if you then decide to bind numerical data to the same attribute of multiple instances of a mark, the scaling of the glyph will need to be controlled. The best and easiest solution is of course to use Charticulator’s data axis. This is not only a very simple and easy method of accurately plotting measures, but it provides a workable numerical axis despite the choice of a rectangle mark or a line within the Glyph pane. More than this, it allows you to design visualizations that you may have thought would be more complex to build, such as bullet, tornado, or box and whisker charts. This has been another milestone along the way of understanding how Charticulator works.

Perhaps, you are also learning that Charticulator never fails to surprise us in the richness of its tools that are fit for purpose, and this allows you to design visuals that inform and inspire by unequivocally showing the insights into your data. This leads me to introduce you to yet another one of these tools, and that is a tool that has a rather unassuming name: the link. We’ve used links before, but in the next chapter, we will throw the spotlight on this feature and discover how it can do a lot more than just produce line charts.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.130.201