fix: 修复折线图切换不同选项后,图形初始化偶现错误
This commit is contained in:
@@ -199,8 +199,6 @@ export default {
|
||||
}
|
||||
const _this = this
|
||||
if (echartsData.length > 0) {
|
||||
const dom = document.getElementById('dnsLineChart')
|
||||
!this.myChart && (this.myChart = echarts.init(dom))
|
||||
this.chartOption = stackedLineChartOption
|
||||
const chartOption = this.chartOption.series[0]
|
||||
this.chartOption.series = echartsData.map((t, i) => {
|
||||
@@ -284,7 +282,13 @@ export default {
|
||||
return stackedLineTooltipFormatter(params)
|
||||
}
|
||||
this.showMarkLine = true
|
||||
this.myChart.setOption(this.chartOption)
|
||||
this.$nextTick(() => {
|
||||
if (this.myChart) {
|
||||
this.myChart.dispose()
|
||||
}
|
||||
this.myChart = echarts.init(document.getElementById('dnsLineChart'))
|
||||
this.myChart.setOption(this.chartOption)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -197,8 +197,8 @@ export default {
|
||||
}
|
||||
|
||||
const _this = this
|
||||
const dom = document.getElementById('linkTrafficLineChart')
|
||||
!this.myChart && (this.myChart = echarts.init(dom))
|
||||
// const dom = document.getElementById('linkTrafficLineChart')
|
||||
// !this.myChart && (this.myChart = echarts.init(dom))
|
||||
|
||||
this.chartOption = linkTrafficLineChartOption
|
||||
const chartOption = this.chartOption.series[0]
|
||||
@@ -253,7 +253,13 @@ export default {
|
||||
}
|
||||
|
||||
this.showMarkLine = true
|
||||
this.myChart.setOption(this.chartOption)
|
||||
this.$nextTick(() => {
|
||||
if (this.myChart) {
|
||||
this.myChart.dispose()
|
||||
}
|
||||
this.myChart = echarts.init(document.getElementById('linkTrafficLineChart'))
|
||||
this.myChart.setOption(this.chartOption)
|
||||
})
|
||||
}
|
||||
},
|
||||
activeChange (item, index) {
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user