(O) Criando um gráfico tipo "Stephen Few" no QlikView
Autor: Laércio Serra | Publicado: 2014-08-11T16:01:00-07:00


This chart as a replacement for a traditional gauge.



A traditional gauge takes up a large amount of space to encode, usually, only one value. A bullet chart is linear and can encode more than one value.



The main components of a bullet chart (from Stephen Few's perceptualedge.com)
are as follows:





A text label
A quantitative scale along a single linear axis
The featured measure
One or two comparative measures (optional)
From two to five ranges along the quantitative scale to declare the featured measure's qualitative state (optional)

There is no native bullet chart in QlikView. However, we can create one by combining a couple of objects. Items 1, 2, 4, and 5 can be achieved with a linear gauge chart. The bar, item 3, can then be overlaid using a separate and transparent bar chart. 

Hands-On


&nbsp;Load the following script:


LOAD * INLINE [
&nbsp;&nbsp;&nbsp; Country, Sales, Target
&nbsp;&nbsp;&nbsp; USA, 1000, 1100
&nbsp;&nbsp;&nbsp; UK, 800, 1000
&nbsp;&nbsp;&nbsp; Germany, 800, 700
&nbsp;&nbsp;&nbsp; Japan, 1000, 1000
];

&nbsp;Add a new gauge chart. You should add a title and enter text for Title in chart. Click on Next.


There is no dimension in this chart. Click on Next.
Enter the following expression: Sum(Target)
Click on Next.
There is no sorting (because there is no dimension), so click on Next.
On the Style tab, select a linear gauge and set the orientation to horizontal.Click on Next.


&nbsp;

There are a few changes needed in the Presentation tab:&nbsp;




There should be two segments by default, add a third segment by clicking onthe Add button. The settings for each segment are as follows:


&nbsp;

Apply appropriate colors for each segment (for example, RAG or Dark/Medium/Light gray). 
Click on Finish.




&nbsp;Most of the bullet chart elements are now in place. In fact, this type of linear chart may be enough for some uses. Now we need to add the bar chart. 


Add a new bar chart. Don't worry about the title (it will be hidden). Turn off Show Title in Chart. Click on Next.
There is no dimension in this chart either. Click on Next.
Add the following expression: Sum(Sales)
Click on Next.
There is no sort (as there is no dimension). Click on Next.




&nbsp;Select a plain bar type. The orientation should be horizontal. Leave the style at the default of Minimal. Click on Next.




&nbsp;Set the following axis settings:




&nbsp;Click on Next.
&nbsp;On the Color tab, set Transparency to 100%. Set the first color to a dark color.Click on Next.
Continue to click on Next until you get to the Layout tab. Set the shadow to NoShadow and the border width to 0. Set the Layer to Top. Click on Next. 
Turn off the Show Caption option. Click on Finish.




&nbsp;Position the bar chart over the gauge so that the scales match (Ctrl + arrow keys are useful here). The bullet chart is created.

&nbsp;Conclusion


By matching the Static Max setting of the bar and the gauge (to the sum of target * 1.2), we ensure that the two charts will always size the same. The 1.2 factor makes the area beyond the target point of 20 percent of the length of the area before it. This might need to be adjusted for different implementations.


It is also crucial to ensure that the layer setting of the bar chart is at least one above the layer of the gauge chart. The default layer (on the Layout tab) for charts is Normal so, in that situation, you should change the bar chart's layer to Top. Otherwise, use the Custom option to set the layers. 



Using techniques such as this to combine multiple QlikView objects can help us create many other visualizations.



Thanks and see you on the next post!



PS: This article has adapted from the original: "Discover the strategies needed to tackle the most challenging tasks facing the QlikView developer (Stephen Redmond)"