Skip to main content
Inspiring
January 21, 2012
Question

CFCHART - Percentages not right

  • January 21, 2012
  • 2 replies
  • 3224 views

I tried to set up a simple chart to display the results of a query, it works fine with labelformat="numbers", but if I change it to percent the results are odd, I get values above 100% on many of the pie slices. Anybody any idea?

Here's the code

<CFCHART

format="flash"

show3d="yes"

showlegend="yes"

chartheight="800"

chartwidth="900"

labelformat="percent"

showborder="true"

pieSliceStyle="sliced"

sortXAxis = "yes"

>

<cfchartseries

type="pie"

query="GetCountry"

valuecolumn="countrycounter"  itemcolumn="countrylong" />

Thanks

Mark

This topic has been closed for replies.

2 replies

BKBK
Adobe Expert
January 23, 2012

ACS LLC wrote:

I tried to set up a simple chart to display the results of a query, it works fine with labelformat="numbers", but if I change it to percent the results are odd, I get values above 100% on many of the pie slices. Anybody any idea?

Here's the code

<CFCHART

format="flash"

show3d="yes"

showlegend="yes"

chartheight="800"

chartwidth="900"

labelformat="percent"

showborder="true"

pieSliceStyle="sliced"

sortXAxis = "yes"

>

<cfchartseries

type="pie"

query="GetCountry"

valuecolumn="countrycounter"  itemcolumn="countrylong" />

You are right. The chart attribute labelformat="percent" produces a pie chart with percentages that don't match. Indeed, many are several hundred percent! That could possibly be a bug.

To correct the problem, use the following chartseries attribute instead: datalabelstyle="pattern". That is

<CFCHART

format="flash"

show3d="yes"

showlegend="yes"

chartheight="800"

chartwidth="900"

showborder="true"

pieSliceStyle="sliced"

sortXAxis = "yes"

>

<cfchartseries

type="pie"

query="GetCountry"

datalabelstyle="pattern"

valuecolumn="countrycounter" 

itemcolumn="countrylong" />

</cfchart>

However, be aware that it is inadvisable to represent more than, say, a dozen or so data values on a pie chart. It can then get a bit crowded, especially if you decide to slice the pie, as you have done. In any case, 74 data points is way too much data to represent on a pie chart.

ACS LLCAuthor
Inspiring
January 24, 2012

Thanks for the help, I could not find any info on datalabelstyle, and even after a search now that I have it I can't find anything

You are right, once I added this, its a little busy, trying to label every country

I think I might be best trying to label with a percentage and then mouse over for the country with percentage but I'm not sure if this can be done?

Right now when I mouse over the slice I get the country name with a total, but no percentage.

Is it possible to put the percentage and country etc into the mouse over label?

Then perhaps I can switch the regular label to just a percentage

Thanks!

Mark

BKBK
Adobe Expert
January 24, 2012

ACS LLC wrote:

Thanks for the help, I could not find any info on datalabelstyle, and even after a search now that I have it I can't find anything

You are right, once I added this, its a little busy, trying to label every country

I think I might be best trying to label with a percentage and then mouse over for the country with percentage but I'm not sure if this can be done?

Right now when I mouse over the slice I get the country name with a total, but no percentage.

Is it possible to put the percentage and country etc into the mouse over label?

Then perhaps I can switch the regular label to just a percentage

The functionality you seek could be in some curious attribute combination in there somewhere. However, we could also play dumb, and create just what we need manually, and then do a mouseover. I was thinking of something like this

<cfquery name="getSum" dbtype="query">

    select sum(countrycounter) as sumCounter

    from GetCountry

</cfquery>

<cfquery name="getCountryPercentage" dbtype="query">

    select countrycounter*100/#getSum.sumCounter# as countryCounter, countrylong

    from GetCountry

</cfquery>

<CFCHART

format="flash"

show3d="yes"

showlegend="yes"

chartheight="800"

chartwidth="900"

showborder="true"

tipStyle = "mouseOver"        

pieSliceStyle="sliced"

sortXAxis = "yes"

>

<cfchartseries

type="pie"

query="getCountryPercentage"

valuecolumn="countrycounter" 

itemcolumn="countrylong" />

</cfchart>

Inspiring
January 22, 2012

Can you provide a repro case that includes the data (which is kinda important to your question).

Just mock a query up with queryNew() / queryAddColumn() etc.

Where possible, if you have a problem you should try to give us a repro case that is completely self-contained, and stand-alone (without any inferences as to how external systems like DB data might affect what you're seeing).  Obviously this is not always possible, but it definitely is in this case.

Cheers.

--

Adam

ACS LLCAuthor
Inspiring
January 22, 2012

The query is pretty basic

<CFQUERY NAME="GetCountry" DATASOURCE="#datasource#">
SELECT countrylong,countrycounter
FROM countrylist
WHERE countrycounter > 0

</CFQUERY>

Here is a CFDUMP of the data

query
RESULTSET
query
COUNTRYCOUNTERCOUNTRYLONG
12 BELGIUM
213 ALGERIA
36 KUWAIT
410 OMAN
52 VENEZUELA, BOLIVARIAN REPUBLIC OF
628 PHILIPPINES
712 BRUNEI DARUSSALAM
82 CZECH REPUBLIC
94 GHANA
101 BANGLADESH
1171 MALAYSIA
12505 UNITED STATES
1332 ITALY
141 LATVIA
152 PANAMA
162 NORWAY
175 AUSTRIA
188 ROMANIA
1963 THAILAND
205 NETHERLANDS
2127 MEXICO
2212 UNITED ARAB EMIRATES
234 IRAQ
2422 EGYPT
2565 KOREA, REPUBLIC OF
26114 VIET NAM
273 SWITZERLAND
2811 SWEDEN
296 MOROCCO
3027 UNITED KINGDOM
3113 SPAIN
3218 CHINA
335 CAMBODIA
3466 INDONESIA
357 JORDAN
3626 TURKEY
3713 SINGAPORE
383 BAHRAIN
3934 GERMANY
4017 AUSTRALIA
41407 INDIA
4214 KAZAKHSTAN
4333 SLOVAKIA
4414 PAKISTAN
454 KENYA
468 UKRAINE
47111 SAUDI ARABIA
4826 TAIWAN
492 ISRAEL
5029 BRAZIL
514 PERU
525 ARGENTINA
535 COSTA RICA
541 LAO PEOPLE'S DEMOCRATIC REPUBLIC
5543 RUSSIAN FEDERATION
5610 CANADA
576 SERBIA
585 PUERTO RICO
593 SLOVENIA
603 BELARUS
614 FINLAND
6239 HONG KONG
631 GUAM
6485 JAPAN
656 SOUTH AFRICA
661 ESTONIA
673 HUNGARY
686 GREECE
692 DENMARK
7016 FRANCE
711 BULGARIA
722 GUADELOUPE
731 TURKMENISTAN
744 POLAND
CACHEDfalse
EXECUTIONTIME2
SQLSELECT countrylong,countrycounter FROM countrylist WHERE countrycounter > 0
Inspiring
January 22, 2012

Can you go back to my earlier post and read it.  You've not provided a repro case, you've just given me a dump of some data.  What am I supposed to do with that?

A repro case is some code that can be run and deomnstrates the problem (and then it can be tweaked etc to work out what the problem is).  SO go back and - please - do what I've asked you to do.  This is all part of learning how to solve your own problems (which in the long run is gonna be more helpful to you than just asking questions).

Trust me.

--

Adam