${str}
@@ -218,7 +229,7 @@ export default {
`
} else if (str) {
return `
-
+
${str}
@@ -227,7 +238,7 @@ export default {
`
} else if (valueStr) {
return `
-
+
${valueStr}
@@ -237,41 +248,45 @@ export default {
}
},
bubbleEnter (e, node) { // 移入气泡
+ if (this.tooltip.dataLinkShow) { return }
this.tooltip.title = node.data.alias
- this.tooltip.value = node.data.showValue
+ 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.mapping = node.data.mapping
this.tooltip.show = true
this.setPosition(e)
},
bubbleMove (e) { // 气泡内移动
- if (this.tooltip.show) {
- this.setPosition(e)
- }
+ if (this.tooltip.dataLinkShow) { return }
+ this.tooltip.show = true
+ this.setPosition(e)
},
bubbleLeave () { // 移出气泡
+ if (this.tooltip.dataLinkShow) { return }
this.tooltip.show = false
},
setPosition (e) {
const windowWidth = window.innerWidth// 窗口宽度
const windowHeight = window.innerHeight// 窗口高度
- const box = document.getElementById(`chart-canvas-tooltip-${this.chartId}`)
- if (box) {
- const boxWidth = box.offsetWidth
- const boxHeight = box.offsetHeight
- if (e.pageX < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框
- this.tooltip.x = e.pageX + 15
+ this.$nextTick(() => {
+ const box = document.getElementById(`chart-canvas-tooltip-${this.chartId}`)
+ if (box) {
+ const boxWidth = box.offsetWidth
+ const boxHeight = box.offsetHeight
+ if (e.pageX < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框
+ this.tooltip.x = e.pageX + 15
+ } else {
+ this.tooltip.x = e.pageX - boxWidth - 15
+ }
+ if (e.pageY + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框
+ this.tooltip.y = e.pageY + 15
+ } else {
+ this.tooltip.y = e.pageY - boxHeight - 10
+ }
} else {
- this.tooltip.x = e.pageX - boxWidth - 15
- }
- if (e.pageY + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框
this.tooltip.y = e.pageY + 15
- } else {
- this.tooltip.y = e.pageY - boxHeight - 10
+ this.tooltip.x = e.pageX + 15
}
- } else {
- this.tooltip.y = e.pageY + 15
- this.tooltip.x = e.pageX + 15
- }
+ })
},
resize () {
setTimeout(() => {
@@ -283,9 +298,26 @@ export default {
this.svg.selectAll('.bubble').on('mouseenter', null)
this.svg.selectAll('.bubble').on('mousemove', null)
this.svg.selectAll('.bubble').on('mouseleave', null)
+ this.svg.selectAll('.bubble').on('click', null)
this.svg.selectAll('g').remove()
this.svg = null
}
+ },
+ chartClick (e, data) {
+ if (this.dataLink.length) {
+ 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.setPosition(e)
+ }
+ },
+ clickout () {
+ if (this.dataLink.length) {
+ this.tooltip.show = false
+ this.tooltip.dataLinkShow = false
+ }
}
},
mounted () {
diff --git a/nezha-fronted/src/components/chart/chart/chartClock.vue b/nezha-fronted/src/components/chart/chart/chartClock.vue
index c2c80c7ab..a539cfe5b 100644
--- a/nezha-fronted/src/components/chart/chart/chartClock.vue
+++ b/nezha-fronted/src/components/chart/chart/chartClock.vue
@@ -40,7 +40,7 @@ export default {
computed: {
hasLegend () {
try {
- return [chartLegendPlacement.bottom, chartLegendPlacement.left, chartLegendPlacement.right].indexOf(this.chartInfo.param.legend.placement) > -1
+ return [chartLegendPlacement.bottom, chartLegendPlacement.left, chartLegendPlacement.right].indexOf(this.chartInfo.param.legend.placement) > -1 && this.chartInfo.param.enable.legend
} catch (e) {
return false
}
diff --git a/nezha-fronted/src/components/chart/chart/chartDoughnut.vue b/nezha-fronted/src/components/chart/chart/chartDoughnut.vue
index fa154c030..c6d0beca3 100644
--- a/nezha-fronted/src/components/chart/chart/chartDoughnut.vue
+++ b/nezha-fronted/src/components/chart/chart/chartDoughnut.vue
@@ -4,7 +4,8 @@
ref="doughnut-chart-box"
class="nz-chart__component"
>
-
+
+
-
@@ -59,7 +68,7 @@ export default {
computed: {
hasLegend () {
try {
- return [chartLegendPlacement.bottom, chartLegendPlacement.left, chartLegendPlacement.right].indexOf(this.chartInfo.param.legend.placement) > -1
+ return [chartLegendPlacement.bottom, chartLegendPlacement.left, chartLegendPlacement.right].indexOf(this.chartInfo.param.legend.placement) > -1 && this.chartInfo.param.enable.legend
} catch (e) {
return false
}
@@ -91,15 +100,16 @@ export default {
y: 0,
title: 0,
value: 0,
- percent: 0,
mapping: {},
- show: false
+ show: false,
+ dataLinkShow: ''
},
svg: null
}
},
methods: {
initChart (animate) {
+ this.setDataLink()
this.legends = []
this.initDoughnutData(this.chartInfo, this.chartData)
this.selectData = this.$loadsh.cloneDeep(this.doughnutData)
@@ -223,6 +233,7 @@ export default {
.on('mouseenter', this.doughnutEnter)
.on('mousemove', this.doughnutMove)
.on('mouseleave', this.doughnutLeave)
+ .on('click', this.chartClick)
.transition().duration(animate === true ? 600 : 0)
.attrTween('d', function (d) {
const i = d3.interpolate({ startAngle: 0, endAngle: 0 }, d)
@@ -247,6 +258,7 @@ export default {
.on('mouseenter', this.doughnutEnter)
.on('mousemove', this.doughnutMove)
.on('mouseleave', this.doughnutLeave)
+ .on('click', this.chartClick)
.style('opacity', 0)
.html((d) => {
return d.endAngle - d.startAngle > 0.25 ? this.formatterLabel(d) : ''
@@ -305,44 +317,47 @@ export default {
`
}
},
- doughnutEnter (e, node) { // 移入气泡
+ doughnutEnter (e, node) {
+ if (this.tooltip.dataLinkShow) { return }
this.tooltip.title = node.data.alias
- this.tooltip.value = node.data.showValue
+ 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
this.tooltip.mapping = node.data.mapping
this.tooltip.show = true
this.setPosition(e)
},
- doughnutMove (e) { // 气泡内移动
- if (this.tooltip.show) {
- this.tooltip.show = true
- this.setPosition(e)
- }
+ doughnutMove (e) {
+ if (this.tooltip.dataLinkShow) { return }
+ this.tooltip.show = true
+ this.setPosition(e)
},
- doughnutLeave () { // 移出气泡
+ doughnutLeave () {
+ if (this.tooltip.dataLinkShow) { return }
this.tooltip.show = false
},
setPosition (e) {
const windowWidth = window.innerWidth// 窗口宽度
const windowHeight = window.innerHeight// 窗口高度
- const box = document.getElementById(`chart-canvas-tooltip-${this.chartId}`)
- if (box) {
- const boxWidth = box.offsetWidth
- const boxHeight = box.offsetHeight
- if (e.pageX < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框
- this.tooltip.x = e.pageX + 15
+ this.$nextTick(() => {
+ const box = document.getElementById(`chart-canvas-tooltip-${this.chartId}`)
+ if (box) {
+ const boxWidth = box.offsetWidth
+ const boxHeight = box.offsetHeight
+ if (e.pageX < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框
+ this.tooltip.x = e.pageX + 15
+ } else {
+ this.tooltip.x = e.pageX - boxWidth - 15
+ }
+ if (e.pageY + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框
+ this.tooltip.y = e.pageY + 15
+ } else {
+ this.tooltip.y = e.pageY - boxHeight - 10
+ }
} else {
- this.tooltip.x = e.pageX - boxWidth - 15
- }
- if (e.pageY + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框
this.tooltip.y = e.pageY + 15
- } else {
- this.tooltip.y = e.pageY - boxHeight - 10
+ this.tooltip.x = e.pageX + 15
}
- } else {
- this.tooltip.y = e.pageY + 15
- this.tooltip.x = e.pageX + 15
- }
+ })
},
clickLegendD3 (isGrey) {
const data = this.doughnutData.filter((item, i) => !isGrey[i])
@@ -361,14 +376,32 @@ export default {
this.svg.selectAll('path').on('mouseenter', null)
this.svg.selectAll('path').on('mousemove', null)
this.svg.selectAll('path').on('mouseleave', null)
+ this.svg.selectAll('path').on('click', 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.remove()
this.svg = null
}
+ },
+ chartClick (e, data) {
+ if (this.dataLink.length) {
+ 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.setPosition(e)
+ }
+ },
+ clickout () {
+ if (this.dataLink.length) {
+ this.tooltip.show = false
+ this.tooltip.dataLinkShow = false
+ }
}
},
mounted () {
diff --git a/nezha-fronted/src/components/chart/chart/chartFunnel.vue b/nezha-fronted/src/components/chart/chart/chartFunnel.vue
index e69c39144..f68b05a08 100644
--- a/nezha-fronted/src/components/chart/chart/chartFunnel.vue
+++ b/nezha-fronted/src/components/chart/chart/chartFunnel.vue
@@ -3,8 +3,11 @@
ref="funnel-chart-box"
class="nz-chart__component"
>
-
-
+
+
diff --git a/nezha-fronted/src/components/chart/chart/chartFunnelNew.vue b/nezha-fronted/src/components/chart/chart/chartFunnelNew.vue
deleted file mode 100644
index 591fabd0a..000000000
--- a/nezha-fronted/src/components/chart/chart/chartFunnelNew.vue
+++ /dev/null
@@ -1,389 +0,0 @@
-
-
-
-
-
diff --git a/nezha-fronted/src/components/chart/chart/chartGauge.vue b/nezha-fronted/src/components/chart/chart/chartGauge.vue
index b83b0b84a..11a0ec79b 100644
--- a/nezha-fronted/src/components/chart/chart/chartGauge.vue
+++ b/nezha-fronted/src/components/chart/chart/chartGauge.vue
@@ -8,6 +8,7 @@
+
@@ -39,11 +59,21 @@ export default {
boxHeight: 0,
boxPadding: 5,
chartInstances: [],
- timer: null
+ timer: null,
+ tooltip: {
+ x: 0,
+ y: 0,
+ title: 0,
+ value: 0,
+ mapping: {},
+ show: false,
+ dataLinkShow: ''
+ }
}
},
methods: {
initChart () {
+ this.setDataLink()
if (this.timer) {
clearTimeout(this.timer)
this.timer = null
@@ -157,6 +187,8 @@ export default {
gaugeChartInit () {
this.chartInstances.forEach(item => {
if (item) {
+ item.off('click')
+ item.off('mousedown')
item.dispose()
}
})
@@ -200,6 +232,7 @@ export default {
}
}
option.tooltip.formatter = this.formatterFunc
+ option.tooltip.position = this.tooltipPosition
if (navigator.userAgent.match(/Mobi/i) ||
navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/iPhone/i)) {
@@ -210,6 +243,15 @@ export default {
// option.tooltip.position = this.formatterFunc
option.series[0].min = item.max == item.min ? 0 : item.min
myChart.setOption(option)
+ if (this.dataLink.length) {
+ myChart.on('click', this.chartClick)
+ myChart.on('mousedown', (params) => {
+ if (this.tooltip.show) {
+ const e = params.event.event
+ e.stopPropagation()
+ }
+ })
+ }
this.chartInstances.push(myChart)
})
},
@@ -231,22 +273,74 @@ export default {
},
formatterFunc: function (params, ticket, callback) {
const self = this
- return `
-
-
${params.data.alias}
-
-
value
-
-
-
-
-
${params.data.showValue}
-
${self.handleDisplay(params.data.mapping.display, { ...params.data.labels, value: params.data.showValue })}
-
-
-
+ return `
+
${params.data.alias}
+
+
value
+
+
+
+
+
${params.data.showValue}
+
${self.handleDisplay(params.data.mapping.display, { ...params.data.labels, value: params.data.showValue })}
+
`
+ },
+ setPosition (e) {
+ const windowWidth = window.innerWidth// 窗口宽度
+ const windowHeight = window.innerHeight// 窗口高度
+ this.$nextTick(() => {
+ const box = document.getElementById(`chart-canvas-tooltip-${this.chartId}`)
+ if (box) {
+ const boxWidth = box.offsetWidth
+ const boxHeight = box.offsetHeight
+ if (e.pageX < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框
+ this.tooltip.x = e.pageX + 15
+ } else {
+ this.tooltip.x = e.pageX - boxWidth - 15
+ }
+ if (e.pageY + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框
+ this.tooltip.y = e.pageY + 15
+ } else {
+ this.tooltip.y = e.pageY - boxHeight - 10
+ }
+ } else {
+ this.tooltip.y = e.pageY + 15
+ this.tooltip.x = e.pageX + 15
+ }
+ })
+ },
+ chartClick (params) {
+ const option = {
+ tooltip: {
+ extraCssText: 'z-index:99999999;visibility:hidden;transition:none;'
+ }
+ }
+ this.chartInstances.forEach(item => {
+ item.setOption(option)
+ })
+ this.tooltip.title = params.data.alias
+ this.tooltip.value = params.data.mapping && params.data.mapping.display ? this.handleDisplay(params.data.mapping.display, { ...params.data.labels, value: params.data.showValue }) : params.data.showValue
+ this.tooltip.mapping = params.data.mapping
+ this.tooltip.show = true
+ this.tooltip.dataLinkShow = true
+ const e = params.event.event
+ this.setPosition(e)
+ },
+ clickout () {
+ if (this.dataLink.length) {
+ this.tooltip.show = false
+ this.tooltip.dataLinkShow = false
+ const option = {
+ tooltip: {
+ extraCssText: 'z-index:99999999;visibility:visible;'
+ }
+ }
+ this.chartInstances.forEach(item => {
+ item.setOption(option)
+ })
+ }
}
},
mounted () {
@@ -257,6 +351,8 @@ export default {
beforeDestroy () {
this.chartInstances.forEach(item => {
if (item && item.dispose) {
+ item.off('click')
+ item.off('mousedown')
item.dispose()
}
})
diff --git a/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue b/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue
index 9bf075285..a24b4c0eb 100644
--- a/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue
+++ b/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue
@@ -1,7 +1,7 @@
@@ -43,7 +50,8 @@ export default {
title: 0,
value: 0,
mapping: {},
- show: false
+ show: false,
+ dataLinkShow: ''
},
svg: null,
spaceBetweenHexa: 3,
@@ -53,6 +61,7 @@ export default {
methods: {
hexbin,
initChart () {
+ this.setDataLink()
if (this.timer) {
clearTimeout(this.timer)
this.timer = null
@@ -181,47 +190,52 @@ export default {
hexa.attr('fill', color) // Paints hexagon
g.on('mouseenter', self.hexagonOver.bind(self, point))
g.on('mouseleave', self.hexagonOut.bind(self, point))
+ g.on('click', self.chartClick.bind(self, point))
self.drawText(this.svg, vals, point, color, hexaRadius, g) // 文本
data[i].fcolor = color
}
return this.svg.node()
},
hexagonOver (that, e) { // 移入六边形
+ if (this.tooltip.dataLinkShow) { return }
this.tooltip.title = that.alias
- this.tooltip.value = that.showValue
+ this.tooltip.value = that.mapping && that.mapping.display ? this.handleDisplay(that.mapping.display, { ...that.metrics, legend: that.alias, value: that.showValue }) : that.showValue
this.tooltip.mapping = that.mapping
this.tooltip.show = true
this.setPosition(e)
},
hexagonMove (e) { // 六边形内移动
- if (this.tooltip.show) {
- this.setPosition(e)
- }
+ if (this.tooltip.dataLinkShow) { return }
+ this.tooltip.show = true
+ this.setPosition(e)
},
- hexagonOut (that) {
+ hexagonOut () {
+ if (this.tooltip.dataLinkShow) { return }
this.tooltip.show = false
},
setPosition (e) {
const windowWidth = window.innerWidth// 窗口宽度
const windowHeight = window.innerHeight// 窗口高度
- const box = document.getElementById(`chart-canvas-tooltip-${this.chartId}`)
- if (box) {
- const boxWidth = box.offsetWidth
- const boxHeight = box.offsetHeight
- if (e.pageX < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框
- this.tooltip.x = e.pageX + 15
+ this.$nextTick(() => {
+ const box = document.getElementById(`chart-canvas-tooltip-${this.chartId}`)
+ if (box) {
+ const boxWidth = box.offsetWidth
+ const boxHeight = box.offsetHeight
+ if (e.pageX < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框
+ this.tooltip.x = e.pageX + 15
+ } else {
+ this.tooltip.x = e.pageX - boxWidth - 15
+ }
+ if (e.pageY + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框
+ this.tooltip.y = e.pageY + 15
+ } else {
+ this.tooltip.y = e.pageY - boxHeight - 10
+ }
} else {
- this.tooltip.x = e.pageX - boxWidth - 15
- }
- if (e.pageY + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框
this.tooltip.y = e.pageY + 15
- } else {
- this.tooltip.y = e.pageY - boxHeight - 10
+ this.tooltip.x = e.pageX + 15
}
- } else {
- this.tooltip.y = e.pageY + 15
- this.tooltip.x = e.pageX + 15
- }
+ })
},
formatStr (d) {
const self = this
@@ -238,6 +252,7 @@ export default {
.attr('stroke-linejoin', 'round')
.attr('stroke-width', 1)
.attr('transform', 'translate(' + x + ',' + y + ')')
+ .style('cursor', this.dataLink.length ? 'pointer' : 'default')
return hexagon
},
drawText (svg, vals, point, color, hexbinRadius, group) {
@@ -273,6 +288,7 @@ export default {
.attr('alignment-baseline', 'central')
.style('font-size', fontSize)
.style('fill', textColor)
+ .style('pointer-events', 'none')
const scrollDiv = fObj.append('xhtml:div')
scrollDiv
.html(`
${str}
`)
@@ -295,6 +311,7 @@ export default {
.attr('alignment-baseline', 'central')
.style('font-size', fontSize)
.style('fill', textColor)
+ .style('pointer-events', 'none')
const scrollDiv2 = fObj2.append('xhtml:div')
scrollDiv2
.html(
@@ -315,6 +332,7 @@ export default {
.attr('alignment-baseline', 'central')
.style('font-size', fontSize)
.style('fill', textColor)
+ .style('pointer-events', 'none')
const scrollDiv = fObj.append('xhtml:div')
scrollDiv
.html(
@@ -342,6 +360,7 @@ export default {
.attr('alignment-baseline', 'central')
.style('font-size', fontSize)
.style('fill', textColor)
+ .style('pointer-events', 'none')
const scrollDiv = fObj.append('xhtml:div')
scrollDiv
.html(
@@ -415,6 +434,7 @@ export default {
this.svg.on('mousemove', null)
this.svg.selectAll('g').on('mouseenter', null)
this.svg.selectAll('g').on('mouseleave', null)
+ this.svg.selectAll('g').on('click', null)
this.svg.remove()
this.svg = null
}
@@ -431,6 +451,22 @@ export default {
})
}, 50)
+ },
+ chartClick (data, e) {
+ if (this.dataLink.length) {
+ this.tooltip.title = data.alias
+ this.tooltip.value = data.mapping && data.mapping.display ? this.handleDisplay(data.mapping.display, { ...data.metrics, legend: data.alias, value: data.showValue }) : data.showValue
+ this.tooltip.mapping = data.mapping
+ this.tooltip.show = true
+ this.tooltip.dataLinkShow = true
+ this.setPosition(e)
+ }
+ },
+ clickout () {
+ if (this.dataLink.length) {
+ this.tooltip.show = false
+ this.tooltip.dataLinkShow = false
+ }
}
},
mounted () {
diff --git a/nezha-fronted/src/components/chart/chart/chartPie.vue b/nezha-fronted/src/components/chart/chart/chartPie.vue
index b937d6876..634490fd5 100644
--- a/nezha-fronted/src/components/chart/chart/chartPie.vue
+++ b/nezha-fronted/src/components/chart/chart/chartPie.vue
@@ -43,7 +43,7 @@ export default {
computed: {
hasLegend () {
try {
- return [chartLegendPlacement.bottom, chartLegendPlacement.left, chartLegendPlacement.right].indexOf(this.chartInfo.param.legend.placement) > -1
+ return [chartLegendPlacement.bottom, chartLegendPlacement.left, chartLegendPlacement.right].indexOf(this.chartInfo.param.legend.placement) > -1 && this.chartInfo.param.enable.legend
} catch (e) {
return false
}
diff --git a/nezha-fronted/src/components/chart/chart/chartRank.vue b/nezha-fronted/src/components/chart/chart/chartRank.vue
index dd8c832c5..3ae7b2553 100644
--- a/nezha-fronted/src/components/chart/chart/chartRank.vue
+++ b/nezha-fronted/src/components/chart/chart/chartRank.vue
@@ -3,10 +3,11 @@
ref="rank-chart-box"
class="nz-chart__component"
>
-
@@ -63,13 +70,15 @@ export default {
value: 0,
mapping: {},
rank: 0,
- show: false
+ show: false,
+ dataLinkShow: ''
},
svg: null
}
},
methods: {
initChart () {
+ this.setDataLink()
this.legends = []
this.initRankData(this.chartInfo, this.chartData)
this.isNoData = !this.rankData.length
@@ -171,6 +180,7 @@ export default {
.on('mouseenter', this.rankEnter)
.on('mousemove', this.rankMove)
.on('mouseleave', this.rankLeave)
+ .on('click', this.chartClick)
bars.exit().remove()
// 文本标签
@@ -183,6 +193,7 @@ export default {
.on('mouseenter', this.rankEnter)
.on('mousemove', this.rankMove)
.on('mouseleave', this.rankLeave)
+ .on('click', this.chartClick)
.html((d) => {
return this.rankFormatterLabel(d)
})
@@ -243,44 +254,47 @@ export default {
`
}
},
-
rankEnter (e, data) { // 移入
+ if (this.tooltip.dataLinkShow) { return }
this.tooltip.title = data.alias
- this.tooltip.value = data.showValue
+ this.tooltip.value = data.mapping && data.mapping.display ? this.handleDisplay(data.mapping.display, { ...data.labels, value: data.showValue }) : data.showValue
this.tooltip.mapping = data.mapping
this.tooltip.rank = data.rank
this.tooltip.show = true
this.setPosition(e)
},
rankMove (e) { // 移动
- if (this.tooltip.show) {
- this.setPosition(e)
- }
+ if (this.tooltip.dataLinkShow) { return }
+ this.tooltip.show = true
+ this.setPosition(e)
},
rankLeave () { // 移出
+ if (this.tooltip.dataLinkShow) { return }
this.tooltip.show = false
},
setPosition (e) {
const windowWidth = window.innerWidth// 窗口宽度
const windowHeight = window.innerHeight// 窗口高度
- const box = document.getElementById(`chart-canvas-tooltip-${this.chartId}`)
- if (box) {
- const boxWidth = box.offsetWidth
- const boxHeight = box.offsetHeight
- if (e.pageX < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框
- this.tooltip.x = e.pageX + 15
+ this.$nextTick(() => {
+ const box = document.getElementById(`chart-canvas-tooltip-${this.chartId}`)
+ if (box) {
+ const boxWidth = box.offsetWidth
+ const boxHeight = box.offsetHeight
+ if (e.pageX < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框
+ this.tooltip.x = e.pageX + 15
+ } else {
+ this.tooltip.x = e.pageX - boxWidth - 15
+ }
+ if (e.pageY + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框
+ this.tooltip.y = e.pageY + 15
+ } else {
+ this.tooltip.y = e.pageY - boxHeight - 10
+ }
} else {
- this.tooltip.x = e.pageX - boxWidth - 15
- }
- if (e.pageY + 50 + boxHeight < windowHeight) { // 说明鼠标上面放不下提示框
this.tooltip.y = e.pageY + 15
- } else {
- this.tooltip.y = e.pageY - boxHeight - 10
+ this.tooltip.x = e.pageX + 15
}
- } else {
- this.tooltip.y = e.pageY + 15
- this.tooltip.x = e.pageX + 15
- }
+ })
},
resize () {
setTimeout(() => {
@@ -292,14 +306,31 @@ export default {
this.svg.selectAll('rect').on('mouseenter', null)
this.svg.selectAll('rect').on('mousemove', null)
this.svg.selectAll('rect').on('mouseleave', null)
+ this.svg.selectAll('rect').on('click', 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('g').remove()
this.svg = null
}
+ },
+ chartClick (e, data) {
+ if (this.dataLink.length) {
+ this.tooltip.title = data.alias
+ this.tooltip.value = data.mapping && data.mapping.display ? this.handleDisplay(data.mapping.display, { ...data.labels, value: data.showValue }) : data.showValue
+ this.tooltip.mapping = data.mapping
+ this.tooltip.show = true
+ this.tooltip.dataLinkShow = true
+ this.setPosition(e)
+ }
+ },
+ clickout () {
+ if (this.dataLink.length) {
+ this.tooltip.show = false
+ this.tooltip.dataLinkShow = false
+ }
}
-
},
mounted () {
this.colorList = initColor(20)
diff --git a/nezha-fronted/src/components/chart/chart/chartRose.vue b/nezha-fronted/src/components/chart/chart/chartRose.vue
index 3da00da97..0c040679c 100644
--- a/nezha-fronted/src/components/chart/chart/chartRose.vue
+++ b/nezha-fronted/src/components/chart/chart/chartRose.vue
@@ -4,7 +4,8 @@
ref="rose-chart-box"
class="nz-chart__component"
>
-