CFCHART | |||||||||||||||||||||||||||||||||||
Description
Generates and displays a chart. |
|||||||||||||||||||||||||||||||||||
Category
Data output tags, Extensibility tags; "Controlling chart appearance" in Chapter 31, "Creating Charts and Graphs," in ColdFusion MX Developer's Guide | |||||||||||||||||||||||||||||||||||
SyntaxSyntax 1 <!--- This syntax uses an XML file or string to specify the chart style. ---> <cfchart style = "XML string or filename"> </cfchart> Syntax 2 <!--- This syntax uses the attributes of the cfchart tag to specify the chart style. ---> <cfchart backgroundColor = "Hex value or Web color" chartHeight = "integer number of pixels" chartWidth = "integer number of pixels" dataBackgroundColor = "Hex value or Web color" font = "font name" fontBold = "yes" or "no" fontItalic = "yes" or "no" fontSize = "integer font size" foregroundColor = "Hex value or Web color" format = "flash" or "jpg" or "png" gridlines = "integer number of lines" labelFormat = "number, currency, percent, date" markerSize = "integer number of pixels" name = "String"> pieSliceStyle = "solid, sliced" scaleFrom = "integer minimum value" scaleTo = "integer maximum value" seriesPlacement = "default, cluster, stacked, percent" show3D = "yes" or "no" showBorder = "yes" or "no" showLegend = "yes" or "no" showMarkers = "yes" or "no" showXGridlines = "yes" or "no" showYGridlines = "yes" or "no" sortXAxis = "yes" or "no" tipBGColor = "hex value or web color" tipStyle = "MouseDown, MouseOver, none" title = "title of chart" url = "onClick destination page" xAxisTitle = "title text" xAxisType = "scale or category" xOffset = "number between -1 and 1" yAxisTitle = "title text" yAxisType = "scale or category" yOffset = "number between -1 and 1" </cfchart> |
|||||||||||||||||||||||||||||||||||
See also
cfchartdata, cfchartseries |
|||||||||||||||||||||||||||||||||||
History
ColdFusion MX 7:
ColdFusion MX 6.1:
ColdFusion MX: Added this tag.
|
|||||||||||||||||||||||||||||||||||
Usage
The cfchart tag defines a container in which a graph displays: its height, width, background color, labels, and so on. The cfchartseries tag defines the chart style in which data displays: bar, line, pie, and so on. The cfchartdata tag defines a data point. Data is passed to the cfchartseries tag in the following ways:
For the font attribute value ArialUnicodeMS, the following rules apply:
The following table lists W3C HTML 4 named color value or hexadecimal values that the color attribute accepts:
For all other color values, you must enter the hexadecimal value. You can enter a six-digit value, which specifies the RGB value, or an eight-digit value, which specifies the RGB value and the transparency. The first two digits of an eight-digit hexadecimal value specify the degree of transparency, with FF indicating opaque and 00 indicating transparent. Values between 00 and FF are allowed. For more color names that are supported by popular browsers, go to www.w3.org/TR/css3-color You can specify whether charts are cached in memory, the number of charts to cache, and the number of chart requests that ColdFusion can process concurrently. To set these options in the ColdFusion Administrator, select Server Settings > Charting. |
|||||||||||||||||||||||||||||||||||
Example<!---The following example analyzes the salary data in the cfdocexamples database and generates a bar chart showing average salary by department. The body of the cfchartseries tag includes one cfchartdata tag to include data that is not available from the query. ---> <!--- Get the raw data from the database. ---> <cfquery name="GetSalaries" datasource="cfdocexamples"> 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" query="DataTable" itemcolumn="Dept_Name" valuecolumn="avgSal"> <cfchartdata item="Facilities" value="35000"> </cfchartseries> </cfchart> |
BACKGROUNDCOLOR | |
Optional | |
Color of the area between the data background and the chart border, around labels and around the legend. Hexadecimal value or supported named color; see the name list in Usage. For a hexadecimal value, use the form "##xxxxxx" or "##xxxxxxxx", where x = 0-9 or A-F; use two number signs or none. |
CHARTHEIGHT | |
Optional | |
Default value: "240"
Chart height; integer number of pixels. |
CHARTWIDTH | |
Optional | |
Default value: "320"
Chart width; integer number of pixels. |
DATABACKGROUNDCOLOR | |
Optional | |
Default value: "white"
Color of area around chart data. Hexadecimal value or supported named color; see the name list in Usage. For a hexadecimal value, use the form "##xxxxxx" or "##xxxxxxxx", where x = 0-9 or A-F; use two number signs or none. |
FONT | |
Optional | |
Default value: "arial "
Name of text font:
|
FONTBOLD | |
Optional | |
Default value: "no"
Whether to make the text bold:
|
FONTITALIC | |
Optional | |
Default value: "no"
Whether to make the text italicized:
|
FONTSIZE | |
Optional | |
Default value: "11"
Font size; integer. |
FOREGROUNDCOLOR | |
Optional | |
Default value: "black"
Color of text, grid lines, and labels. Hexadecimal value or supported named color; see name list in Usage. For a hexadecimal value, use the form "##xxxxxx" or "##xxxxxxxx", where x = 0-9 or A-F; use two number signs or none. |
FORMAT | |
Optional | |
Default value: "flash"
File format in which to save the graph:
|
GRIDLINES | |
Optional | |
Default value: "10, including top and bottom"
Number of grid lines to display on the value axis, including axis; positive integer. |
LABELFORMAT | |
Optional | |
Default value: "number"
Format for y-axis labels:
|
MARKERSIZE | |
Optional | |
Default value: "(Automatic)"
Size of data point marker in pixels; integer. |
NAME | |
Optional | |
Page variable name; string. Generates the the graph as binary data and assigns it to the specified variable. Suppresses chart display. You can use the name value in the cffile tag to write the chart to a file. |
PIESLICESTYLE | |
Optional | |
Default value: "sliced"
Applies to the cfchartseries type attribute value pie.
|
ROTATED | |
Optional | |
Default value: "no"
Whether to rotate the chart 90 degrees:
|
SCALEFROM | |
Optional | |
Default value: "Determined by data"
Y-axis minimum value; integer. |
SCALETO | |
Optional | |
Default value: "Determined by data"
Y-axis maximum value; integer. |
SERIESPLACEMENT | |
Optional | |
Default value: "default "
Relative positions of series in charts that have more than one data series.
|
SHOW3D | |
Optional | |
Default value: "yes"
Whether to display the chart with three-dimensional appearance:
|
SHOWBORDER | |
Optional | |
Default value: "no"
Whether to display a border around the chart:
|
SHOWLEGEND | |
Optional | |
Default value: "yes"
Whether to display the legend if the chart contains more than one data series:
|
SHOWMARKERS | |
Optional | |
Default value: "yes "
Whether to display markers at data points in line, curve, and scatter graphs:
|
SHOWXGRIDLINES | |
Optional | |
Default value: "no"
Whether to display x-axis gridlines:
|
SHOWYGRIDLINES | |
Optional | |
Default value: "yes"
Whether to display y-axis gridlines:
|
SORTXAXIS | |
Optional | |
Default value: "no"
Whether to display column labels in alphabetic order along the x-axis:
Ignored if the xAxisType attribute is scale. |
STYLE | |
Optional | |
XML file or string to use to specify the style of the chart. |
TITLE | |
Optional | |
Title of the chart. |
TIPBGCOLOR | |
Optional | |
Default value: "white"
Background color of tips. Applies only to Flash format graph files. Hexadecimal value or supported named color; see the name list in the Usage section. For a hexadecimal value, use the form "##xxxxxx", where x = 0-9 or A-F; use two number signs or none. |
TIPSTYLE | |
Optional | |
Default value: "mouseOver"
Determines the action that opens a pop-up window to display information about the current chart element.
|
URL | |
Optional | |
URL to open if the user clicks item in a data series; the onClick destination page. You can specify variables within the URL string; ColdFusion passes current values of the variables.
For example: "somepage.cfm?item=$ITEMLABEL$&series=$ SERIESLABEL$&value=$VALUE$
|
XAXISTITLE | |
Optional | |
Title that appears on the x-axis; text. |
XAXISTYPE | |
Optional | |
Default value: "category"
Whether the x-axis indicates data or is numeric:
|
XOFFSET | |
Optional | |
Default value: "0.1"
Number of units by which to display the chart as angled, horizontally. Applies if show3D="yes". The number can be between -1 and 1, where "-1" specifies 90 degrees left and "1" specifies 90 degrees right. |
YAXISTITLE | |
Optional | |
Title of the y-axis; text. |
YAXISTYPE | |
Optional | |
Default value: "category"
Currently has no effect, as the y-axis is always used for data values. |
YOFFSET | |
Optional | |
Default value: "0.1 "
Number of units by which to display the chart as angled, vertically. Applies if show3D="yes". The number can be between -1 and 1, where "-1" specifies 90 degrees left and "1" specifies 90 degrees right. |