fix:清除拓扑绑定事件

This commit is contained in:
zyh
2023-04-03 16:30:49 +08:00
parent dced2c0bd4
commit d27577a2c4
5 changed files with 27 additions and 6 deletions

View File

@@ -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() // 清空作图区域
}
}
</script>

View File

@@ -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() // 清空作图区域
}
}
</script>

View File

@@ -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() // 清空作图区域
}
}
</script>

View File

@@ -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() // 清空作图区域
}
}
</script>

View File

@@ -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)
}
}