@@ -102,16 +122,6 @@ export default {
chartId: '',
roseData: [],
selectData: [],
- tooltip: {
- x: 0,
- y: 0,
- title: 0,
- value: 0,
- percent: 0,
- mapping: {},
- show: false,
- dataLinkShow: false
- },
svg: null,
drawing: false
}
@@ -263,7 +273,6 @@ export default {
.on('mousemove', this.roseMove)
.on('mouseleave', this.roseLeave)
.on('click', this.chartClick)
- .on('mousedown', this.chartMousedown)
.transition().duration(animate === true ? 600 : 0)
.attrTween('d', function (d) {
const i = d3.interpolate({ startAngle: 0, endAngle: 0 }, d)
@@ -289,7 +298,6 @@ export default {
.on('mousemove', this.roseMove)
.on('mouseleave', this.roseLeave)
.on('click', this.chartClick)
- .on('mousedown', this.chartMousedown)
.style('opacity', 0)
.html((d) => {
return d.endAngle - d.startAngle > 0.25 ? this.formatterLabel(d) : ''
@@ -350,7 +358,6 @@ export default {
}
},
roseEnter (e, node) { // 移入气泡
- if (this.tooltip.dataLinkShow) { return }
this.tooltip.title = node.data.alias
this.tooltip.value = node.data.mapping && node.data.mapping.display ? this.handleDisplay(node.data.mapping.display, { ...node.data.labels, value: node.data.showValue }) : node.data.showValue
this.tooltip.percent = node.percent
@@ -359,12 +366,10 @@ export default {
this.setPosition(e)
},
roseMove (e) { // 气泡内移动
- if (this.tooltip.dataLinkShow) { return }
this.tooltip.show = true
this.setPosition(e)
},
roseLeave () { // 移出气泡
- if (this.tooltip.dataLinkShow) { return }
this.tooltip.show = false
},
setPosition (e) {
@@ -424,62 +429,56 @@ export default {
this.svg.selectAll('path').on('mousemove', null)
this.svg.selectAll('path').on('mouseleave', null)
this.svg.selectAll('path').on('click', null)
- this.svg.selectAll('path').on('mousedown', null)
this.svg.selectAll('foreignObject').on('mouseover', null)
this.svg.selectAll('foreignObject').on('mouseout', null)
this.svg.selectAll('foreignObject').on('mouseenter', null)
this.svg.selectAll('foreignObject').on('mousemove', null)
this.svg.selectAll('foreignObject').on('mouseleave', null)
this.svg.selectAll('foreignObject').on('click', null)
- this.svg.selectAll('foreignObject').on('mousedown', null)
this.svg.remove()
this.svg = null
}
},
- datalinkPosition (e) {
+ toolboxPosition (e) {
const windowWidth = window.innerWidth// 窗口宽度
const windowHeight = window.innerHeight// 窗口高度
this.$nextTick(() => {
- const box = document.getElementById(`chart-canvas-tooltip-${this.chartId}`)
+ const box = document.getElementById(`chart-toolbox-${this.chartId}`)
const left = e.pageX - this.$refs['rose-chart-box'].getBoundingClientRect().left
const top = e.pageY - this.$refs['rose-chart-box'].getBoundingClientRect().top
if (box) {
const boxWidth = box.offsetWidth
const boxHeight = box.offsetHeight
if (e.pageX < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框
- this.tooltip.x = left + 15
+ this.toolbox.x = left + 15
} else {
- this.tooltip.x = left - boxWidth - 15
+ this.toolbox.x = left - boxWidth - 15
}
if (e.pageY + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框
- this.tooltip.y = top + 15
+ this.toolbox.y = top + 15
} else {
- this.tooltip.y = top - boxHeight - 10
+ this.toolbox.y = top - boxHeight - 10
}
}
})
},
chartClick (e, data) {
if (this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') {
- this.tooltip.title = data.data.alias
- this.tooltip.value = data.data.mapping && data.data.mapping.display ? this.handleDisplay(data.data.mapping.display, { ...data.data.labels, value: data.data.showValue }) : data.data.showValue
- this.tooltip.mapping = data.data.mapping
- this.tooltip.show = true
- this.tooltip.dataLinkShow = true
- this.tooltip.metric.labels = data.data.labels
- this.tooltip.metric.expressionIndex = data.data.expressionIndex
- this.datalinkPosition(e)
- }
- },
- chartMousedown (e) {
- if ((this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') && this.tooltip.dataLinkShow) {
- e.stopPropagation()
+ this.tooltip.show = false
+
+ this.toolbox.title = data.data.alias
+ this.toolbox.value = data.data.mapping && data.data.mapping.display ? this.handleDisplay(data.data.mapping.display, { ...data.data.labels, value: data.data.showValue }) : data.data.showValue
+ this.toolbox.percent = data.percent
+ this.toolbox.mapping = data.data.mapping
+ this.toolbox.show = true
+ this.toolbox.metric.labels = data.data.labels
+ this.toolbox.metric.expressionIndex = data.data.expressionIndex
+ this.toolboxPosition(e)
}
},
clickout () {
- if ((this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') && this.tooltip.dataLinkShow) {
- this.tooltip.show = false
- this.tooltip.dataLinkShow = false
+ if ((this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') && this.toolbox.show) {
+ this.toolbox.show = false
}
}
},
diff --git a/nezha-fronted/src/components/chart/chart/chartSankey.vue b/nezha-fronted/src/components/chart/chart/chartSankey.vue
index 9f8645af8..d46d77527 100644
--- a/nezha-fronted/src/components/chart/chart/chartSankey.vue
+++ b/nezha-fronted/src/components/chart/chart/chartSankey.vue
@@ -7,8 +7,8 @@
-
-
+