简体   繁体   English

Google Charts Annotated Time Line - 在缩放时调整y轴

[英]Google Charts Annotated Time Line - adjust y-axis on zoom

I am using the annotated time line chart in google charts API. 我在谷歌图表API中使用带注释的时间线图表 I have a long time line of data (20 years) and range of the data goes from about 0 to 900,000 (see picture) If you zoom on the most recent year, the max from this set is only about 400,000. 我有一个很长的时间线数据(20年),数据范围从大约0到900,000(见图)如果你放大最近一年,这个集合的最大值只有大约400,000。 So when we zoom in, I don't need the y-axis to go all the way to 900,000, but only to 400,000. 因此,当我们放大时,我不需要y轴一直到900,000,但只需要400,000。 This way the chart would be easier to read. 这样,图表更容易阅读。

What I would like to achieve is the chart to re-adjust the maximum vertical axis value every time I adjust the zoom. 我想要实现的是每次调整变焦时重新调整最大垂直轴值的图表。

在此输入图像描述

Zoom in on most recent year: 放大最近一年:

在此输入图像描述

Before I start hacking my way through this, does anyone know a good way to do this? 在我开始黑客攻击之前,有没有人知道这样做的好方法?

Thanks! 谢谢!

Use the scaleType configuration option . 使用scaleType 配置选项 Specify value of maximized if you have one series. 如果您有一个系列,请指定最大化的值。 Specify allmaximized if you have more than one series. 如果您有多个系列,请指定allmaximized This snippet works on the code playground : 此代码段适用于代码操场

  var annotatedtimeline = new google.visualization.AnnotatedTimeLine(
      document.getElementById('visualization'));
  annotatedtimeline.draw(data, {'scaleType':'allmaximized'});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM