fix: 修复折线图切换不同选项后,图形初始化偶现错误

This commit is contained in:
刘洪洪
2023-03-28 16:19:54 +08:00
parent d4ab1d19e6
commit 4af4dc4260
3 changed files with 27 additions and 10 deletions

View File

@@ -212,8 +212,8 @@ export default {
echartsData = echartsData.filter(t => t.show === true)
this.$nextTick(() => {
if (echartsData.length > 0) {
const dom = this.$refs['chart-line']
!this.myChart && (this.myChart = echarts.init(dom))
// const dom = this.$refs['chart-line']
// !this.myChart && (this.myChart = echarts.init(dom))
this.chartOption = _.cloneDeep(trafficLineChartOption)
const chartOption = this.chartOption.series[0]
@@ -275,8 +275,15 @@ export default {
return stackedLineTooltipFormatter(params)
}
this.myChart.on('legendselectchanged', this.selectLegend)
this.myChart.setOption(this.chartOption, true)
this.$nextTick(() => {
if (this.myChart) {
this.myChart.dispose()
}
const dom = this.$refs['chart-line']
this.myChart = echarts.init(dom)
this.myChart.setOption(this.chartOption, true)
this.myChart.on('legendselectchanged', this.selectLegend)
})
}
})
},