Previous Topic: Report Sections

Next Topic: Queries


Charts

Basic types are pie, bar, and line charts. Bar charts and line charts can show multiple sets of data. Bars and lines can be combined on one chart.

The data for a pie chart is provided by embedding a <query> or <reference> tag inside the <chart> tag. The result of the query for a pie chart must have at least two columns. The first should be character data and is used to label the pie slices; the second should be numeric and is used to provide the values to be plotted. Any subsequent columns are ignored.

As for tables, you can use a datalimit="n" attribute in a <chart> tag to limit the number of rows used. If the query returns more than n rows, the excess rows are discarded.

Example: Pie Chart

<chart style="pie">
   <query>
      select aName, nfValue 
      from <databasename/>.attribute, <databasename/>.numericfact
      where <databasename>.attribute.aName = <databasename/>.numericfact.aName
   </query>
</chart>

The data for a bar or line chart is provided by one or possibly two <query> tags. In the result from a query, the first column is always used as X-axis values and the second and subsequent columns are each treated as a set of data to be plotted. For most charts, it is expected that one query is enough. The left-hand Y-axis is always labeled with values that describe the data in the first (or only) <query> tag. If there is a second <query> tag, the right-hand Y-axis will be labeled to describe it.

Pie Charts

The <chart> tag for a pie chart is as follows:

<chart style="pie">

The result used to build the chart must have at least two columns. The first column is used for labels and the second column is used for the numerical data that is plotted. Third and subsequent columns are ignored. There is no way to plot more than one set of data on a pie chart.

It is usually a good idea to specify in the query that the set of results be sorted in descending order on the numerical data. The reason is that the chart generator will plot some reasonable number of slices and group any remaining results into one slice, which can hide important information if that slice contains big lumps of data.

Bar Charts

The <chart> tag for a bar chart has two variations as follows:

<chart style="bar">
<chart style="stackedbar">

Bar charts can plot one or more sets of data against a set of X-axis values. The first column of the result forms the X-axis values. The second and subsequent columns are the sets of data to be plotted. If there is more than one set of data, a legend is included to identify them.

If a <chart style="bar"> tag contains multiple sets of data, they are plotted side by side with the first set of data on the left.

If a <chart style="stackedbar"> tag contains multiple sets of data, they are stacked vertically with the first set of data at the bottom. A stacked bar chart with only one set of data does not really make a lot of sense, but it does no harm.

Line Charts

The <chart> tag for a line chart is as follows:

<chart style="line">

Line charts can plot one or more sets of data against a set of X-axis values. The first column of the result forms the X-axis values. The second and subsequent columns are the sets of data to be plotted. If there is more than one set of data, a legend is included to identify them.

Combined Bar and Line Chart

The <chart> tag for a combined bar and line chart is as follows:

<chart style="linebar">

A combined bar and line chart combines a line and a set of bars on one chart. For 3-D charts, the line is plotted in front of the bar. This type of chart can only show two sets of data-you cannot have multiple lines or multiple sets of bars.

X-axis Labels

By default, only the first and last points on the X-axis are labeled. This can be overridden by specifying an “xlabels” attribute in the chart tag as follows:

<chart style="anything-other-than-pie" xlabels="all">

Valid values are all, none, and ends.