如何在谷歌图表中以时间格式显示vAxis?
我想创建一个折线图,在垂直轴上显示单圈时间,即:
lap1: 1:14.9
lap2: 1:14.0
lap3: 1:12.8
lap4: 1:13.6
客户希望在垂直轴上有时间格式(而不是普通数字)。是否可以配置谷歌图表来绘制这个?
I would like to create a line chart that show lap times in vertical axis, i.e:
lap1: 1:14.9
lap2: 1:14.0
lap3: 1:12.8
lap4: 1:13.6
The customer would like to have a time format (instead of plain numbers) in vertical axis. Is it possible to configure google charts to draw this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题很老了,但是......
我有一个类似的问题并发布了这个问题。
据我所知,无法通过 vAxis.format 来实现此目的,但您可以使用 vAxis.ticks 来实现您想要的效果。例如,如果您传递给图表的“时间”值只是一个以秒为单位的数字,您可以创建一个
ticks
对象,如下所示:问题是 v 轴将 始终显示您通过的所有刻度。因此,如果您事先不知道 v 轴的范围,您可能必须通过循环数据并确定最高和最低时间来动态生成
ticks
对象。This question is old, but...
I had a similar issue and posted this question.
As far as I'm aware there's no way to do this through
vAxis.format
, but you can achieve the effect you want withvAxis.ticks
. For example, if the "time" value you're passing to your chart is just a number in seconds, you could create aticks
object like this:The catch is that the v-axis will always display all ticks that you pass it. So if you don't know in advance what the range of the v-axis will be, you might have to dynamically generate the
ticks
object by looping over your data and determining what the highest and lowest times are.