如何设置Google时间轴图表的最小和最大日期? [英] How to set Min and Max date for Google timeline charts?

查看:250
本文介绍了如何设置Google时间轴图表的最小和最大日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Google时间轴图表中设置最小和最大日期。
Google时间轴图表



我试过使用

  hAxis:{
viewWindow:{
分钟:新日期(2014,1,31)
}}

p>

  hAxis:{
viewWindow:{
minValue:new Date(2014,1,31)
}}

都不起作用。如果没有办法设置日期范围,如何获取由api本身设置的最小和最大日期值? 解决方案

谷歌图表43版(发布于10月2日, 2015)支持横轴的minValue和maxValue:

  .... 

var options = {
hAxis:{
minValue:new Date(1785,0,0),
maxValue:new Date(1816,0,0)
}
};

...

您必须通过冻结版本加载器,但显然它未按照常规流程成功部署



它看起来像minValue和maxValue只适用于在时间线的开始和结束处放置间距。因此,如果您指定的minValue晚于某个数据点的开始日期,那么时间线仍然会从该数据点开始,而不是在minValue。



这里是一个 jsfiddle ,它显示了minValue和maxValue在第一个Google时间轴示例的开始和结束处提供间距:https://jsfiddle.net/o27ttyy3


I would like to set the Min and Max date in Google timeline charts. Google Timeline Charts

I have tried using

 hAxis: {
        viewWindow: {
          min: new Date(2014, 1, 31)
        }}

and

 hAxis: {
        viewWindow: {
          minValue: new Date(2014, 1, 31)
        }}  

both does not work. If there is no way to set the date ranges, how to get the Min and Max date values that is set by the api itself?

解决方案

Google Charts version 43 (released October 2, 2015) supports minValue and maxValue for the horizontal axis:

....

var options = {
  hAxis: {
    minValue: new Date(1785, 0, 0),
    maxValue: new Date(1816, 0, 0)
  }
};

....

You have to load it via the frozen version loader though since apparently it wasn't successfully deployed by the usual process.

It looks like minValue and maxValue works only for putting spacing at the beginning and end of the timeline. So if you specify a minValue that is later than the start date of one of your data points, the timeline still starts at that data point and not at the minValue.

Here is a jsfiddle that shows minValue and maxValue providing spacing at the beginning and end of the first Google Timeline example: https://jsfiddle.net/o27ttyy3

这篇关于如何设置Google时间轴图表的最小和最大日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆