Google Charts 可以支持双 y 轴(v 轴)吗?
The Flot chart api supports dual v-axis scales, as shown by this example.
I'm using Google Charts - is this possible also with Google? I've had a look through the examples and docs, but can't find any examples / references to indicate it does support dual axis charts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我花了一段时间才弄清楚这一点,但 Google 图表确实支持双 Y 轴(v 轴)。我想使用 Javascript API 而不是 HTML 界面。
这个例子可以在这里测试:
http://code.google.com/apis/ajax/playground/ ?type=visualization#line_chart
将所有代码替换为以下代码,显示如何拥有两个不同的 Y 轴刻度:
通过将
maxValue: 2
添加到代码中,并设置系列 1 & ; 2 到该轴,它们在第二个轴上正常工作。It took me a while, to figure this out, but Google Charts does support dual Y-axis (v-axis). I want to use the Javascript API and not the HTML interface.
This example can be tested here:
http://code.google.com/apis/ajax/playground/?type=visualization#line_chart
Replace all of that code with this code showing how to have two different Y-axis scales:
By adding
maxValue: 2
to the code, and setting series 1 & 2 to that axis, they work properly on a second axis.非 JavaScript 解决方案
假设您正在寻找共享相同 X 轴(水平)但 Y 轴(垂直)具有不同值(和比例)的系列,那么您可以这样做无需求助于 JavaScript,如下所示:
现在,您可以编辑图表的各种其他属性,使其在呈现方式上符合您想要的方式。
Non-JavaScript solution
Assuming that you are looking for a series that shares that same X-axis (horizontal) but has different values (and scales) for the Y-axis (vertical) then you can do this without recourse to JavaScript as follows:
You can now edit the various other properties of the chart to get it to look the way you want in terms of presentation.
我做到了。
即可完成。
I did it.
Might be done then.