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
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
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 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CACHED | false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
EXECUTIONTIME | 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SQL | SELECT countrylong,countrycounter FROM countrylist WHERE countrycounter > 0 |
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
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.
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
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>
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
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%"!
Copy link to clipboard
Copied
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.