The example in the following procedure adds a title to the bar chart, specifies that the chart is three dimensional, adds grid lines, sets the minimum and maximum y-axis values, and uses a custom set of colors.
The following table describes the code in the preceding example.
Code |
Description |
---|---|
scaleFrom=40000 |
Set the minimum value of the vertical axis to 40000. |
scaleTo=100000 |
Set the maximum value of the vertical axis to 100000. The minimum value is the default, 0. |
font="arial" |
Displays text using the Arial font. |
fontSize=16 |
Makes the point size of the labels 16 points. |
gridLines = 4 |
Displays four grid lines between the top and bottom of the chart. |
show3D = "yes" |
Shows the chart in 3D. |
foregroundcolor="##000066" |
Sets the color of the text, gridlines, and labels. |
databackgroundcolor="##FFFFCC" |
Sets the color of the background behind the bars. |
seriescolor="##33CC99" |
Sets the color of the bars. |
paintstyle="shade" |
Sets the paint display style. |
The example in the following procedure adds a pie chart to the page.
The following table describes the 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]= Round(DeptSalaries.SumByDept[i]/ 1000)*1000> |
In the cfloop tag, round the salary sums to the nearest thousand. |
<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 three dimensions. |
<cfchartseries type="pie" query="DeptSalaries" valueColumn="SumByDept" itemColumn="Dept_Name" colorlist= "##6666FF,##66FF66,##FF6666,##66CCCC" /> |
Create a pie chart using the SumByDept salary sum values from the DeptSalaries 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 number signs prevent ColdFusion from trying to interpret the color data as variable names. |