views:

84

answers:

3

I have some pretty basic data for a pie chart.

Yes:     189.84 (57.03%)
No:      252 (42.97%)
Abstain: 0 (0%)

When I request the google pie chart at this URL: http://chart.apis.google.com/chart?cht=p&chs=400x200&chl=Yes%2042.97%|No%2057.03%|Abstain%200%&chd=t:189.84,252,0&chdl=189.84|252|0&chco=FF0000

...It looks very much like each colored section is exactly 50%, even though one is 42% and the other is 57%. Is this a problem with my data format or is this a limitation of the pie chart service?

A: 

Are you feeding it what it expects? (Two columns: column 1 a string, column 2 a number?)

John at CashCommons
+3  A: 

You need to set the scale. Add &chds=0,252 to the end of your URL to set the minimum 0 and the maximum 252.

As far as I can tell, it doesn't matter what the maximum is, as long as it is larger than your largest value.

So this would be the URL: http://chart.apis.google.com/chart?cht=p&chs=400x200&chl=Yes%2042.97%|No%2057.03%|Abstain%200%&chd=t:189.84,252,0&chdl=189.84|252|0&chco=FF0000&chds=0,252

Serplat
+2  A: 

From the docs:

Basic text-formatted data lets you specify floating point values from 0—100, inclusive, as numbers.

Everything > 100 is interpreted as 100. Check this:

http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=t:100,1000

Or, as Serplat correctly mentions, add scaling.

Henning