Chart.js时间刻度:在xAxes上设置最小值和最大值

dba5bblo  于 2022-11-06  发布在  Chart.js
关注(0)|答案(2)|浏览(278)

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

  1. scales: {
  2. yAxes: [{
  3. ticks: {
  4. beginAtZero:false,
  5. }
  6. }],
  7. xAxes: [{
  8. type: 'time',
  9. ticks: {
  10. min: moment(1471174953000),
  11. max: moment(1473853353000)
  12. }
  13. }]
  14. }

下面是chart.js时间刻度文档。

nbewdwxp

nbewdwxp1#

您要查找的属性实际上位于time属性中:

  1. options: {
  2. scales: {
  3. xAxes: [{
  4. type: "time",
  5. time: {
  6. min: 1471174953000,
  7. max: 1473853353000
  8. }
  9. }]
  10. }
  11. }
ybzsozfc

ybzsozfc2#

这在3.0中已更改
https://www.chartjs.org/docs/latest/getting-started/v3-migration.html#options

  1. scales.[x/y]Axes.time.max was renamed to scales[id].max
  2. scales.[x/y]Axes.time.min was renamed to scales[id].min

相关问题