fix: 修复app echarts 方法传值错误问题

This commit is contained in:
@changcode
2022-07-26 10:24:38 +08:00
parent ec2bc25512
commit 62f8625b65

View File

@@ -160,7 +160,8 @@ export default {
searcherApp: '', searcherApp: '',
appShowTypeTab: 0, appShowTypeTab: 0,
initialAppOptionsData: [], initialAppOptionsData: [],
initialProviderOptionsData: [] initialProviderOptionsData: [],
myChartArray: []
} }
}, },
methods: { methods: {
@@ -575,37 +576,38 @@ export default {
'0' '0'
] ]
].map(v => [Number(v[0]) * 1000, Number(v[1]), 'time']) ].map(v => [Number(v[0]) * 1000, Number(v[1]), 'time'])
this.initChart(app) this.initChart(this.appData[i])
}) })
}, },
initChart (obj) { initChart (obj) {
const dom = document.getElementById(`chart${obj.name}`) const dom = document.getElementById(`chart${obj.name}`)
this.myChart.push(echarts.init(dom)) this.myChart = echarts.init(dom)
this.chartOption = appListChartOption this.chartOption = appListChartOption
const seriesTemplate = this.chartOption.series[0] const seriesTemplate = this.chartOption.series[0]
this.chartOption.series = [{ if (obj && obj.lineData) {
...seriesTemplate, this.chartOption.series[0] = {
data: obj.lineData, ...seriesTemplate,
lineStyle: { data: obj.lineData,
color: obj.trend === 'up' ? '#7FA054' : '#35ADDA' lineStyle: {
}, color: obj.trend === 'up' ? '#7FA054' : '#35ADDA'
areaStyle: { },
opacity: 0.1, areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ opacity: 0.1,
{ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
offset: 0, {
color: obj.trend === 'up' ? '#7FA054' : '#35ADDA' offset: 0,
}, color: obj.trend === 'up' ? '#7FA054' : '#35ADDA'
{ },
offset: 1, {
color: obj.trend === 'up' ? '#7FA054' : '#35ADDA' offset: 1,
} color: obj.trend === 'up' ? '#7FA054' : '#35ADDA'
]) }
])
}
} }
}] this.myChartArray.push(this.myChart)
this.myChart.forEach(t => { this.myChart.setOption(this.chartOption)
t.setOption(this.chartOption) }
})
}, },
addApp () { addApp () {
this.showAddApp = true this.showAddApp = true
@@ -669,7 +671,7 @@ export default {
} }
}, },
resize () { resize () {
this.myChart.forEach(t => { this.myChartArray.forEach(t => {
t.resize() t.resize()
}) })
} }