如何在Google Chart中设置轴步长?
我想知道如何在由 JavaScript 构建的谷歌图表中设置轴步长? 我用它来设置最小值和最大值:
vAxis: {
title: 'temps (ms)',
viewWindowMode: 'explicit',
viewWindow: {
max: 180,
min: 0
},
}
例如,我需要添加另一个约束来将垂直步长固定为 0.1。
I'm wondering how to set axis step in a google chart built from JavaScript?
I use this to set min and max:
vAxis: {
title: 'temps (ms)',
viewWindowMode: 'explicit',
viewWindow: {
max: 180,
min: 0
},
}
And I need to add an other constraint to fix vertical step to 0.1 for example.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最后我发现了一个技巧:
它不设置步骤,而是告诉
因此,例如将 max 设置为 180,则每个步骤的值为 18 > 使用
计数:10
。Finally I found a trick using :
It don't set steps but instead, tell that
So for example with max set to 180, each steps will have a value of 18 using
count: 10
.你可以用刻度线来做到这一点:
You can do it with ticks:
我基本上做了 alain 所做的事情,计算最大值,将其乘以 1.1(考虑图表上最大元素上方的填充),然后除以我想要的步骤,得到我需要的步骤。
其中
max
是最大值,interval
是所需的间隔。这尚未经过彻底测试,因此
1.1
的常量和使用Math.ceil
可能需要调整。I essentially did what alain did, calculating the max value, multiplying it by 1.1 (to account for the padding above the max element on the chart) and dividing it by the steps I wanted to give me the steps I needed.
where
max
is the max value andinterval
is the desired interval.This has not been thoroughly tested, so the constant of
1.1
and usingMath.ceil
may need to be tweaked.