For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
Creating Charts and Graphs / 

Creating charts: examples

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 


Creating a bar chart

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.

  1. Open the chartdata.cfm file in your editor.
  2. Edit the cfcharttag so that it appears as follows:

    <!--- Bar chart, from Query of Queries --->
    <cfchart
    scaleFrom=40000
    scaleTo=100000
    font="arial"
    fontSize=16
    gridLines=4
    show3D="yes"
    foregroundcolor="##000066"
    databackgroundcolor="##FFFFCC"
    chartwidth="450"
    >

    <cfchartseries
    type="bar"
    query="DeptSalaries"
    valueColumn="AvgByDept"
    itemColumn="Dept_Name"
    seriescolor="##33CC99"
    paintstyle="shade"
    />

    </cfchart>

     

  3. Save the file as chartdatastyle1.cfm.
  4. View the chartdatastyle1.cfm page in your browser.
Reviewing the code

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.

Creating a pie chart

The example in the following procedure adds a pie chart to the page.

  1. Open the chartdata.cfm file in your editor.
  2. Edit the DeptSalaries query and the cfloopcode 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>

     

  3. Add the following cfcharttag:

    <!--- 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>

     

  4. Save the file as chartdatapie1.cfm.
  5. View the chartdatapie1.cfm page in your browser:
Reviewing the code

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"
fontsize=14
fontBold="yes"
backgroundColor = "##CCFFFF"
show3D="yes"
>

 

Show a tip only when a user clicks 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.

Creating an area chart

The example in the following procedure adds an area chart to the salaries analysis page. The chart shows the average salary by start date to the salaries analysis page. It shows the use of a second query of queries to generate a new analysis of the raw data from the GetSalaries query. It also shows the use of additional cfchart attributes.

  1. Open the chartdata.cfm file in your editor.
  2. Edit the GetSalaries query so that it appears as follows:

    <!-- Get the raw data from the database. -->
    <cfquery name="GetSalaries" datasource="cfdocexamples">
    SELECT Departmt.Dept_Name,
    Employee.StartDate,
    Employee.Salary
    FROM Departmt, Employee
    WHERE Departmt.Dept_ID = Employee.Dept_ID
    </cfquery>

     

  3. Add the following code before the htmltag:

    <!--- Convert start date to start year. --->
    <!--- Convert the date to a number for the query to work --->
    <cfloop index="i" from="1" to="#GetSalaries.RecordCount#">
    <cfset GetSalaries.StartDate[i]=
    NumberFormat(DatePart("yyyy", GetSalaries.StartDate[i]) ,9999)>
    </cfloop>

    <!--- Query of Queries for average salary by start year. --->
    <cfquery dbtype = "query" name = "HireSalaries">
    SELECT
    StartDate,
    AVG(Salary) AS AvgByStart
    FROM GetSalaries
    GROUP BY StartDate
    </cfquery>

    <!--- Round average salaries to thousands. --->
    <cfloop index="i" from="1" to="#HireSalaries.RecordCount#">
    <cfset HireSalaries.AvgByStart[i]=
    Round(HireSalaries.AvgByStart[i]/1000)*1000>
    </cfloop>

     

  4. Add the following cfchart tag before the end of the bodytag block:

    <!--- Area-style Line chart, from HireSalaries Query of Queries. --->
    <cfchart
    chartWidth=400
    BackgroundColor="##FFFF00"
    show3D="yes"
    >
    <cfchartseries
    type="area"
    query="HireSalaries"
    valueColumn="AvgByStart"
    itemColumn="StartDate"
    />
    </cfchart>
    <br>

     

  5. Save the page.
  6. View the chartdata.cfm page in your browser.
Reviewing the code

The following table describes the code and its function:

Code

Description

 

Employee.StartDate,

 

Add the employee start date to the data in the GetSalaries query.

 

<cfloop index="i" from="1" to="#GetSalaries.RecordCount#">
<cfset GetSalaries.StartDate[i]=NumberFormat(DatePart("yyyy", GetSalaries.StartDate[i]) ,9999)>
</cfloop>

 

Use a cfloop tag to extract the year of hire from the hire data, and convert the result to a four-digit number.

 

<cfquery dbtype = "query" name = "HireSalaries">
SELECT
StartDate,
AVG(Salary) AS AvgByStart
FROM GetSalaries
GROUP BY StartDate
</cfquery>

 

Create a second query from the GetSalaries query. This query contains the average salary for each start year.

 

<cfloop index="i" from="1" to="#HireSalaries.RecordCount#">
<cfset HireSalaries.AvgByStart[i]=Round(HireSalaries.AvgByStart[i]/1000)*1000>
</cfloop>

 

Round the salaries to the nearest thousand.

 

<cfchart
chartWidth=400
BackgroundColor="##FFFF00"
show3D="yes"
>
<cfchartseries
type="area"
query="HireSalaries"
valueColumn="AvgByStart"
itemColumn="StartDate"
/>
</cfchart>

 

Create an area chart using the HireSalaries query. Chart the average salaries against the start date.Limit the chart width to 400 pixels, show the chart in three dimensions, and set the background color to white.

Setting curve chart characteristics


Curves charts use the attributes already discussed. However, curve charts require a large amount of processing to render. For fastest performance, create them offline, write them to a file or variable, and then reference them in your application pages. For information on creating offline charts, see Writing a chart to a variable.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices