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

CFCHART - Percentages not right

Enthusiast ,
Jan 21, 2012 Jan 21, 2012

Copy link to clipboard

Copied

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

TOPICS
Advanced techniques

Views

2.9K

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
LEGEND ,
Jan 22, 2012 Jan 22, 2012

Copy link to clipboard

Copied

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

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
Enthusiast ,
Jan 22, 2012 Jan 22, 2012

Copy link to clipboard

Copied

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

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
LEGEND ,
Jan 22, 2012 Jan 22, 2012

Copy link to clipboard

Copied

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

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
Community Expert ,
Jan 23, 2012 Jan 23, 2012

Copy link to clipboard

Copied

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.

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
Enthusiast ,
Jan 23, 2012 Jan 23, 2012

Copy link to clipboard

Copied

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

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
Community Expert ,
Jan 24, 2012 Jan 24, 2012

Copy link to clipboard

Copied

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>

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
Enthusiast ,
Jan 24, 2012 Jan 24, 2012

Copy link to clipboard

Copied

Very Creative

That's much easier to read now, the only thing I am missing is the totals, in the first attempt on the main labels that were visible without mouse over it had the count of the slice and also 'out of' ... am I pushing it now 😉

Thanks

Mark

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
Community Expert ,
Jan 24, 2012 Jan 24, 2012

Copy link to clipboard

Copied

ACS LLC wrote:

Very Creative

That's much easier to read now, the only thing I am missing is the totals, in the first attempt on the main labels that were visible without mouse over it had the count of the slice and also 'out of' ... am I pushing it now 😉

That was the datalabelstyle="pattern" attribute of the chartseries. However, it puts the "out of..." on the chart itself, not on the mouseover. In any case, if we were to do that now, I would expect it to say "out of 100%"!

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
Valorous Hero ,
Jan 24, 2012 Jan 24, 2012

Copy link to clipboard

Copied

LATEST
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

"LabelFormat"  does not perform calcuations. It just applies a simple mask to the axis values, controlling how they are displayed ie As a simple number (33), percentage (3300%), currency ($33.00) etecetera.

      

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