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