简体   繁体   English

chart.js在固定时间范围内绘制时间序列数据

[英]chart.js plot timeseries data on a fixed timescale

I've got a data with the interval of 1 minutes for steppedLine chart which is looks like: 我有一个间隔为1分钟的steppedLine图表数据,看起来像:

0: {x: "15:33", y: 0}
1: {x: "15:34", y: 0}
2: {x: "15:35", y: 1}
3: {x: "15:36", y: 1}
4: {x: "15:37", y: 0}

The data however might only cover few hours from 24 hours(no data available for remained hours) I want to plot it on the 24 hour hour scale public lineChartLabels: Array<any> = ['0:00', '1:00', '2:00', '3:00', '4:00', '5:00', '6:00', '7:00', '8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00']; 但是数据可能仅覆盖24小时内的几个小时(剩余时间无可用数据)我想在24小时小时制public lineChartLabels: Array<any> = ['0:00', '1:00', '2:00', '3:00', '4:00', '5:00', '6:00', '7:00', '8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'];绘制它图表public lineChartLabels: Array<any> = ['0:00', '1:00', '2:00', '3:00', '4:00', '5:00', '6:00', '7:00', '8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'];

Question - what is the best way to do so? 问题 -最好的方法是什么?

You could add in the other fields for the 24 hours, but keep them blank and overwrite them as time goes on. 您可以在24小时内添加其他字段,但将其保留为空白并随着时间的推移而覆盖它们。

(I would comment this, but I don't have enough reputation.) (我会对此发表评论,但是我没有足够的声誉。)

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

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