echarts动态加载数据无法更新series
更改前
setOptions({week,ruleArr,totalData} = {}) {
const option = {
title: {
text: '每日收入'
},
xAxis: {
data: week,
boundaryGap: false,
axisTick: {
show: false
}
},
grid: {
left: 10,
right: 10,
bottom: 20,
top: 60,
containLabel: true
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
},
padding: [5, 10]
},
yAxis: {
axisTick: {
show: false
}
},
legend: {
data: ruleArr,
width:700
},
series: totalData
}
this.chart.setOption(option);
}
打印发现传入的值都是有改变的,但页面上还是显示一开始的数据,查完资料发现图表数据会和之前的合并。
更改后
setOptions({week,ruleArr,totalData} = {}) {
const option = {
title: {
text: '每日收入'
},
xAxis: {
data: week,
boundaryGap: false,
axisTick: {
show: false
}
},
grid: {
left: 10,
right: 10,
bottom: 20,
top: 60,
containLabel: true
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
},
padding: [5, 10]
},
yAxis: {
axisTick: {
show: false
}
},
legend: {
data: ruleArr,
width:700
},
series: totalData
}
this.chart.setOption(option,true);
}