From ed7bce9b808fec7ad57bd2758a2ffaded4eae898 Mon Sep 17 00:00:00 2001 From: zyh Date: Wed, 7 Feb 2024 10:29:10 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-3409=20fix:=20dashboard=20snapshot=20toolti?= =?UTF-8?q?p=20z-index=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/assets/css/common.scss | 2 +- .../chart/chart/uplot/chartTimeSeriesMixin.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/nezha-fronted/src/assets/css/common.scss b/nezha-fronted/src/assets/css/common.scss index 30a879c6f..cbfd32554 100644 --- a/nezha-fronted/src/assets/css/common.scss +++ b/nezha-fronted/src/assets/css/common.scss @@ -538,7 +538,7 @@ td .nz-icon-gear:before { position: absolute; } .chart-time-series-tooltip { - position: absolute; + position: fixed; display: block; border-style: solid; white-space: nowrap; diff --git a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js index 4d17ea0e8..5af924efe 100644 --- a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js +++ b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js @@ -221,15 +221,15 @@ export default { let x = 0 let y = 0 if (self.mousePosition.left < (windowWidth / 2)) { // 说明鼠标在左边放不下提示框 - tooltip.style.left = (tooltipLeftOffset + lft + shiftX) + 'px' + tooltip.style.left = (self.mousePosition.left + shiftX) + 'px' } else { - tooltip.style.left = (tooltipLeftOffset + lft - shiftX) + 'px' + tooltip.style.left = (self.mousePosition.left - shiftX) + 'px' x = '-100%' } if (self.mousePosition.top + 50 < windowHeight / 2) { // 说明鼠标上面放不下提示框 - tooltip.style.top = (tooltipTopOffset + top + shiftY) + 'px' + tooltip.style.top = (self.mousePosition.top + shiftY) + 'px' } else { - tooltip.style.top = (tooltipTopOffset + top - shiftY) + 'px' + tooltip.style.top = (self.mousePosition.top - shiftY) + 'px' y = '-100%' } tooltip.style.transform = `translate(${x},${y})` @@ -558,7 +558,7 @@ export default { } } }, - uplotMouseenter () { + uplotMouseenter (e) { const chart = getChart(this.chartId) const over = chart.over const root = chart.root.querySelector('.u-wrap') @@ -567,6 +567,10 @@ export default { tooltip = tooltip[0] // tooltip.style.display = 'block' } + this.mousePosition = { + left: e.pageX, + top: e.pageY + } over.addEventListener('mouseleave', this.uplotMouseleave) over.addEventListener('mousemove', this.uplotMousemove) over.addEventListener('mousedown', this.uplotMousedown)