更新代码
This commit is contained in:
@@ -102,6 +102,7 @@ export default {
|
||||
mounted() {
|
||||
publisherInstance.subscribe('refresh', this.staticAmountLine);
|
||||
this.$nextTick(() => {
|
||||
this.chart = echarts.init(this.$refs.chart, 'macarons')
|
||||
this.staticAmountLine();
|
||||
})
|
||||
},
|
||||
@@ -112,20 +113,25 @@ export default {
|
||||
if (code === 200) {
|
||||
const { x } = data;
|
||||
echartsConfig.xAxis.data = x;
|
||||
const series = [];
|
||||
for (const key in legendMap) {
|
||||
const name = legendMap[key];
|
||||
echartsConfig.series.push({
|
||||
series.push({
|
||||
name,
|
||||
yAxisIndex: key === 'orderCountData' ? 1 : 0,
|
||||
data: data[key],
|
||||
type: "line",
|
||||
})
|
||||
}
|
||||
const options = this.chart.getOption();
|
||||
if (options && options.legend) {
|
||||
echartsConfig.legend = { selected: options.legend[0].selected }
|
||||
}
|
||||
echartsConfig.series = series;
|
||||
this.initChart(echartsConfig)
|
||||
}
|
||||
},
|
||||
initChart(chartData) {
|
||||
this.chart = echarts.init(this.$refs.chart, 'macarons')
|
||||
this.chart.setOption(chartData);
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user