You want to display data as a vertical bar chart.
|
Table of Contents
|
The examples below will walk you through the steps to create Klips with vertical bar charts using example Klips. You can also download a finished sample Klip instead.
<setup>
<chart>
<type>verticalbar</type>
<categorylabels>my_category_column_name</categorylabels>
<series>my_number_column_name(s)</series>
</chart>
</setup>
The following examples use a static XML file located at http://static.klipfolio.com/static/klips/samples/verticalbar/data.xml as their content source.
1. Build a Klip with the data you will want to display as a full-frame vertical bar chart. For example, here is a Klip displaying data on 10 products that looks like this when it is loaded: verticalbar1.klip

2. Add the <chart> block in the Klip's <setup> block. In it, specify the <type> of the chart, the name of the column to use for the <categorylabels>, and the name of the column to display as bars (<series>).
For example, to turn verticalbar1.klip into a vertical bar chart using the values in the "Product" column as the category labels and values in the "Available" column as bars, add the following code in its <setup> block, then save and reload it:
<chart>
<type>verticalbar</type>
<categorylabels>name</categorylabels>
<series>units</series>
</chart>
Note that we use the names of the columns as specified in the <style> block, which are case-sensitive. The Klip should now look like this:

You will notice that the exact value for the bar is indicated as you hover over each product. In this example, you will also see a tooltip whenever you hover over a bar; the use of tooltips is especially useful for full-frame charts because additional information about each item can be displayed. (See the style definitions in the <style> block.)

<chart>
<type>verticalbar</type>
<categorylabels>name</categorylabels>
<series>units</series>
<legend>false</legend>
</chart>

<chart>
<type>verticalbar</type>
<categorylabels>name</categorylabels>
<series>units</series>
<scaletodata>true</scaletodata>
</chart>
This will result in the horizontalbar1.klip displayed like this:

Note how the range of the chart is now adjusted to 490 to 520. Though this example uses static data, the range would readjust itself if the incoming data values were to precede or exceed the smallest and largest values that are currently available.
<chart>
<type>verticalbar</type>
<categorylabels>name</categorylabels>
<series>units</series>
<seriestitle>Units</seriestitle>
</chart>

<chart>
<type>verticalbar</type>
<categorylabels>name</categorylabels>
<series>units,orders</series>
</chart>

<chart>
<type>verticalbar</type>
<categorylabels>name</categorylabels>
<series>units,orders</series>
<format>line(orders)</format>
</chart>
Note how both columns that are used in the chart, i.e. units for the bar chart and orders for the line chart, must be listed in the <series> block.

<chart>
<type>verticalbar</type>
<categorylabels>name</categorylabels>
<series>units,orders</series>
<format>line(orders),points</format>
</chart>
Here's how the verticalbar1.klip looks with the above settings:

<chart>
<type>verticalbar</type>
<categorylabels>name</categorylabels>
<series>units,orders,shipped</series>
<format>line(orders),line(shipped),points</format>
</chart>

1. First, start with a regular drilldown Klip that includes the data you will want to display as a chart. Be sure to specify the formula for each of the type: number columns as required for any drilldown Klip. For details, refer to the how-to article, Displaying values in a drilldown Klip.
For example, here is a drilldown Klip using the same content source as example 1 above: verticalbar2.klip. When loaded, it should look like this.

Try clicking on the Appliances item to drill down to see how this Klip works at this stage.
2. To turn it into a chart Klip, you will want to use the column that is type: enum; drilldown: 1 as the <categorylabels>, so that this is the level on which the chart is displayed when the Klip is loaded:
<chart>
<type>verticalbar</type>
<categorylabels>category</categorylabels>
<series>units</series>
</chart>
Now, the Klip should look like this when it is loaded, with 4 categories:

You can click on any bar to drill down into it.
You may also add the optional settings discussed above to the drill down chart Klip.