How to set Min and Max date for Google timeline charts?

前端 未结 1 1636
耶瑟儿~
耶瑟儿~ 2021-01-11 10:01

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

I have tried using

 hAxis: {
        viewWindow: {
                


        
相关标签:
1条回答
  • 2021-01-11 10:43

    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

    0 讨论(0)
提交回复
热议问题