【发布时间】:2021-07-28 09:32:23
【问题描述】:
当这样通过时
错误:“实时”不是注册比例
刷新功能:
onRefresh=(chart) =>{
var now = Date.now();
chart.data.datasets[0].data.push({
x: now,
y: this.state.realdata.sitting
});
}
组件:
<Line
data={{
datasets: [
{
label: "Customers",
borderColor: "rgb(54,162, 235)",
backgroundColor: "rgba(54,162, 235, 0.5)",
lineTension: 0,
borderDash: [8, 4],
data: this.state.livePeopleSitting,
},
],
}}
options={{
scales: {
x: {
type: "realtime",
realtime: {
onRefresh: this.onRefresh,
delay: 4000,
duration: 160000,
refresh: 3000,
},
},
y: {
title: {
display: true,
text: "people seated",
},
},
},
}}
/>
通过尺度后
x: [{
...
}]
而不是
x: {
...
}
我不再收到错误,但它根本不显示 x 轴, 虽然对象形式是最新的chart.js 3.0.0
【问题讨论】:
标签: reactjs graph chart.js react-chartjs-2