| Contents > Developing ColdFusion MX Applications > Charting and Graphing Data > Controlling chart appearance > Setting pie chart characteristics |
|
|
|
|
||
You can specify the following additional characteristics for pie charts:
Chart characteristic |
Attributes used |
Description |
|---|---|---|
Slice style ( |
pieSliceStyle |
Display pie chart as solid or sliced. Default is sliced. |
Data point colors ( |
colorList |
A comma-separated list of colors to use for each pie slice. You can specify 16 color names or use any valid HTML color format. If you use the numeric format, you must use double pound signs, for example, blue or ##FF33CC. For the complete list of colors, see Configuring and Administering ColdFusion MX. If you specify fewer colors than data points, the colors repeat. If you specify more colors than data points, the extra colors are not used. |
The example in the following procedure adds a pie chart to the page.
cfloop code so that it appears as follows:
<!--- A query to get statistical data for each department. --->
<cfquery dbtype = "query" name = "DeptSalaries">
SELECT
Dept_Name,
SUM(Salary) AS SumByDept,
AVG(Salary) AS AvgByDept
FROM GetSalaries
GROUP BY Dept_Name
</cfquery>
<!--- Reformat the generated numbers to show only thousands --->
<cfloop index="i" from="1" to="#DeptSalaries.RecordCount#">
<cfset DeptSalaries.SumByDept[i]=Round(DeptSalaries.SumByDept[i]/
1000)*1000>
<cfset DeptSalaries.AvgByDept[i]=Round(DeptSalaries.AvgByDept[i]/
1000)*1000>
</cfloop>
cfchart tag:
<!--- Pie chart, from DeptSalaries Query of Queries --->
<cfchart
tipStyle="mousedown"
font="Times"
fontsize=14
fontBold="yes"
backgroundColor = "##CCFFFF"
show3D="yes"
>
<cfchartseries
type="pie"
query="DeptSalaries"
valueColumn="SumByDept"
itemColumn="Dept_Name"
colorlist="##6666FF,##66FF66,##FF6666,##66CCCC"
/>
</cfchart>
<br>
http://127.0.0.1/myapps/chartdata.cfm
The following figure appears:

The following table describes the highlighted code and its function:
Code |
Description |
|---|---|
SUM(Salary) AS SumByDept, |
In the DeptSalaries query, add a SUM aggregation function to get the sum of all salaries per department. |
<cfset DeptSalaries.SumByDept[i]= |
In the |
<cfchart tipStyle="mousedown" font="Times" fontBold="yes" backgroundColor = "##CCFFFF" show3D="yes" > |
Show a tip only when a user clicks on the chart, display text in Times Bold font, set the background color to light blue, and display the chart in 3-D. |
<cfchartseries type="pie" query="DeptSalaries" valueColumn="SumByDept" itemColumn="Dept_Name" colorlist= |
Create a pie chart using the SumByDept salary sum values from the DeptSalares query. Use the contents of the Dept_Name column for the item labels displayed in the chart legend. Get the pie slice colors from a custom list, which uses hexadecimal color numbers. The double pound signs prevent ColdFusion from trying to interpret the color data as variable names. |
|
|
||
| Contents > Developing ColdFusion MX Applications > Charting and Graphing Data > Controlling chart appearance > Setting pie chart characteristics |
|
|
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.