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.
- 1.
Create separate scales for each measure by binding data to different attributes of the same or different marks.
- 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.
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
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
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
“Current Yr” to the Height attribute
“Previous Yr” to the Fill attribute
“Current Target” bound to the size of a symbol
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
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.
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
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.
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
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.
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.”
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.
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.
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.
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.
Cartesian bullet chart
Polar bullet chart
Dumbbell
Box and whisker
Tornado
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.
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
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
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
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.
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
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
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.