To chart data from both query and individual data values, you specify the query name and related attributes in the cfchartseries
tag, and provide additional data points using the cfchartdata
tag.
ColdFusion displays the chart data specified by a cfchartdata
tag before the data from a query; for example, to the left on a bar chart. You can use the sortXAxis
attribute of the cfchart
tag to sort data alphabetically along the x-axis.
One use of combining queries and data points is to provide data that is missing from the database; for example, to provide the data for one department if the data for that department is missing. The example in the following procedure adds data for the Facilities and Documentation departments to the salary data obtained from the query shown in the previous section:
cfchart
tag so that it appears as follows:
<cfchart chartwidth="600"> <cfchartseries type="bar" query="DeptSalaries" itemColumn ="Dept_Name" valueColumn="AvgByDept" > <cfchartdata item="Facilities" value="35000"> <cfchartdata item="Documentation" value="45000"> </cfchartseries> </cfchart>
http://localhost/myapps/chartqueryanddata.cfm