2016-09-16 202 views
3

如何在xAxes上设置最小值和最大值?它在yAxes上正常工作,但在xAxes上没有显示任何行为。我的xAxes正在使用type: 'time'。我的标签xAxis也使用moment对象。但是,当我删除类型时间并使用正常数字时,它也不起作用。我正在使用Chart.js版本2.2.2。Chart.js时间刻度:在xAxes上设置最小值和最大值

scales: { 
    yAxes: [{ 
     ticks: { 
     beginAtZero:false, 
     } 
    }], 
    xAxes: [{ 
     type: 'time', 
     ticks: { 
     min: moment(1471174953000), 
     max: moment(1473853353000) 
     } 
    }] 
} 

Here is the chart.js Time Scale documentation.

回答

8

你正在寻找真正的性质都在time属性:

options: { 
    scales: { 
     xAxes: [{ 
      type: "time", 
      time: { 
       min: 1471174953000, 
       max: 1473853353000 
      } 
     }] 
    } 
} 
+0

谢谢,这是为我工作。我只是想知道为什么我可以将最小/最大值放在yAxes的ticks属性中。 – Steckdoserich

+0

@Steckdoserich我也不知道,这是它是如何内置的。我想这是有用的,如果你有几个xAxes – tektiv

+0

好吧。另外,有没有办法切断重叠的图形?现在这张图正在通过yAxes。 – Steckdoserich

相关问题