The Chart class is the proxy for the ColdFusion Chart service, which provides the functionality of the cfchart tag and its child chartdata and chartseries tags.

  • You specify the cfchart attributes as Chart object properties.
  • You represent chart series in the chartSeries element of the chart object. The chartSeries element is an arrays of objects, each of which represents a single chart (chartseries tag) document section. These objects include a type element for the chart type, a chartdata element for the chart data, and elements for any other series attributes.
  • You represent each chart's data as an array of objects, each of which contains an item element and a value element. You use these arrays as the chartdata elements of the chartSeries object.
  • You call the document object execute() function to run the service.
    The following example shows how you can use the chart service:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:cf="coldfusion.service.mxml.*" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

[Bindable]
public var chaSer:Array;
public var chaDat:Array;
function init():void
{
chaDat =
[{item:"Facilities",value:"35000"},
{item:"Facilities1",value:"32000"}];
chaSer = [{type:"bar",chartdata:chaDat},
{type:"line",chartdata:chaDat}];chartest.execute();
}
function handleResult(event:ResultEvent):void
{
Alert.show("success" + event.result.toString());
}
function handleFault(event:FaultEvent):void
{
Alert.show("failure" + event.toString());
}
]]>
</mx:Script>
<cf:Config id="configid" cfServer="localhost"
cfPort="80" servicePassword="service"
serviceUserName="service" >
</cf:Config>
<cf:Chart id="chartest"
action="generate"
format="jpg"
xAxisTitle="Department"
yAxisTitle="Salary Average"
chartSeries="{chaSer}"
result="handleResult(event)"
fault="handleFault(event)"
backgroundColor = "Black"
chartHeight = "500"
chartWidth = "600"
dataBackgroundColor = "yellow"
font = "ariel"
fontBold = "yes"
fontItalic = "yes"
fontSize = "12"
foregroundColor = "red"
gridLines = "2"
labelFormat = "number"
markerSize = "10"
showBorder = "yes"
showLegend = "yes"
showMarkers = "yes"
showxGridLines="yes"
showyGridLines="yes"
tipBgColor="blue"
tipStyle = "MouseOver"
title = "AIR Integration testing"/>
</mx:Application>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy