Positioning Labels on Pizza's Chart
Labels are used on pizza's chart to show information about values by dimensions. To enable values around pizza's chart is necessary enable
Values on Data Points from Expressions tab. In some cases, small values for each dimension can be showed over each other as you can see at picture at side. This document teaches you how to split each value with more space to avoid a value overwritten.
In this document you will be able to go ahead putting more information on each data point. Using this technique legends aren't necessary because all you need show to user are shown with a value around pizza's chart, with each data point, allowing you use all available space for more informations with other objects.
On other hand, it's possible to show pizza's chart legends with different values from that is showed on data points. This means you'll able show more information than a default legends are able to do. For example, for each data point is possible to show relative values in percentage, while absolute values are shown on pizza's chart legends.
In next sections you can load some data sample to test these techniques. A
QVW file is also available to download. Furthermore, it's possible merge these tricks with others like customized tooltips, what allow you to show rich information for users. For more information about tooltips, see this document, only in portuguese.
By default, when you select
Values on Data Points option from Expression tab, all dimensions will show their values around Pizza's chart. In some cases, as shown at the picture above, labels with values are placed over others. But, is possible to change expression definition to handle this behavior. To reproduce this technique use the following sample from a new QlikView document.
- Execute QlikView 11 from Windows.
- Cancel the data load wizard.
- Create a new project clicking
- Open the script editor pressing
CTRL + E.
- Copy from this document the following data sample.
LOAD * INLINE [ Country, Sales USA, 100000 Canada, 50000 Mexico, 25000 UK, 70000 Germany, 20000 Brazil, 15000 France, 10000 Japan, 9000 China, 8000 Australia, 7000 ];
After paste previous load statement in your new script, save the document as a new QVW file. Execute the script pressing
CTRL + R or clicking
Reload button from toolbar. Returning to QlikView Desktop main interface, create a new Pizza's chart as usual. From Dimension tab, select
Country. After that, go to Expression tab and use the following formula:
=Dual(Sum(Sales) & Repeat(chr(13)&chr(10), rank(Sum(Sales))-6), Sum(Sales))
Dual is responsible to show a text instead a formula, it's possible instruct QlikView to break rows when small values are together. That is done using
Sum(Sales) & Repeat(chr(13)&chr(10), rank(Sum(Sales))-6) because
Chr(10) has the same effect of Enter key. But, idea isn't press Enter key from first value. Otherwise, last values will be far from their pieces. That's why
repeat function is used. This will force Qlikview to press Enter only from a specific number of values. Using the
Chr will be in place only after 6 values around the chart. Of course, to work fine it's necessary to group small values at the end. For that, from Sort tab,
Y-value needs to be selected with
From now, problem with values over others are solved. But, using this solution, legends are necessary to indicate what means each piece (slice). If you wanna hide legends but at the same time show information about each slice, you will like to see next section.
Adding Text to Label
Using the previous technique is possible add dimension values for each slice around Pizzas chart. I mean you can disable the legend transferring its content to data points. It's usefull when the dashboard has no space for more objects. Using the same formula that was presented before, fill in
Dual function the
Country field as the following code:
=Dual(Country & ' - ' & Sum(Sales) & Repeat(chr(13)&chr(10), rank(Sum(Sales))-6), Sum(Sales))
From now, contents from Country field will be filled in for each dimension at side each slice. Chart at side shows how labels will be showed. Using this method legend is not necessary. All information that a user need to understand the data are present on chart.
Remember that dual function has two parameters. First one is filled with what you wanna show to user, while second one is a formula to be calculated. When Country field is used in first parameter, its content will be used to show information about each dimension value to user. Up to this section you have learned the following functions:
- DUAL, used to show a string instead of a value.
- REPEAT, used to replicate a value a number of times.
- CHR, used to used to map keys from keyboard.
- RANK, used to "count" how many values (slices) are present.
- SUM, used to sum.
Legend With Complementary Data
One of main targets when creating a dashboard is show all informations using a restricted area. By default, the legend on Pizza's chart will show the same value that is used on data points. But, it's possible show a different information between data points and the Pizza's chart legends. To do that is necessary to use two expressions. First one is a simple formula using sum function. This formula will be used to show values for each dimension (Country) at the legend. The best way to test this feature is create a new chart. So, create a new formula using the following instruction:
The previous expression is a default behavior for a Pizza's chart. For this FIRST expression don't select
Values on Data Points. Instead of this, go to Presentation tab and enable
Show Legend option. Also, select
Show Number in Legend. Back to Expresion tab and create a new expression using the following formula:
=Dual(num(Sum(Sales) / Sum(TOTAL Sales), '0,00' & '%') & Repeat(chr(13)&chr(10), rank(Sum(Sales))-6), Sum(Sales))
This formula will calculate the percentage for each country while the first expression will show absolute value on the legend. For this second expression select
Values on Data Points. Done! Now the Pizza's chart is showing a relative value around the chart while it's showing absolute value on the legend. For this we have used the same functions from previous section with NUM to format output for second expression. Use of NUM is essential to work as expected. Don't format this expression from Number tab.
When a same expression is used in different objects you can create a variable to store its formula.
Variables can be defined with parameters and act as a typical function.. Learn here!
|Need more? Mail Us!|