© 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_11

11. Working with Multiple 2D Region Plot Segments

Alison Box1  
(1)
Billingshurst, West Sussex, UK
 

In Chapter 5, you learned how to create your own 2D region plot segment by dragging and drawing it within the default guides on the canvas. However, when you first open up Charticulator, there is already a 2D region plot segment anchored on the canvas, and consequently you’re not yet in the habit of adding your own, and indeed as yet you’ve not had any reason to do so. In this chapter, that is about to change because you will learn that one of the benefits of creating plot segments for yourself is the ability to design visuals that use multiple plot segments, in effect creating multiple complementary charts within a single visual.

You may not be surprised to hear that you can create as many plot segments as you require, but what you will also learn in this chapter is that each plot segment can contain a different glyph, and this is one of the many unique features to be discovered when you use Charticulator to generate your visuals. You can see an example of the type of visual to which I’m alluding in Figure 11-1.
Figure 11-1

This visual uses multiple plot segments, each with its own glyph

However, it’s not just the use of different glyphs that is a reason to use multiple plot segments. Each plot segment has its own set of attributes, and one of these attributes is designed particularly to be used with additional plot segments. This is the “Group by…” attribute. Using this feature, you can design visuals that can analyze total values (or indeed any aggregation) across your categorical data, and this is something that we are also going to explore later in this chapter along with its companion attribute, “Filter by….”

Using a Second 2D Region Plot Segment

However, let’s not get too carried away to start. Why don’t we generate just two 2D region plot segments on the canvas and see what we can do with them? To do this, let’s start with a new chart and use our default data: “Year,” “Salespeople,” and “Sales.” Remove “PlotSegment1” from the Layers pane, and then using the Plot Segments button on the toolbar, draw two new 2D region plot segments along the horizontal guides to make two “landscape” style plot segments. Remember you must anchor the plot segments to the guides; see Figure 11-2.
Figure 11-2

Anchor the two 2D region plot segments to the guides on the canvas

Now add a rectangle mark to the Glyph pane and bind your numerical field, for example, “Sales,” to the Height attribute and your categorical field, for example, “Salespeople,” to the Fill attribute. You will notice that the charts in both plot segments show the same data. The purpose of the two plot segments is to make two different charts. What we could do here is change the chart in the top plot segment by binding a categorical field, such as “Year,” to the x-axis and use the Opposite attribute to place it at the top. Then, in the bottom plot segment, we could sort by our numerical field and use the Top alignment. Finally, we could add a legend for our categorical field; see Figure 11-3. Note the legend is added to the chart and not to any specific plot segment.
Figure 11-3

Two different charts in the two plot segments

I don’t know how you feel about the visual in Figure 11-3, but by all accounts, it could be improved. The axis at the top doesn’t work for the chart at the bottom, and there doesn’t seem to be any good reason to show the data in two different plot segments within the same chart. Expressing this data in two separate charts would work better.

The problem is that at the moment we are confined to using the same glyph in both plot segments. However, we might want the glyph in the bottom plot segment to be a different shape, color, or size and have different data bound to it, but at present we don’t know how to do that. If we could use different glyphs for different plot segments, that would give us greater scope in the design of the visual. This is the first time we’ve considered using more than one glyph in any of our visuals, so let’s see how using a second glyph can make the visual a little less predictable.

Using Additional Glyphs

We could, for instance, redesign the bottom chart in Figure 11-3 to use a different glyph and generate the visual as shown in Figure 11-4. Here, we have a reason for the two charts presented together: to compare the salespeople’s performance in each year and the yearly performance for each salesperson.
Figure 11-4

Using separate glyphs for each plot segment gives more scope for the design

To create the chart in Figure 11-4, delete PlotSegment2 from the Layers pane. We must now create the second glyph before we can create the second plot segment that will use it. To create the second glyph, click the plus at the bottom left of the Glyph pane. You will then see a message in the Glyph pane prompting you to create the new plot segment; see Figure 11-5.
Figure 11-5

Creating a second glyph requires a second plot segment

By clicking the new glyph button first and then creating the plot segment, this associates the new glyph with the new plot segment. Now draw the second plot segment as we did before inside the guides of the canvas.

We can now design our second glyph. For this, we used a symbol and bound the “Year” field to the Fill attribute and the “Sales” field to the Size attribute. We could then edit the following attributes of the second plot segment:
  • Bind the “Salespeople” field to the x-axis.

  • Use the Stack Y sub-layout.

  • Sort descending by “Sales.”

Adding a legend for the “Year” field completes the visual. To position the legend correctly, you will need to drag the green anchor handle of the second legend and anchor it to the middle guide on the canvas.

Using Group By…

Let’s now move on to explore another reason to use a second plot segment, and that is to group the data in a categorical field to enable summarization of the data in each group. Consider the visual in Figure 11-6. You can see that in the bottom plot segment, there is a rectangle mark that represents the total year’s sales, while in the top plot segment, sales are broken down into the respective salespeople’s values.
Figure 11-6

Using the Group by… attribute allows you to summarize your data in a second plot segment

To create the chart in Figure 11-6, we can start over with a completely new chart, and because we will need to generate a new scale for the Height attribute in the top chart, we must start with the bottom plot segment that groups the data by the “Year” field. In the new chart, delete PlotSegment1 from the Layers pane, then draw your new plot segment within the guides at the bottom of the canvas.

In this plot segment, we are going to use the Group by… attribute to group the data by the “Year” field as shown in Figure 11-7.
Figure 11-7

Using the Group by… attribute of the plot segment

We can now design the glyph that uses this plot segment and will represent sales for each year. For this, we used a simple rectangle mark, changed the fill color to gray, and bound the “Sales” field to the Height attribute. Notice that the Height attribute defaults to show the average of the sales value, but we want the height to reflect the sum of the sales. To change the function used by the attribute, click into the Height attribute and select the Sum function from the pop-up list; see Figure 11-8.
Figure 11-8

Remember to change the aggregate function used by the Height attribute

To label the total sales value in the rectangle glyph, we used a text mark and bound the “Sales” field to the Text attribute. Note that you must also change the aggregate function used by the text mark. If you want the text mark to show the sum of the sales, edit the Text attribute as shown in Figure 11-9. The final touch to this plot segment is to align the glyphs at the top.
Figure 11-9

You may need to edit the Text attribute to show a different aggregation

You can now create the second glyph followed by a second plot segment that sits at the top of the visual. This is a simple column chart that shows sales by salespeople that we’ve created many times in earlier chapters. There is just one caveat to the creation of the second glyph that is used in this chart. When you bind the “Sales” field to the Height attribute, hold down the SHIFT key while you drag and drop the field into the dropzone of the Height attribute. This is because you must create a new scale for the Height attribute that maps the average sales and not the sum. We looked at managing Charticulator’s scales in Chapter 9. This will complete the creation of this chart.

Filter By…

You will find that mostly if you want to filter the data displayed in your Charticulator visual, you can use the normal Power BI filters such as slicers or the visual level filter. However, there is a reason why you may want to use Charticulator’s Filter By attribute, and that is to analyze different categorical items in different plot segments. Consider the chart in Figure 11-10. It comprises two plot segments, each one showing sales for a different year.
Figure 11-10

A visual showing two plot segments, each filtered by different years

This chart uses two 2D region plot segments and two glyphs. Each glyph is a rectangle that has the “Sales” field bound to the Height attribute and “Regions” bound to the Fill attribute. Then we used the Filter by… attribute of each plot segment, selecting the “Categories” filter type and filtering by each year, respectively; see Figure 11-11.
Figure 11-11

Using the Filter by… attribute

If you want a numerical legend for both charts, the chart must be created using a data axis which we will explore in Chapter 14. You could instead just use a text mark anchored to the rectangle to show the sales values.

Hands-On with Plot Segments and Glyphs

Using the techniques you’ve learned earlier to generate multiple plot segments, to add additional glyphs, and to group your data and indeed all the skills in Charticulator you’ve acquired along the way, why don’t you see if you can re-create the chart shown in Figure 11-1? This visual uses three categorical fields, “Year,” “Salespeople,” and “Regions,” and one numerical field, “Sales.” To help you, in Figure 11-12, I’ve identified the three plot segments that this visual comprises by outlining them in red. Note the use of guides to position and anchor these plot segments, and seeing the Layers pane should also help you.
Figure 11-12

This visual uses three plot segments, three glyphs, and custom guides

How did you do? This was quite a challenging exercise that requires more detailed knowledge of Charticulator, so congratulations if you completed the task successfully. You’re fast becoming a Charticulator expert!

What you’ve learned in this chapter is that by using multiple 2D region plot segments, you can design visuals that are multifaceted, and whether this is to show complementary charts inside one visual or to show ad hoc summarizations of your categorical data, I’m sure you’ll find many reasons to add plot segments to your chart canvas and work with additional glyphs.

However, there is another important aspect of a Charticulator chart that impinges on plot segments and that we’ve yet to even mention in this book. This is the little understood world of Charticulator’s X and Y scaffolds. What are they and why would you need to use them? We will find out in the next chapter.

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

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