initChart (dataSet = [5, 20, 36, 10, 10, 20]) {
if (this.barChart) {//关键步骤
this.barChart.dispose()
this.barChart = null
}
this.barChart = echarts.init(this.$refs.chartBox)
const option = {
title: {
text: ‘ECharts 入门示例’
},
tooltip: {},
legend: {
data: [‘销量’]
},
xAxis: {
data: [‘衬衫’, ‘羊毛衫’, ‘雪纺衫’, ‘裤子’, ‘高跟鞋’, ‘袜子’]
},
yAxis: {},
series: [
{
name: ‘销量’,
type: ‘bar’,
data: dataSet
}
]
}
this.barChart.setOption(option)
}
echart 重新初始化
最新推荐文章于 2024-08-07 11:38:54 发布