fix: 修改多次刷新图表 堆叠事件重复添加的问题

This commit is contained in:
zhangyu
2021-11-27 13:41:26 +08:00
parent aa6c4f16c2
commit 62ab3ef6bd
3 changed files with 139 additions and 140 deletions

View File

@@ -829,6 +829,7 @@ export default {
// chartSite用于区分是全屏显示还是局部显示
initChart (chartInfo, dataArg, ele, legend) {
const self = this
self.isStackArea = false
let minTime = null
let maxTime = null
if (dataArg.length > 0 && dataArg[0].data &&
@@ -936,9 +937,7 @@ export default {
str += '<br/>'
}
showFlag = showFlag || item.data[1]
if (isNaN(item.data[1] + '')) {
return
}
if (!isNaN(item.data[1] + '')) {
const val = formatScientificNotation(item.data[1], 2)
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;">'
@@ -952,15 +951,16 @@ export default {
}())
str += '</div>'
str += '</div>'
}
})
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="line-height: 18px; font-size: 12px;padding-left:20px;">'
str += self.$t('dashboard.panel.chartTotal')
str += '</div>'
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>'
}
@@ -1088,6 +1088,7 @@ export default {
this.$refs.loadingPreview.endLoading()
})
this.echartModalStore.off('magictypechanged')
this.echartModalStore.on('magictypechanged', function (params) {
self.isStackArea = !self.isStackArea
if (self.isStackArea) {

View File

@@ -647,6 +647,7 @@ export default {
this.legendMagicType = legend
this.chartInfo = chartInfo
const self = this
self.isStackArea = false
this.chartType = '' // 图表类型
if (chartInfo.type === 4) { // line,bar
this.chartType = 'line'
@@ -837,9 +838,7 @@ export default {
minusFlag = false
}
showFlag = showFlag || item.data[1]
if (isNaN(item.data[1] + '')) {
return
}
if (!isNaN(item.data[1] + '')) {
const previousItem = params.find((series) => ('Previous ' + item.seriesName) === series.seriesName)
let paramsDot = bus.countDecimals(item.data[1])
if (paramsDot < self.chartDot) {
@@ -874,12 +873,13 @@ export default {
}
str += '</div>'
str += '</div>'
}
})
if (self.data.type === 'stackArea' || self.isStackArea) {
if (!self.stackTotalColor || self.stackTotalColor == '') {
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="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>`
@@ -1101,6 +1101,7 @@ export default {
}, 800)
window.addEventListener('resize', this.chartResize)
getChart(this.chartIndex).off('magictypechanged')
getChart(this.chartIndex).on('magictypechanged', function (params) {
self.isStackArea = !self.isStackArea
if (self.isStackArea) {
@@ -1152,9 +1153,7 @@ export default {
str += '</div>'
}
showFlag = showFlag || item.data[1]
if (isNaN(item.data[1] + '')) {
return
}
if (!isNaN(item.data[1] + '')) {
const val = formatScientificNotation(item.data[1], 2)
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;">'
@@ -1163,15 +1162,16 @@ export default {
str += chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(val, null, -1, paramsDot)
str += '</div>'
str += '</div>'
}
})
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="line-height: 18px; font-size: 12px;padding-left:20px;">'
str += self.$t('dashboard.panel.chartTotal')
str += '</div>'
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>'
}
@@ -1276,7 +1276,7 @@ export default {
self.echartModalStore.off('finished')
})
}, 100)
this.echartModalStore.off('magictypechanged')
this.echartModalStore.on('magictypechanged', function (params) {
self.isStackArea = !self.isStackArea
if (self.isStackArea) {
@@ -1337,9 +1337,7 @@ export default {
minusFlag = false
}
showFlag = showFlag || item.data[1]
if (isNaN(item.data[1] + '')) {
return
}
if (!isNaN(item.data[1] + '')) {
const previousItem = params.find((series) => ('Previous ' + item.seriesName) === series.seriesName)
const val = formatScientificNotation(item.data[1], 2)
sum += isNaN(self.numberWithEConvent(val)) ? 0 : Number(self.numberWithEConvent(val))
@@ -1382,9 +1380,10 @@ export default {
str += '</div>'
}
str += '</div>'
}
})
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="line-height: 18px; font-size: 12px;padding-left:20px;">'
str += self.$t('dashboard.panel.chartTotal')

View File

@@ -438,9 +438,7 @@ export default {
minusFlag = false
}
showFlag = showFlag || item.data[1]
if (isNaN(item.data[1] + '')) {
return
}
if (!isNaN(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="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>'
if (!showFlag) {