2
votes

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?

3
This should probably be on the webapps stackexchange site - Jherico
Pasting that url into their wizard tool doesn't work, they say it's not properly formatted. - fredley
Since I'm already calculating my percentages server side, I might as well provide the percentages as the data -- they will always be 0-100 and I don't have to worry about the scaling parameter. Thanks - Michael Butler

3 Answers

5
votes

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

3
votes

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.

0
votes

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