fix: 修改多次刷新图表 堆叠事件重复添加的问题
This commit is contained in:
@@ -829,6 +829,7 @@ export default {
|
|||||||
// chartSite用于区分是全屏显示还是局部显示
|
// chartSite用于区分是全屏显示还是局部显示
|
||||||
initChart (chartInfo, dataArg, ele, legend) {
|
initChart (chartInfo, dataArg, ele, legend) {
|
||||||
const self = this
|
const self = this
|
||||||
|
self.isStackArea = false
|
||||||
let minTime = null
|
let minTime = null
|
||||||
let maxTime = null
|
let maxTime = null
|
||||||
if (dataArg.length > 0 && dataArg[0].data &&
|
if (dataArg.length > 0 && dataArg[0].data &&
|
||||||
@@ -936,9 +937,7 @@ export default {
|
|||||||
str += '<br/>'
|
str += '<br/>'
|
||||||
}
|
}
|
||||||
showFlag = showFlag || item.data[1]
|
showFlag = showFlag || item.data[1]
|
||||||
if (isNaN(item.data[1] + '')) {
|
if (!isNaN(item.data[1] + '')) {
|
||||||
return
|
|
||||||
}
|
|
||||||
const val = formatScientificNotation(item.data[1], 2)
|
const val = formatScientificNotation(item.data[1], 2)
|
||||||
sum += isNaN(self.numberWithEConvent(val)) ? 0 : Number(self.numberWithEConvent(val))
|
sum += isNaN(self.numberWithEConvent(val)) ? 0 : Number(self.numberWithEConvent(val))
|
||||||
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
||||||
@@ -952,15 +951,16 @@ export default {
|
|||||||
}())
|
}())
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (chartInfo.type === 'stackArea' || self.isStackArea) {
|
if (chartInfo.type === 'stackArea' || self.isStackArea) {
|
||||||
sum = parseFloat(Number(sum).toFixed(2))
|
sum = parseFloat(Number(sum).toFixed(6))
|
||||||
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
||||||
str += '<div style="line-height: 18px; font-size: 12px;padding-left:20px;">'
|
str += '<div style="line-height: 18px; font-size: 12px;padding-left:20px;">'
|
||||||
str += self.$t('dashboard.panel.chartTotal')
|
str += self.$t('dashboard.panel.chartTotal')
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
str += '<div style="padding-left: 10px;">'
|
str += '<div style="padding-left: 10px;">'
|
||||||
str += chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(sum, null, 2)
|
str += chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(sum, null, 6)
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
}
|
}
|
||||||
@@ -1088,6 +1088,7 @@ export default {
|
|||||||
|
|
||||||
this.$refs.loadingPreview.endLoading()
|
this.$refs.loadingPreview.endLoading()
|
||||||
})
|
})
|
||||||
|
this.echartModalStore.off('magictypechanged')
|
||||||
this.echartModalStore.on('magictypechanged', function (params) {
|
this.echartModalStore.on('magictypechanged', function (params) {
|
||||||
self.isStackArea = !self.isStackArea
|
self.isStackArea = !self.isStackArea
|
||||||
if (self.isStackArea) {
|
if (self.isStackArea) {
|
||||||
|
|||||||
@@ -647,6 +647,7 @@ export default {
|
|||||||
this.legendMagicType = legend
|
this.legendMagicType = legend
|
||||||
this.chartInfo = chartInfo
|
this.chartInfo = chartInfo
|
||||||
const self = this
|
const self = this
|
||||||
|
self.isStackArea = false
|
||||||
this.chartType = '' // 图表类型
|
this.chartType = '' // 图表类型
|
||||||
if (chartInfo.type === 4) { // line,bar
|
if (chartInfo.type === 4) { // line,bar
|
||||||
this.chartType = 'line'
|
this.chartType = 'line'
|
||||||
@@ -837,9 +838,7 @@ export default {
|
|||||||
minusFlag = false
|
minusFlag = false
|
||||||
}
|
}
|
||||||
showFlag = showFlag || item.data[1]
|
showFlag = showFlag || item.data[1]
|
||||||
if (isNaN(item.data[1] + '')) {
|
if (!isNaN(item.data[1] + '')) {
|
||||||
return
|
|
||||||
}
|
|
||||||
const previousItem = params.find((series) => ('Previous ' + item.seriesName) === series.seriesName)
|
const previousItem = params.find((series) => ('Previous ' + item.seriesName) === series.seriesName)
|
||||||
let paramsDot = bus.countDecimals(item.data[1])
|
let paramsDot = bus.countDecimals(item.data[1])
|
||||||
if (paramsDot < self.chartDot) {
|
if (paramsDot < self.chartDot) {
|
||||||
@@ -874,12 +873,13 @@ export default {
|
|||||||
}
|
}
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (self.data.type === 'stackArea' || self.isStackArea) {
|
if (self.data.type === 'stackArea' || self.isStackArea) {
|
||||||
if (!self.stackTotalColor || self.stackTotalColor == '') {
|
if (!self.stackTotalColor || self.stackTotalColor == '') {
|
||||||
self.stackTotalColor = randomcolor()
|
self.stackTotalColor = randomcolor()
|
||||||
}
|
}
|
||||||
sum = parseFloat(Number(sum).toFixed(2))
|
sum = parseFloat(Number(sum).toFixed(6))
|
||||||
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
||||||
str += '<div style="line-height: 18px; font-size: 12px;padding-left:0px;">'
|
str += '<div style="line-height: 18px; font-size: 12px;padding-left:0px;">'
|
||||||
str += `<span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${self.stackTotalColor};}'></span>`
|
str += `<span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${self.stackTotalColor};}'></span>`
|
||||||
@@ -1101,6 +1101,7 @@ export default {
|
|||||||
}, 800)
|
}, 800)
|
||||||
|
|
||||||
window.addEventListener('resize', this.chartResize)
|
window.addEventListener('resize', this.chartResize)
|
||||||
|
getChart(this.chartIndex).off('magictypechanged')
|
||||||
getChart(this.chartIndex).on('magictypechanged', function (params) {
|
getChart(this.chartIndex).on('magictypechanged', function (params) {
|
||||||
self.isStackArea = !self.isStackArea
|
self.isStackArea = !self.isStackArea
|
||||||
if (self.isStackArea) {
|
if (self.isStackArea) {
|
||||||
@@ -1152,9 +1153,7 @@ export default {
|
|||||||
str += '</div>'
|
str += '</div>'
|
||||||
}
|
}
|
||||||
showFlag = showFlag || item.data[1]
|
showFlag = showFlag || item.data[1]
|
||||||
if (isNaN(item.data[1] + '')) {
|
if (!isNaN(item.data[1] + '')) {
|
||||||
return
|
|
||||||
}
|
|
||||||
const val = formatScientificNotation(item.data[1], 2)
|
const val = formatScientificNotation(item.data[1], 2)
|
||||||
sum += isNaN(self.numberWithEConvent(val)) ? 0 : Number(self.numberWithEConvent(val))
|
sum += isNaN(self.numberWithEConvent(val)) ? 0 : Number(self.numberWithEConvent(val))
|
||||||
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
||||||
@@ -1163,15 +1162,16 @@ export default {
|
|||||||
str += chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(val, null, -1, paramsDot)
|
str += chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(val, null, -1, paramsDot)
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (self.data.type === 'stackArea' || self.isStackArea) {
|
if (self.data.type === 'stackArea' || self.isStackArea) {
|
||||||
sum = parseFloat(Number(sum).toFixed(2))
|
sum = parseFloat(Number(sum).toFixed(6))
|
||||||
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
||||||
str += '<div style="line-height: 18px; font-size: 12px;padding-left:20px;">'
|
str += '<div style="line-height: 18px; font-size: 12px;padding-left:20px;">'
|
||||||
str += self.$t('dashboard.panel.chartTotal')
|
str += self.$t('dashboard.panel.chartTotal')
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
str += '<div style="padding-left: 10px;">'
|
str += '<div style="padding-left: 10px;">'
|
||||||
str += chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(sum, null, 2)
|
str += chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(sum, null, self.chartDot)
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
}
|
}
|
||||||
@@ -1276,7 +1276,7 @@ export default {
|
|||||||
self.echartModalStore.off('finished')
|
self.echartModalStore.off('finished')
|
||||||
})
|
})
|
||||||
}, 100)
|
}, 100)
|
||||||
|
this.echartModalStore.off('magictypechanged')
|
||||||
this.echartModalStore.on('magictypechanged', function (params) {
|
this.echartModalStore.on('magictypechanged', function (params) {
|
||||||
self.isStackArea = !self.isStackArea
|
self.isStackArea = !self.isStackArea
|
||||||
if (self.isStackArea) {
|
if (self.isStackArea) {
|
||||||
@@ -1337,9 +1337,7 @@ export default {
|
|||||||
minusFlag = false
|
minusFlag = false
|
||||||
}
|
}
|
||||||
showFlag = showFlag || item.data[1]
|
showFlag = showFlag || item.data[1]
|
||||||
if (isNaN(item.data[1] + '')) {
|
if (!isNaN(item.data[1] + '')) {
|
||||||
return
|
|
||||||
}
|
|
||||||
const previousItem = params.find((series) => ('Previous ' + item.seriesName) === series.seriesName)
|
const previousItem = params.find((series) => ('Previous ' + item.seriesName) === series.seriesName)
|
||||||
const val = formatScientificNotation(item.data[1], 2)
|
const val = formatScientificNotation(item.data[1], 2)
|
||||||
sum += isNaN(self.numberWithEConvent(val)) ? 0 : Number(self.numberWithEConvent(val))
|
sum += isNaN(self.numberWithEConvent(val)) ? 0 : Number(self.numberWithEConvent(val))
|
||||||
@@ -1382,9 +1380,10 @@ export default {
|
|||||||
str += '</div>'
|
str += '</div>'
|
||||||
}
|
}
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (self.data.type === 'stackArea' || self.isStackArea) {
|
if (self.data.type === 'stackArea' || self.isStackArea) {
|
||||||
sum = parseFloat(Number(sum).toFixed(2))
|
sum = parseFloat(Number(sum).toFixed(6))
|
||||||
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
||||||
str += '<div style="line-height: 18px; font-size: 12px;padding-left:20px;">'
|
str += '<div style="line-height: 18px; font-size: 12px;padding-left:20px;">'
|
||||||
str += self.$t('dashboard.panel.chartTotal')
|
str += self.$t('dashboard.panel.chartTotal')
|
||||||
|
|||||||
@@ -438,9 +438,7 @@ export default {
|
|||||||
minusFlag = false
|
minusFlag = false
|
||||||
}
|
}
|
||||||
showFlag = showFlag || item.data[1]
|
showFlag = showFlag || item.data[1]
|
||||||
if (isNaN(item.data[1] + '')) {
|
if (!isNaN(item.data[1] + '')) {
|
||||||
return
|
|
||||||
}
|
|
||||||
const val = Number(item.data[1])
|
const val = Number(item.data[1])
|
||||||
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
str += '<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">'
|
||||||
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${item.color};}'></span>${alias || item.seriesName}: </div>`
|
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${item.color};}'></span>${alias || item.seriesName}: </div>`
|
||||||
@@ -475,6 +473,7 @@ export default {
|
|||||||
str += '</div>'
|
str += '</div>'
|
||||||
|
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
str += '</div>'
|
str += '</div>'
|
||||||
if (!showFlag) {
|
if (!showFlag) {
|
||||||
|
|||||||
Reference in New Issue
Block a user