简体   繁体   English

Chartjs xaxes 最小刻度

[英]Chartjs xaxes tick min

I am trying to continue the chart in the future, even though there are is no data for those specific dates.即使没有这些特定日期的数据,我也会尝试在未来继续绘制图表。 I have created an example: https://jsfiddle.net/r28wa54q/1/ .我创建了一个示例: https://jsfiddle.net/r28wa54q/1/ I have placed the minimum value and maximum value inside the ticks, as follows:我在刻度内放置了最小值和最大值,如下所示:

"xAxes": [{
        "type": "time",
        "distribution": 'series',
        "time": {
          "displayFormats": {
            "second": "HH:mm:ss",
            "minute": "HH:mm:ss",
            "hour": "D. MMM HH:mm",
            "day": "D. MMM",
            "quarter": "[Q]Q/YYYY"
          },
          
        },
        "ticks": {
          "min": 1498860000000,
          "max": 1500115887909
        }
      }]

I would expect the xaxes to continue until the 15th of july (ticks.max) but it stops on the last data point.我希望 xaxes 会持续到 7 月 15 日(ticks.max),但它会在最后一个数据点停止。 Moving the min and max combination inside the scales.xAxes.times throws deprecation errors.在 scales.xAxes.times 中移动 min 和 max 组合会引发弃用错误。

This is the correct place (I think) according to the documentation ( https://www.chartjs.org/docs/latest/axes/cartesian/ ), am I missing something?根据文档( https://www.chartjs.org/docs/latest/axes/cartesian/ ),这是正确的地方(我认为),我错过了什么吗?

This seems to happen because you have set distribution to series , I guess chart.js doesnt like this internally so it might be a bugg.这似乎是因为您已将分布设置为series ,我猜 chart.js 在内部不喜欢这个,所以它可能是一个错误。 If you set it to linear it will work.如果将其设置为linear ,它将起作用。

https://jsfiddle.net/Leelenaleee/6c0vzaod/2/ https://jsfiddle.net/Leelenaleee/6c0vzaod/2/

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

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