Creating a Simple Graph

Regardless of the type of chart or graph you want to create, you need to start with the cfchart tag. cfchart acts as a container tag for setting up the chart’s basic characteristics, such as height, width, and background color. The cfchart tag is a paired tag and must have both an opening and closing tag.

The cfchartseries tag determines what type of chart or graph to create for a particular series of static or dynamic data and allows you to specify attributes for the series, such as labels, color, etc. ColdFusion MX 6.1 can graph multiple data series in a single chart. The number of data series is limited only by the size of the chart.[1] The cfchartseries tag is also paired and requires an opening and closing tag. Additional static data points may be added to a chart series by nesting one or more cfchartdata tags inside a cfchartseries pair. Example 17-1 shows how to generate a bar chart from static data using all three tags just mentioned.

Example 17-1. Creating a simple graph from static data

<cfchart format="Flash" chartheight="400" chartwidth="400" foregroundcolor="##000000" backgroundcolor="##C0C0C0" databackgroundcolor="##0000FF" rotated="No" showborder="Yes" scalefrom="0" scaleto="100000" gridlines="11" showxgridlines="Yes" showygridlines="Yes" seriesplacement="Default" font="Arial" fontsize="12" fontbold="Yes" fontitalic="Yes" xaxistitle="Salary" yaxistitle="Employee" xaxistype="scale" yaxistype="scale" sortxaxis="No" labelformat="Currency" ...

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.