如何使 Google Charts 正确缩放扩展编码线图?
在我的一生中,我无法使用扩展编码正确显示该图表。
如果我将轴范围从 0 更改为 15,它看起来是正确的,但如果我将轴范围从 9 更改为 15,则数据绘制不正确。
结果是正确的:
<img src="http://chart.apis.google.com/chart?cht=lc&chco=125292&chm=B,cee1f5,0,0,0&chls=2&chs=408x237&chxt=x,y&chxl=0:|Jan|Feb|Mar|Apr|May|Jun|Jul&chxr=1,0,15&chd='+extendedEncode(Array(10,15,9,11,12,10,11),15)+'" />
但这缩放不正确:
<img src="http://chart.apis.google.com/chart?cht=lc&chco=125292&chm=B,cee1f5,0,0,0&chls=2&chs=408x237&chxt=x,y&chxl=0:|Jan|Feb|Mar|Apr|May|Jun|Jul&chxr=1,9,15&chd='+extendedEncode(Array(10,15,9,11,12,10,11),15)+'" />
我花了几个小时试图弄清楚这一点出来,我觉得我错过了一些非常简单的东西。由于我的程序最终要处理的数字范围,我必须使用扩展编码,因此更改为“具有自定义缩放比例的文本格式”不是一个选项。
For the life of me, I can't get this graph to display properly with extended encoding.
If I change the axis range from 0 to 15, it looks correct, but if I change the axis from 9 to 15, the data is plotted incorrectly.
This turns out correct:
<img src="http://chart.apis.google.com/chart?cht=lc&chco=125292&chm=B,cee1f5,0,0,0&chls=2&chs=408x237&chxt=x,y&chxl=0:|Jan|Feb|Mar|Apr|May|Jun|Jul&chxr=1,0,15&chd='+extendedEncode(Array(10,15,9,11,12,10,11),15)+'" />
But this scales incorrectly:
<img src="http://chart.apis.google.com/chart?cht=lc&chco=125292&chm=B,cee1f5,0,0,0&chls=2&chs=408x237&chxt=x,y&chxl=0:|Jan|Feb|Mar|Apr|May|Jun|Jul&chxr=1,9,15&chd='+extendedEncode(Array(10,15,9,11,12,10,11),15)+'" />
I have spent hours and hours trying to figure this out, and I feel like I'm missing something incredibly simple. I have to use extended encoding because of the range of numbers my program will ultimately be handling, so changing to "Text Format with Custom Scaling" is not an option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
读这个:
http://code.google.com/apis/chart /image/docs/gallery/line_charts.html#axis_range
和这个:
http://code.google.com/apis/chart/image /docs/data_formats.html#axis_scale
当使用简单或扩展编码时,无论您使用什么,数据都会达到 0-100 的比例。这让 Google Chart 减少了 url 长度并将更多数据放入 GET HTTP 请求中。
作为副作用,您必须缩放数据而不是轴。由于绘制这些图表时不使用轴数据。
Read this:
http://code.google.com/apis/chart/image/docs/gallery/line_charts.html#axis_range
and this:
http://code.google.com/apis/chart/image/docs/data_formats.html#axis_scale
When using simple or extended encoding data is brought to 0-100 scale no matter what you use. This let Google Chart reduce url length and fit more dat into the GET HTTP Request.
As a side effect you have to scale the data instead of the axis. Since the axis data is not used when plotting these charts.