• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cfchart

Guest
Oct 14, 2007 Oct 14, 2007

Copy link to clipboard

Copied

Hi there

I have created two arrays which contain the data that I want to report on using cfchart.

Basically I have a person name array and a person sales array. I am trying to work out how I can use the data in the arrays to produce the cfchart.

Currently I have hard coded the information into the cfchart below, but this is limiting as this report will run for various retail stores and I dont know the sles people from each store.

<cfchart
chartwidth="950"
chartheight="500"
xaxistitle="Sales Staff"
yaxistitle="Revenue"
show3d="Yes">
<cfchartseries
type="pie"
serieslabel="Sales Staff"
seriescolor="##ffcc00">
<cfchartdata item="Alan Ash" value="2387 ">
<cfchartdata item="Brad Bloom" value="7795">
<cfchartdata item="Colin Craig" value="2487">
<cfchartdata item=" Doug Douglas" value="511">
<cfchartdata item="Ed Edwards" value="1565">
<cfchartdata item="Frank Farina" value="781">
</cfchartseries>
</cfchart>

Thanks in advance for feedback
TOPICS
Advanced techniques

Views

752

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 14, 2007 Oct 14, 2007

Copy link to clipboard

Copied

Hi there

I have tried the following:

<cfset myList = ArrayToList(servicelineNameArray, ",")>
<cfoutput>
<P>The contents of the Service Name Array are as follows:
<P>#myList#
<P>This array has #ArrayLen(servicelineNameArray)# elements.
</cfoutput>

<cfset myList1 = ArrayToList(servicelineTotalRevenueArray, ",")>
<cfoutput>
<P>The contents of the Service Line Total Revenue Array are as follows:
<P>#myList1#
<P>This array has #ArrayLen(servicelineTotalRevenueArray)# elements.
</cfoutput>

<cfchart
chartwidth="950"
chartheight="500"
xaxistitle="Service Lines"
yaxistitle="Revenue"
show3d="Yes">
<cfchartseries
type="pie"
serieslabel="Service Line Revenue"
seriescolor="##ffcc00">
<cfloop list="#mylist#" index="mylist">
<cfchartdata item="#mylist#" value="#mylist1#">
</cfloop>
</cfchartseries>
</cfchart>

But get the error

Attribute validation error for the CFCHARTDATA tag.
The value of the VALUE attribute is invalid. The value cannot be converted to a numeric because it is not a simple value.Simple values are booleans, numbers, strings, and date-time values.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 02, 2007 Nov 02, 2007

Copy link to clipboard

Copied

LATEST
Hi there -

I don't know if you ever figured out what to do, but I thought I would add my 2 cents so that it may help you or someone else.

The Short and sweet answer to using Arrays in CFCHART is to turn them into Queries.
I will provide my code and some comments to explain what I am doing and why. I won't explain the tags, that's up to you.

I hope this helps!


<!--- This will create a Query without a datasource and can be accessed normally in a CFOUTPUT tag if you wanted. --->
<cfset bp_query = QueryNew("bp, bp_cnt, total", "varchar, varchar, decimal")>


<!--- This next section creates a simple counter, and the loop goes through my array to exclude any array row that has a $0 total. I do this so that the CFCHART looks cleaner in the presentation. But that's only because I need to do that. You may not want to. --->
<cfset bp_row_cnt = 0>
<cfloop from="1" to="6" index="i">
<cfif bodyparts [2] GT 0>
<cfset bp_row_cnt = bp_row_cnt + 1>
</cfif>
</cfloop>


<!--- This next command adds the number of rows to the query. It adds the number of rows that it counted above --->
<cfset temp = QueryAddRow(bp_query, bp_row_cnt)>


<!--- This next section does the following: It sets a counter (zz). This will be used to assign my array row into the proper Query Row. Some may be saying, why not use the Index in the loop(below) to keep track. Simply put, you may have 9 rows in the array and your query will only need to display 7 of 9. If you try and put Array row 9 into the Query, it will blow up.
Anyway, the following code takes each part of the arrya and inserts it into the query into the proper row and column--->
<cfset zz=1>
<cfloop from="1" to="6" index="i">
<cfif bodyparts
[2] GT 0>
<cfset temp = QuerySetCell(bp_query,"bp",bodyparts [1],zz)>
<cfset temp = QuerySetCell(bp_query,"bp_cnt",bodyparts
[2],zz)>
<cfset temp = QuerySetCell(bp_query,"total",numberformat(bodyparts [3],"0.00"),zz)>
<cfset zz=zz+1>
</cfif>
</cfloop>

Any questions, please let me know.

Thanks,

Doug

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation