User Guide

Table Of Contents
Writing a chart to a variable 757
To write a chart to a variable and a file:
1.
Create a new ColdFusion page with the following content:
<cfchart name="myChart" format="jpg">
<cfchartseries type="pie">
<cfchartdata item="New Vehicle Sales" value=500000>
<cfchartdata item="Used Vehicle Sales" value=250000>
<cfchartdata item="Leasing" value=300000>
<cfchartdata item="Service" value=400000>
</cfchartseries>
</cfchart>
<cffile
action="WRITE"
file="c:\inetpub\wwwroot\charts\vehicle.jpg"
output="#myChart#">
<img src="/charts/vehicle.jpg" height=240 width=320>
2.
Save the page as chartToFile.cfm in myapps under the web root directory.
3.
View the chartToFile.cfm page in your browser.
Reviewing the code
The following table describes the highlighted code and its function:
Code Description
<cfchart
name="myChart"
format="jpg">
Define a chart written to the myChart variable
using the JPEG format.
<cffile
action="WRITE"
file=
"c:\inetpub\wwwroot\charts\vehicle.jpg"
output="#myChart#">
Use the cffile tag to write the chart to a file.
<img
src="/chartsvehicle.jpg"
height=240
width=320>
Use the HTML img tag to display the chart.