Google 饼图非常不准确,分别为 57% 和 42%
我有一些非常基本的饼图数据。
Yes: 189.84 (57.03%)
No: 252 (42.97%)
Abstain: 0 (0%)
当我在此 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
...看起来非常像每个彩色部分正好是 50%,尽管一个是 42%,另一个是 57%。这是我的数据格式的问题还是饼图服务的限制?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要设置比例。将
&chds=0,252
添加到 URL 末尾以设置最小值 0 和最大值 252。据我所知,最大值是多少并不重要,只要它大于您的最大值。
因此,网址为:http://chart.apis.google.com/chart?cht =p&chs=400x200&chl=是%2042.97%|否%2057.03%|弃权%200%&chd=t:189.84,252,0&chdl=189.84|252|0&chco=FF0000&chds=0,252
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
来自文档:
一切> 100 被解释为 100。检查一下:
http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=t:100,1000
或者,正如 Serplat 正确提到的那样,添加 缩放。
From the docs:
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.
你给它喂的东西符合它的预期吗? (两列:第一列是字符串,第二列是数字?)
Are you feeding it what it expects? (Two columns: column 1 a string, column 2 a number?)