在谷歌图表API中,如何更改轴的位置?
制作图表时是否可以将轴的原点置于中间,以便显示轴的交叉? 我们使用一种解决方法,通过设置网格使网格线落在 (0,0) 点 但这样你就不能使用更细的网格层来获得更好的视觉引导。 如果没有解决方法,是否可以实现? 例如下面的图表?
在图表 API 论坛和文档中进行的准确研究仅显示了解决方法。 如果没有标准的解决方案,你能想一下为什么google没有实现轴的定位吗?
When making a chart is it possible to center the origin of the axes into the middle so that a cross of axes shows up?
We use a workaround, by setting the grid so that the grid line falls to the (0,0) point
But then you can not use a finer lined grid layer for better visual guidance.
Is it possible without workaround?
For example with the following chart?
A accurate research in the chart api forum and the documentation showed only workarounds.
If no standard solution is available, can you think about a reason why google did not implement the positioning of axes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,每个谷歌图表都在 [0% 到 100%] 范围内。因此,如果您想要不同的值(例如负值),您将需要一些算术来完成它。
我还制作了 此问题的解决方法。使用 50% 步长策略的网格。就我而言,由于我的 X 轴和 Y 轴范围从 -100 到 100,因此我必须应用于任何值的函数为:f(v) = (v - 100) / 2。
有一个元素可以是添加以使该解决方案完整。如果 API 提供了多个具有不同分辨率(不同步长)的网格,则可以添加另一个更细的网格层。
恕我直言,谷歌图表 API 提供了较低级别的调用来控制图表上的视觉元素。我想说,这里缺少的元素是多个网格,以允许更精细的衬里层。使用这些元素,上层 API 可以由 google 构建,也可以封装在包装器库上,例如 charts4j。这个上层 API 应该处理算术和像这两个网格这样的问题。
Seems to me that every google chart is on a [0% to 100%] range. Só if you want different values (like negative ones) you are going to need some arithmetics to accomplish it.
I've also made a workaround to this problem. Using the grid with 50% step strategy. In my case, due to my X and Y axes ranging from -100 to 100 the function i'd have to apply to any values would be: f(v) = (v - 100) / 2.
There's one element that could be added to make this solution complete. If only the API provided multiple grids with different resolution (different step sizes) another finer lined grid layer could be added.
IMHO google charts API provides lower level calls to control visual elements on charts. I'd say that the missing element here is the multiple grids to allow the finer lined layer. With those elements a upper level API could be built either by google or encapsulated on a wrapper lib like charts4j. This upper level API should handle arithmetics and issues like this two grids.