SAMPLE: Simple Pie Chart - ColdFusion
The information in this article applies to:
- Swiff Chart Generator 2
This example illustrates how to generate a simple pie chart in ColdFusion.
<CFSETTING ENABLECFOUTPUTONLY="Yes" SHOWDEBUGOUTPUT="No">
<CFHEADER NAME= "Expires" VALUE="#Now()#">
<CFOBJECT TYPE="COM"
NAME="chart"
CLASS="SwiffChartObject.ChartObj.1"
ACTION="CREATE">
<CFSCRIPT>
dirpath = GetDirectoryFromPath( GetBaseTemplatePath() );
sep= ";";
ignoremultseparators= true;
chart.SetSeparators(sep, ignoremultseparators);
// Fill the categories
categories= "USA" & sep & "Germany" & sep & "United Kingdom";
chart.SetCategoriesFromString(categories);
// Fill the first series named "Sales 2001"
series= "45" & sep & "28" & sep & "16";
chart.AddSeries();
chart.SetSeriesValuesFromString(0, series);
// Set the chart title
chart.SetTitle("Geographical Distribution");
// Apply a Pie style
// The chart type is stored in the style file (*.scs)
// Here the selected style is the predefined pie style "Honolulu"
style = "pie/Honolulu";
chart.LoadStyle( style );
chart.SetWidth( 400 );
chart.SetHeight( 200 );
chart.SetLooping( false );
chart_res= chart.GetHTMLTag();
</CFSCRIPT>
<CFOUTPUT>
<H2>The Pie Chart</H2>
<br>#chart_res#
</CFOUTPUT>
| Keywords: | ColdFusion CFML Pie |
