View comments | RSS feed
Contents > CFML Reference > ColdFusion Tags > cfchartdata PreviousNext

cfchartdata

Used with the cfchart and cfchartseries tags. This tag defines chart data points. Its data is submitted to the cfchartseries tag.

Data output tags, Extensibility tags

<cfchartdata 
item = "text"
value = "number">

cfchart, cfchartseries

ColdFusion MX: Added this tag.

Attribute

Req/Opt

Default

Description

item

 

 

string; data point name

value

 

 

number or expression; data point value


Contents > CFML Reference > ColdFusion Tags > cfchartdata PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


Sarge said on Mar 19, 2004 at 1:53 PM :
We are working to improve the examples in the ColdFusion reference pages. We propose to replace the current example on this page with the the following example. If you have any comments on this example, add them to this page.

The following example analyzes the salary data in the CompanyInfo database and generates a bar chart showing average salary by department. The body of the cfchartseries tag loops over a cfchartdata tag to include data available from the query.
<!--- Get the raw data from the database. --->
<cfquery name="GetSalaries" datasource="CompanyInfo">
SELECT Departmt.Dept_Name,
Employee.Dept_ID,
Employee.Salary
FROM Departmt, Employee
WHERE Departmt.Dept_ID = Employee.Dept_ID
</cfquery>

<!--- Use a query of queries to generate a new query with --->
<!--- statistical data for each department. --->
<!--- AVG and SUM calculate statistics. --->
<!--- GROUP BY generates results for each department. --->
<cfquery dbtype = "query" name = "DataTable">
SELECT
Dept_Name,
AVG(Salary) AS avgSal,
SUM(Salary) AS sumSal
FROM GetSalaries
GROUP BY Dept_Name
</cfquery>

<!--- Reformat the generated numbers to show only thousands --->
<cfloop index = "i" from = "1" to = "#DataTable.RecordCount#">
<cfset DataTable.sumSal[i] = Round(DataTable.sumSal[i]/1000)*1000>
<cfset DataTable.avgSal[i] = Round(DataTable.avgSal[i]/1000)*1000>
</cfloop>

<h1>Employee Salary Analysis</h1>
<!--- Bar graph, from Query of Queries --->
<cfchart format="flash"
xaxistitle="Department"
yaxistitle="Salary Average">

<cfchartseries type="bar"
itemcolumn="Dept_Name"
valuecolumn="avgSal">

<cfloop query="DataTable">
<cfchartdata item="#DataTable.Dept_Name#" value="#DataTable.avgSal#">
</cfloop>

</cfchartseries>
</cfchart>
zedfox said on Aug 6, 2004 at 9:02 PM :
Here is an example of using a combination of <cfchartdata> and <cfchartseries> tags. I didn't think of this and now that I have got a nice graph working, let me share with you how things worked for me. Hopefully someone will be benefited. I have also used pre-set (cfset) variables in the following code:

My intention: Two lines use cfchartdata looping through a query. One line uses the query directly using cfchartseries. This code has been picked up from a trial script. I am not able to get to the original script right now but this is where I got things started to work. Hope it helps.


<cfoutput><div align="center">#title#</div></cfoutput>
<cfchart format="png"
chartheight="300"
chartwidth="450"
showxgridlines="no"
showygridlines="yes"
gridlines="10"
xaxistitle="Date"
yaxistitle="#yaxistitle#"
markersize="1"
>

<cfchartseries
type="line"
seriesColor="green"
paintStyle="shade"
markerStyle="circle"
serieslabel="#serieslabel1#"
>

<cfset acc_gdd=0>
<cfloop query="airportcharts">
<cfset acc_gdd = #acc_gdd# + #rain#>
<cfchartdata item="#mydate#" value="#acc_gdd#">
</cfloop>

</cfchartseries>

<cfchartseries
type="line"
seriesColor="blue"
paintStyle="shade"
markerStyle="circle"
serieslabel="#serieslabel2#"
>

<cfset acc_gdd=0>
<cfloop query="normals">
<cfset acc_gdd = #acc_gdd# + #rain#>
<cfchartdata item="#mydate#" value="#acc_gdd#">
</cfloop>

</cfchartseries>

<cfchartseries
type="line"
seriesColor="blue"
paintStyle="shade"
markerStyle="circle"
query="normals"
itemcolumn="mydate"
serieslabel="#serieslabel2#"
valuecolumn="#valuecolumn#"
>
</cfchartseries>

</cfchart>
No screen name said on Oct 29, 2004 at 4:24 AM :
What happens with some values?
<cfchart format="jpg">
<cfchartseries type="line" >
<cfchartData item="1" value="14,14">
</cfchartseries>
</cfchart>
renerates an error "The value of the attribute VALUE is invalid". If the value is "14,11" - then it works!
CF MX 6.1

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-a12.htm