我有3组数据,其中我必须在图表中依次显示每个数据集,例如前5秒钟应该显示数据集1,接下来5秒钟应该显示数据集
我尝试使用updatechart函数,但不起作用
export class AcidLineChartComponent implements OnInit {
public lineChartData: ChartDataSets[] = [
{ data: [33, 4, 21, 35, 67, 8, 34] },
{ data: [34,4,61,43,65,8,12,0,45] },
{ data: [23,4,12,34,65,78,90,56] }
];
public lineChartLabels: Array<any> = [1522.37, 1522.40, 1522.43, 1522.46, 1522.49, 1522.52, 1522.55, 1522.58];
public randomize(): void {
const lineChartData: ChartDataSets[] = new Array(this.lineChartData.length);
for (let i = 0; i < this.lineChartData.length; i++) {
lineChartData[i] = { data: new Array(this.lineChartData[i].data.length), label: this.lineChartData[i].label };
for (let j = 0; j < this.lineChartData[i].data.length; j++) {
lineChartData[i].data[j] = Math.floor((Math.random() * (i < 2 ? 100 : 1000)) + 1);
}
}
this.lineChartData = lineChartData;
}
updateChart(){
let _dataSets:Array<any> = new Array(this.lineChartData.length);
for (let i = 0; i < this.lineChartData.length; i++) {
_dataSets[i] = {data: new Array(this.lineChartData[i].data.length), label: this.lineChartData[i].label};
for (let j = 0; j < this.lineChartData[i].data.length; j++) {
_dataSets[i].data[j] = this.lineChartData[i].data[j];
}
}
this.lineChartData = _dataSets;
// this.lineChartData = this.lineChartData.slice()
}
}
我想显示一个图表,它必须一个接一个地显示linechartdata。目前,我一次获得三个图表。 可以建议答案。。谢谢。