Skip to main content
Inspiring
February 1, 2012
Answered

CFCHART and CFQUERY problem :(

  • February 1, 2012
  • 1 reply
  • 814 views

Hi,

I'm trying to use <cfchart> to create a pie chart from a query that shows 3 wedges with 3 different values.  I can't for the life of me figure out how to do this.  Here is my code:

<cfchart format="png"  chartheight="150"   chartwidth="200">

    <cfchartseries type="pie" query="qCompanyStatus">

</cfchart>

The query returns 1 row with 4 columns

CompanyName | NumberStarted | NumberInProgress | NumberComplete

ABC Company, 4, 5, 9

I'd like to display a pie chart with three wedges showing the values in each of these columns.

How can I do this?  It seems there is only an itemcolumn and valuecolumn, I need to display multiple values here and just not sure how to do it.  It must be something simple.


Any help highly appreciated...

Thanks

This topic has been closed for replies.
Correct answer -__cfSearching__-

1) Generate the cfchartdata elements yourself

<cfchartseries type="pie">

    <cfloop query="qCompanyStatus">

        <cfchartdata  item="#CompanyName#" value="#NumberStarted#">

        <cfchartdata  item="#CompanyName#" value="#NumberInProgress#">

         ....

    </cfloop>

</cfchartseries>

2) Reformat the query results to return a single value column.

ABC Company, 4

ABC Company, 5

ABC Company, 9

1 reply

-__cfSearching__-Correct answer
Inspiring
February 1, 2012

1) Generate the cfchartdata elements yourself

<cfchartseries type="pie">

    <cfloop query="qCompanyStatus">

        <cfchartdata  item="#CompanyName#" value="#NumberStarted#">

        <cfchartdata  item="#CompanyName#" value="#NumberInProgress#">

         ....

    </cfloop>

</cfchartseries>

2) Reformat the query results to return a single value column.

ABC Company, 4

ABC Company, 5

ABC Company, 9

WestSideAuthor
Inspiring
February 1, 2012

Thanks.. that worked.   Appreciated very much!