Link

About Slopegraphs and Bumps Charts

Hey everyone! Today’s post answers a request from one of our readers and features two not-so-common visualizations that you can use to make time comparisons: slopegraphs and bumps charts. Although these objects have a very simple nature, they’re also quite elegant and intuitive, so there’s a good chance that they will help you get some unexpected insights in your analyses.

We’ll also discuss one or two tips that can help you improve their readability and make them more meaningful by adding extra context to the data. As requested, the football dataset that we’ve been using lately will give life to our examples! 😉

Slopegraph

Slopegraphs are a great way to compare two points in time. However, instead of describing the ups and downs along the way like traditional line charts, they focus on how the journey started and how it ended. This visualization is the perfect candidate for “then and now” analyses (much like that TV show that presents celebrities and how they looked 30 years ago). * Note to self: stop making that kind of references, people will laugh at you. You should recommend Cole’s blog instead. *

When working with these charts, our brain can easily spot patterns and recognize the distinctive slopes of certain elements in terms of direction or magnitude. It is also an intuitive way of showing how the rankings changed from a point in time to another, as the lines will intersect each other and end up in a different order.

26_01

In this example, we can visualize the performance of all the teams in the Premier League over the last two seasons. Each squad is portrayed by a line and its position and slope depend on the rank achieved in both the 2015 and 2016 tournaments. In order to improve the chart’s readability, you can highlight the selected team by adding some color and changing its line’s width.

26_02

* Fun Fact: This chart is so cool that it made it to the cover of one of my favorite books about data visualization, The Functional Art by Alberto Cairo.

26_00Tutorial

As usual, you can download the QVW and the rest of the materials here.

1.- Let’s start by creating a simple line chart using Season and Team as dimensions and only(Rank) as expression. Remember that the first dimension always goes to the axis and the second one is represented with multiple colors.

26_03

2.- Remove all the unnecessary elements in the chart:

  • General: Show Title in Chart
  • Dimension: Turn off the Label box
  • Presentation: Show Legend
  • Axes: Hide Axis
  • Layout: Use Borders
  • Caption: Show Caption

26_04

3.- The first problem we have to solve is that the chart is upside-down (well, kind of). Even though the best teams have the lowest rankings, we want to see them on top! In order to achieve this, let’s modify the expression by changing the rank’s symbol:

26_05

4.- Sadly, this trick brought a little side effect: the popups will now display negative numbers. But don’t worry, we can easily fix this.

26_06

Go to the Numbers tab and select Integer. Now, change the Format Pattern located in the right side to #,##0;#,##0;

26_07

This will force QlikView to display both positive and negative values in the same way (Dirty trick, I know).

5.- Our visualization is looking good, but clearly we don’t want to display every single season at once. In order to filter only the first and last possible values, we’ll have to rely on our old friend Set Analysis:

26_08

Since Season is a dual field (text and number at the same time), we can literally ask QlikView to filter the Min and Max values. Don’t forget the dollar sign expansion and the single quotes for the resulting string!

26_09

6.- My favorite thing about this chart is that, even though you focus on just one team, you don’t lose the context given by the rest of the lines. Therefore, it is easy to identify distinctive elements in terms of directions or slopes. However, QlikView’s nature isolates the selections leaving us with something like this:

26_10

We need to tell QlikView to “ignore” the selections made in this particular field so we always visualize all the squads. The solution [once again] is Set Analysis:

26_11

7.- Now let’s talk about the colors. Since Pick-Up Sticks charts are incredibly hard to read, I’d recommend to use gray for the “context” lines and a brighter color for the selected team.

26_12

Get it? Pick-Up Sticks Chart? Anyone? *Sigh* 

Go to the Expressions tab and type the following formula in the Background Color box:

26_13

26_14

The first condition verifies whether there’s a selected team or not. If the user only picked a League, all the lines will remain gray so he can choose any team that strikes his attention. The second part is a little bit trickier as it calculates the length of the string for each element without using any Set Analysis. Since our original expression disregards the selections made in the Team field, we’ll always see all the values. However, len(Team) will only return a value for the “active” elements. Therefore, only the selected team will be colored.

26_15

8.- How about we give a little twist to the color expression? Let’s change it so that it turns green or red depending on the nature of the slope (positive or negative).

26_16

The condition is fairly simple; you just have to check is the rank for the latest season was better than the first one. The $(=) syntax asks QlikView to calculate the color “outside” the chart and then just insert the result in the expression.

26_17

9.- In order to lighten up the chart a little, we can also change the width of the lines using the Line Styles option in the Expressions tab.

26_18

26_19

Don’t forget: <Wn> for width, <Sn> for the style!

10.- Go to the Axes tab and check the Show Grid option for the Dimensions Axis.

26_20

11.- Finally, add some extra stuff to your visualization. I chose a couple of text objects with the rank, points and goals for each season, the team’s logo and a couple of filters.

26_21

 

Bumps Chart

If you remove the Season filter in the expression you can turn this object into a Bumps Chart, a visualization that lets you analyze the changes in ranking over time.

26_22

The trick to add the numbers in the selected team’s line is to create a new expression with this configuration:

26_23

And voilà, our visualizations are now ready! I really hope you liked today’s tutorial. Slopegraphs are great visualizations; so why don’t you try them in your next app?

By the way, in order to celebrate our second Qlik Dev Group in Mexico (this time in Monterrey), our friends at Pack Publishing are offering an eBook discount (50% off) for these 5 QlikView titles. Just go to their website and type the code QLIKDEV50 (Valid until 31st July, 2016).

Keep Qliking. Until next time!

Advertisements

3 thoughts on “About Slopegraphs and Bumps Charts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s