here's the code:
list.component.ts
chart: any = []
data = [
{
date: (5) ["2020-02-15 12:00:00",, "2020-02-15 13:00:00", "2020-02-15 14:00:00", "2020-02-15 15:00:00", "2020-02-15 16:00:00"],
temperature: (5) [24.8, 25, 25.3, 25.3, 25.4]
},{
date: (5) ["2020-02-26 11:00:00" ,"2020-02-26 12:00:00" ,"2020-02-26 13:00:00" ,"2020-02-26 14:00:00" ,"2020-02-26 15:00:00"],
temperature: (5) [25.4, 25.3, 25.7, 25.5, 25.7]
}, {
date: (4) ["2020-02-26 12:00:00" ,"2020-02-26 13:00:00" ,"2020-02-26 14:00:00" ,"2020-02-26 15:00:00"],
temperature: (4) [27.9, 27.6, 27.4, 27.3]
}
];
ngOnInit() {
data.foreach((param: any) => {
option = {
xAxis: {
type: 'category',
boundaryGap: false,
data: param.date
},
yAxis: {
type: 'value'
},
series: [{
data: param.temperature,
type: 'line',
areaStyle: {}
}]
};
this.chart.push(option);
}
}
What I'm trying to here is to display an array of echarts, but there's an error in the date. It only gets the last item data, instead it should get the data based on their index.
list.component.ts
<div *ngFor="let record of data;let i = index">
<div echarts [options]="chartOption[i]" [autoResize]="true" style="height: 210px;"></div>
</div>