生成并且显示一个chart。
<!--- This syntax uses an XML file or string to specify the chart style. --->
<cfchart
style = "XML string|XML filename">
</cfchart>
或者
<!--- This syntax uses the attributes of the cfchart tag to specify the chart style. --->
<cfchart
backgroundColor = "hexadecimal value|web color"
chartHeight = "integer number of pixels"
chartWidth = "integer number of pixels"
dataBackgroundColor = "hexadecimal value|web color"
font = "font name"
fontBold = "yes|no"
fontItalic = "yes|no"
fontSize = "font size"
foregroundColor = "hexadecimal value|web color"
format = "flash|jpg|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|no"
showBorder = "yes|no"
showLegend = "yes|no"
showMarkers = "yes|no"
showXGridlines = "yes|no"
showYGridlines = "yes|no"
sortXAxis = "yes|no"
tipBGColor = "hexadecimal value|web color"
tipStyle = "MouseDown|MouseOver|none"
title = "title of chart"
url = "onClick destination page"
xAxisTitle = "title text"
xAxisType = "scale|category"
xOffset = "number between -1 and 1"
yAxisTitle = "title text"
yAxisType = "scale|category"
yOffset = "number between -1 and 1">
</cfchart>
ColdFusion 8:
ColdFusion MX 7.01: 把文件改成state,这样fontSize属性就可以接受一个非整数的数字。
ColdFusion MX 7:
ColdFusion MX 6.1:
ColdFusion MX: 添加了这个标签
|
属性 |
必选/可选 |
默认 |
描述 |
|---|---|---|---|
| BackgroundColor
|
可选 |
|
数据背景和chart边框之间区域的颜色,around labels and around the legend. Hexadecimal 值或者支持的命名颜色,请看使用方法里面的命名表对于一个 hexadecimal 值来说, 可以这样使用: "##xxxxxx" 或者 "##xxxxxxxx", 这里 x = 0-9 or A-F; 使用了两个颜色标志或者一个都不用。 |
|
chartHeight |
可选 |
240 |
Chart 的高度; 单位是整数的 pixels. |
|
chartWidth |
可选 |
320 |
Chart 的宽度; 单位是整数的 pixels. |
|
dataBackgroundColor |
可选 |
白色 |
chart 数据周围区域的颜色。 Hexadecimal 值或者支持的命名颜色r; 请看使用方法部分的命名清单。 对于一个hexadecimal 值, 使用"##xxxxxx" 或者 "##xxxxxxxx"的形式, 这里 x = 0-9 or A-F; 使用两个数字标志或者一个都不用. |
|
font |
可选 |
arial |
text font的名字:
|
|
fontBold |
可选 |
no |
文字是否使用粗体 :
|
|
fontItalic |
可选 |
no |
是否把文字设置为楷体:
|
|
fontSize |
可选 |
11 |
字体大小。如果数字不是一个整数,ColdFusion会把数字归整为下一个整数。 |
|
foregroundColor |
可选 |
black |
文本颜色, 网格线, 和标签. Hexadecima值或者支持的命名颜色;请看使用方法部分的命名清单. 对于一个 hexadecimal 值, 请使用 "##xxxxxx" 或者 "##xxxxxxxx"的形式, 这里 x = 0-9 or A-F; 使用两个数字标志或者一个都不用. |
|
format |
可选 |
flash |
保存图表的文件格式
|
|
gridlines |
可选 |
10, including top and bottom |
在x轴上显示的网格线的数量,整数。 |
|
labelFormat |
可选 |
number |
y轴的格式
|
|
markerSize |
可选 |
(Automatic) |
轴线上的点的大小,整数 |
|
name |
可选 |
|
页面变量名,字符串。产生二进制的图,并指定给指定的变量。压制chart显示。你可以使用cffile标签里的名字变量把chart写到文件里去。 |
|
pieSliceStyle |
可选 |
sliced |
使用于cfchartseries类型属性的值
|
|
scaleFrom |
可选 |
Determined by data |
y轴上最小的值;整数 |
|
scaleTo |
可选 |
Determined by data |
y轴上最大的值;整数 |
|
seriesPlacement |
可选 |
default |
chart里面series的相关位置,这些位置有不止一个的数据series
|
|
show3D |
可选 |
yes |
是否显示 3D外形的chart。
|
|
showBorder |
可选 |
no |
是否显示chart外部的边框
|
|
showLegend |
可选 |
yes |
如果chart包含不止一个的数据series,是否显示legend
|
|
showMarkers |
可选 |
yes |
是否在直线上,曲线上,散射图上的数据点显示标记,
|
|
showXGridlines |
可选 |
no |
是否显示x轴上的gridlines
|
|
showYGridlines |
可选 |
yes |
是否显示y轴上的gridlines
|
|
sortXAxis |
可选 |
no |
是否在显示x轴上字母命令的列标签
如果x轴的类型属性是scale的话,可以忽略。 |
|
style |
可选 |
|
XML文件或者字符串可以用来指定chart的类型。 |
|
title |
可选 |
|
标题 |
|
tipbgcolor |
可选 |
white |
tip的背景色. 只适用于 Flash格式的图文件。 Hexadecimal 值或支持的命名颜色,请看使用方法部分的命名清单。 对于一个 hexadecimal 值,请使用"##xxxxxx"的格式, where x = 0-9 or A-F; 使用两个数字标示或者一个也不用。 |
|
tipStyle |
可选 |
mouseOver |
定义了一个反应:一个跳出框提示当前chart元素的信息。
|
|
url |
可选 |
|
如果用户在一个数据series里点击了该项目,URL就会打开onClick的目标页面。 你可以在URL字符串里指定变量;ColdFusion可以通过变量的当前值。
|
|
xAxisTitle |
可选 |
|
显示在x轴上的标题,文本格式。 |
|
xAxisType |
可选 |
category |
x轴是显示数据还是数字
|
|
xOffset |
可选 |
0.1 |
一些units可以用来以角度和横向联合的不同方式显示chart。只适用于 show3D="yes"的情况。数字可以是-1到1,这里-1指的是左转90度 ,1指的是右转90。 |
|
yAxisTitle |
可选 |
|
y轴的标题,文本格式。 |
|
yAxisType |
可选 |
category |
目前还没有具体作用,因为y轴总是用来表示数据值。 |
|
yOffset |
可选 |
0.1 |
unit的值,用来以角度的方式显示chart。只适用于 show3D="yes"的情况。数字可以是-1到1,这里-1指的是左转90度 ,1指的是右转90。 |
cfchart标签定义了一个container ,在container里图会显示它的高度,宽度,背景色,标签(labels)等等。 cfchartseries标签定义了chart 的类型,包括: bar, line, pie, 等等。 cfchartdata 标签定义了一个 data point。
数据以以下方式传递给 cfchartseries 标签:
字体类型的值是 ArialUnicodeMS以下规则适用:
以下的表格列出了 W3C HTML 4 ,它可以被颜色属性接受,名字叫做 color value 或者 hexadecimal 值:
|
Color name |
RGB value |
|---|---|
|
Aqua |
##00FFFF |
|
Black |
#000000 |
|
Blue |
##0000FF |
|
Fuchsia |
##FF00FF |
|
Gray |
##808080 |
|
Green |
##008000 |
|
Lime |
##00FF00 |
|
Maroon |
##800000 |
|
Navy |
##000080 |
|
Olive |
##808000 |
|
Purple |
##800080 |
|
Red |
##FF0000 |
|
Silver |
##C0C0C0 |
|
Teal |
##008080 |
|
White |
##FFFFFF |
|
Yellow |
##FFFF00 |
对于所有其他的r color values, 你都必须输入 hexadecimal 值。你可以输入一个 six-digit 值,它指定了RGB 值,或是输入 一个eight-digit 值, 它指定了RGB 值和 and the 透明度。最先的hexadecimal 值的两个 digits指定了透明度的度数, 00 和 FF之间的值都是可用的。
更多流行浏览器支持的color names请看 www.w3.org/TR/css3-color
无论char是否缓存在内存里,无论多少chart被缓存,无论多少的chartColdFusion可以马上运行,你都可以进行具体的指定。要在 ColdFusion Administrator里进行这些设置,你可以选择Server Settings > Charting.
ColdFusion 8 让你可以在一个使用cfdocument标签的PDF 文件中嵌入Flash chart。例如:
<cfdocument format="pdf">
...
<!--- Flash chart embedded here. --->
<cfchart format="flash" xaxistitle="Department" yaxistitie="Salary Average">
<cfchartseries type="bar" query="DataTable" itemcolumn="Dept_Name"
valuecolumn="avgSal">
<cfchardata item="Facilities" value="35000">
</cfchartseries>
</cfchart>
</cfdocument>
<!---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>