Charting a query

Each bar, dot, line, or slice of a chart represents data from one row/column coordinate in your result set. A related group of data is called a chart series.

Because each bar, dot, line, or slice represents the intersection of two axes, you must craft the query result set such that the row and column values have meaning when displayed in a chart. This often requires that you aggregate data in the query. You typically aggregate data in a query using one of the following:

When you chart a query, you specify the query name using the query attribute of the cfchartseries tag. For example, the code for a simple bar chart might be as follows:

<cfchart
      xAxisTitle="Department"
      yAxisTitle="Salary Average"
   >
   <cfchartseries 
      type="bar" 
      query="DataTable" 
      valueColumn="AvgByDept" 
      itemColumn="Dept_Name"
      />
</cfchart>

This example displays the values in the AvgByDept column of the DataTable query. It displays the Dept_Name column value as the item label by each bar.

The following table lists the attributes of the cfchartseries tag that you use when working with queries:

Attribute Description

query

The query that contains the data. You must also specify the valueColumn and itemColumn.

valueColumn

The query column that contains the values to be charted.

itemColumn

The query column that contains the description for this data point. The item normally appears on the horizontal axis of bar and line charts, on the vertical axis of horizontalbar charts, and in the legend in pie charts.


View comments in LiveDocs