Jonas T
Jonas T

Reputation: 3077

Google Chart(Pie Chart) Bug?

Please check the following chart and why the size of 10.52% and 2.72 are the same?

https://chart.googleapis.com/chart?cht=pc&chxs=0,000000,9&chxt=x&chs=490x200&chp=4.7&chd=t:720,207,322,108,69,283,519,246,138,158,89,344&chl=%2822.03%25%29|%286.33%25%29|%289.85%25%29|%283.30%25%29|%282.11%25%29|%288.65%25%29|%2815.88%25%29|%287.52%25%29|%284.22%25%29|%284.83%25%29|%282.72%25%29|%2810.52%25%29&chco=FF00FF|336699|800000|FF00FF|ff6600|808000|0099cc|3366ff|000000|3399ff|C0C0C0|800080|00FF00

Upvotes: 1

Views: 1088

Answers (2)

phils
phils

Reputation: 73246

You were just missing the chds=a parameter, which specifies "automatic scaling" of the values. Add that and the chart will be correct when the data are not percentages.

See: https://developers.google.com/chart/image/docs/data_formats#textformatautoscaling

Here is your example chart with the added parameter.

Unfortunately you'll get seemingly-accurate results without this parameter a lot of the time, so it's easy to miss it. It appears to me that it's basically a requirement for pie charts, though, so I can't imagine why it isn't the default behaviour.

Providing exact percentage values might also work correctly in all situations. I don't actually know the details of the problem, only that automatic scaling solves it when it occurs, so I'm inclined to suggest using it just in case.

Upvotes: 1

Jonas T
Jonas T

Reputation: 3077

chd=t: values are percentage. I thought they were values and google chart will work out the percentage for them.

It has been fixed as soon as I replaced actual values with percentage values. The chart is fixed.

Upvotes: 0

Related Questions