Brushing parallel coordinates
Parallel coordinates is a long established method of visualizing multivariate data. QlikView will display a parallel coordinate chart and a user can interact with the data, but sometimes it is useful to allow the user to "brush" the data, selecting different values and seeing those values versus the whole of the data.
We can do this by using two almost identical charts with one being transparent and sitting over the other.
Getting ready
We need to download some data for this from the United States Census QuickFacts website. Go to http://quickfacts.census.gov/qfd/download_data.html and download the first three files on offer:
Files |
Description |
---|---|
|
Raw data |
|
Information on the different metrics in the raw data |
|
List of the U.S. counties |
Load the following script:
// Cross table the raw data into a temp table Temp_Data: CrossTable(MetricCode, Value) LOAD * FROM DataSet.txt (txt, codepage is 1252, embedded labels, delimiter is ',', msq); // Load the temp table into our data table. // Only load county information. // Only load RHI data (Resident Population). Data: NoConcatenate Load fips, MetricCode, Value Resident Temp_Data Where Mod(fips, 1000) <> 0 // Only County And MetricCode Like 'RHI*'; // Only RHI // Drop the temporary table Drop Table Temp_Data; // Load the location information. // Use LEFT to only load locations that match Data. Location: Left Keep (Data) LOAD @1:5 as fips, @6:n as Location FROM FIPS_CountyName.txt (fix, codepage is 1252); // Load the Metric information // Use LEFT to only load metrics that match Data. Metrics: Left Keep (Data) LOAD @1:10 As MetricCode, Trim(SubField(SubField(@11:115, ':', 2), ',', 1)) as Metric, @116:119 as Unit, @120:128 as Decimal, @129:140 as US_Total, @141:152 as Minimum, @153:164 as Maximum, @165:n as Source FROM DataDict.txt (fix, codepage is 1252, embedded labels);
How to do it…
To create a parallel coordinates chart with brushing, perform the following steps:
Add a list box for Location onto the layout.
Create a new line chart. Add
Metric
andLocation
as dimensions.Add the following expression:
Avg({<Location={*}>} Value)
Label the expression as
%
.Click on the + sign beside the expression and enter the following expression for Background Color:
LightGray()
On the Sort tab, set the sort for the Metric dimension to Load Order and Original as shown in the following screenshot:
On the Presentation tab, turn off the Suppress Zero-Values and Suppress Missing options. Also, turn off the Show Legend option:
On the Axes tab, turn on the Static Max option and set it to
101
. Set the Primary Dimension Labels option to /. Turn on the Show Grid option under Dimension Axis:Click on Finish.
Right-click on the chart and select Clone from the menu. Position the new chart so it exactly overlaps the first. Edit the properties.
On the Expressions tab, modify the expression:
Avg(Value)
Click on the + sign beside the expression and change the Background Color property to:
Blue()
On the Colors tab, set the Transparency option to
100%
.On the Layout tab, set the Layer option to Top. Set the Show option to Conditional and enter the following expression:
GetSelectedCount(Location)>0
Click on OK.
Note
Note that when you make a selection on the chart or in the list box, the selection is highlighted or "brushed".
How it works…
The transparent chart with the slightly different color and expression is the trick here. When a selection is made, our chart overlays the first chart and displays the "brush". The underlying chart will remain the same as we have a set that excludes selections in the Location field.
As far as the user is concerned, there is only one chart being displayed.
There's more…
Using transparent charts to overlay another chart is a great technique to use when the particular visualization is just not available in QlikView.
See also
The Creating a "Stephen Few" bullet chart recipe