From d27577a2c42f47265c2354077dcff1aee3320085 Mon Sep 17 00:00:00 2001 From: zyh Date: Mon, 3 Apr 2023 16:30:49 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E6=B8=85=E9=99=A4=E6=8B=93?= =?UTF-8?q?=E6=89=91=E7=BB=91=E5=AE=9A=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/chart/chart/chartBubble.vue | 5 ++++- .../src/components/chart/chart/chartFunnelNew.vue | 5 ++++- .../src/components/chart/chart/chartRank.vue | 5 ++++- .../src/components/chart/chart/chartSankey.vue | 6 ++++-- .../components/common/project/meta2d/meta2dMain.vue | 12 +++++++++++- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart/chartBubble.vue b/nezha-fronted/src/components/chart/chart/chartBubble.vue index ff26a5f41..586d9eabc 100644 --- a/nezha-fronted/src/components/chart/chart/chartBubble.vue +++ b/nezha-fronted/src/components/chart/chart/chartBubble.vue @@ -108,7 +108,7 @@ export default { }, drawBubbleChart () { this.$nextTick(() => { - d3.select(`#bubble-svg-${this.chartId}`).selectAll('g').remove()// 清空作图区域 + d3.select(`#bubble-svg-${this.chartId}`).selectAll('g').remove() // 清空作图区域 const svg = document.getElementById(`bubble-svg-${this.chartId}`) if (!svg) { return false @@ -282,6 +282,9 @@ export default { mounted () { this.colorList = initColor(20) this.chartInfo.loaded && this.initChart() + }, + beforeDestroy () { + d3.select(`#bubble-svg-${this.chartId}`).selectAll('g').remove() // 清空作图区域 } } diff --git a/nezha-fronted/src/components/chart/chart/chartFunnelNew.vue b/nezha-fronted/src/components/chart/chart/chartFunnelNew.vue index bb2aa152e..7b63e01ff 100644 --- a/nezha-fronted/src/components/chart/chart/chartFunnelNew.vue +++ b/nezha-fronted/src/components/chart/chart/chartFunnelNew.vue @@ -122,7 +122,7 @@ export default { funnelData = funnelData.filter(item => item.value !== 0) } this.$nextTick(() => { - d3.select(`#funnel-svg-${this.chartId}`).selectAll('g').remove()// 清空作图区域 + d3.select(`#funnel-svg-${this.chartId}`).selectAll('g').remove() // 清空作图区域 // 获取svg宽高 初始化画布 const svgDom = document.getElementById(`funnel-svg-${this.chartId}`) if (!svgDom) { @@ -372,6 +372,9 @@ export default { mounted () { this.colorList = initColor(20) this.chartInfo.loaded && this.initChart(true) + }, + beforeDestroy () { + d3.select(`#funnel-svg-${this.chartId}`).selectAll('g').remove() // 清空作图区域 } } diff --git a/nezha-fronted/src/components/chart/chart/chartRank.vue b/nezha-fronted/src/components/chart/chart/chartRank.vue index e8f9624a3..228d30d95 100644 --- a/nezha-fronted/src/components/chart/chart/chartRank.vue +++ b/nezha-fronted/src/components/chart/chart/chartRank.vue @@ -115,7 +115,7 @@ export default { drawRankChart () { this.$nextTick(() => { - d3.select(`#rank-svg-${this.chartId}`).selectAll('g').remove()// 清空作图区域 + d3.select(`#rank-svg-${this.chartId}`).selectAll('g').remove() // 清空作图区域 // 获取svg宽高 初始化画布 const svgDom = document.getElementById(`rank-svg-${this.chartId}`) if (!svgDom) { @@ -294,6 +294,9 @@ export default { mounted () { this.colorList = initColor(20) this.chartInfo.loaded && this.initChart() + }, + beforeDestroy () { + d3.select(`#rank-svg-${this.chartId}`).selectAll('g').remove() // 清空作图区域 } } diff --git a/nezha-fronted/src/components/chart/chart/chartSankey.vue b/nezha-fronted/src/components/chart/chart/chartSankey.vue index 857f440ee..7fbf42b3c 100644 --- a/nezha-fronted/src/components/chart/chart/chartSankey.vue +++ b/nezha-fronted/src/components/chart/chart/chartSankey.vue @@ -136,8 +136,7 @@ export default { drawSankeyChart () { this.$nextTick(() => { - // 清空作图区域 - d3.select(`#sankey-svg-${this.chartId}`).selectAll('g').remove() + d3.select(`#sankey-svg-${this.chartId}`).selectAll('g').remove() // 清空作图区域 // 获取svg宽高 初始化画布 const svgDom = document.getElementById(`sankey-svg-${this.chartId}`) @@ -395,6 +394,9 @@ export default { mounted () { this.colorList = initColor(20) this.chartInfo.loaded && this.initChart() + }, + beforeDestroy () { + d3.select(`#sankey-svg-${this.chartId}`).selectAll('g').remove() // 清空作图区域 } } diff --git a/nezha-fronted/src/components/common/project/meta2d/meta2dMain.vue b/nezha-fronted/src/components/common/project/meta2d/meta2dMain.vue index 25f80e5ae..4de4bd40d 100644 --- a/nezha-fronted/src/components/common/project/meta2d/meta2dMain.vue +++ b/nezha-fronted/src/components/common/project/meta2d/meta2dMain.vue @@ -190,12 +190,22 @@ export default { }, beforeDestroy () { if (getTopology(this.meta2dId)) { - getTopology(this.meta2dId).clear() + getTopology(this.meta2dId).off('translate', this.topTranslate) // 平移· + getTopology(this.meta2dId).off('scale', this.topoScale) // 缩放· + getTopology(this.meta2dId).off('active', this.pensActive) // 选中· + getTopology(this.meta2dId).off('translatePens', () => {}) // 移动画笔结束· + getTopology(this.meta2dId).off('translatingPens', () => {}) // 移动画笔进行中· + getTopology(this.meta2dId).off('enter', this.penEnter) // 移入画笔· + getTopology(this.meta2dId).off('leave', this.penLeave) // 移出画笔· + getTopology(this.meta2dId).off('add', this.appPen) // 添加新画笔· + getTopology(this.meta2dId).off('click', this.topoClick) // click画笔· + getTopology(this.meta2dId).destroy() setTopology(this.meta2dId, null) } bus.$off('changeSelectPens', this.pensActive) this.$refs.meta2dBox.removeEventListener('mousemove', this.mousemove) this.$refs.meta2dBox.removeEventListener('mouseup', this.mouseup) + window.removeEventListener('click', this.contextmenuNone) } }