mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 05:22:13 +08:00
fix(图表): 修复多个tab页,提示显示错乱,会把tab2的提示显示到tab1的问题 #16271
This commit is contained in:
committed by
jianneng-fit2cloud
parent
e2b120409e
commit
2cfd1ed038
@@ -270,7 +270,8 @@ class ChartCarouselTooltip {
|
||||
this.chart.customAttr?.tooltip?.show &&
|
||||
this.chart.customAttr?.tooltip?.carousel?.enable &&
|
||||
this.values.length > 0 &&
|
||||
this.chartIsVisible
|
||||
this.chartIsVisible &&
|
||||
!this.hasParentWithSwitchHidden(this.plot.chart.ele)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -434,6 +435,21 @@ class ChartCarouselTooltip {
|
||||
return tooltipCtl.tooltip?.cfg?.container
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断元素是否有父元素包含 'switch-hidden' 类
|
||||
* @param element
|
||||
*/
|
||||
public hasParentWithSwitchHidden(element: HTMLElement) {
|
||||
let parent = element.parentElement
|
||||
while (parent) {
|
||||
if (parent.classList.contains('switch-hidden')) {
|
||||
return true
|
||||
}
|
||||
parent = parent.parentElement
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定事件监听
|
||||
* */
|
||||
@@ -475,8 +491,11 @@ class ChartCarouselTooltip {
|
||||
// 定义鼠标滚轮事件处理函数
|
||||
const handleMouseWheel = this.debounce(() => {
|
||||
CAROUSEL_MANAGER_INSTANCES?.forEach(instance => {
|
||||
instance.paused()
|
||||
instance.resume()
|
||||
// 如果元素有父元素不包含 'switch-hidden' 类,则继续轮播
|
||||
if (!this.hasParentWithSwitchHidden(instance.plot.chart.ele)) {
|
||||
instance.paused()
|
||||
instance.resume()
|
||||
}
|
||||
})
|
||||
}, 50)
|
||||
// 定义 touchmove 事件处理函数(移动端)
|
||||
|
||||
@@ -1784,6 +1784,10 @@ export function configPlotTooltipEvent<O extends PickOptions, P extends Plot<O>>
|
||||
if (!tooltipCtl) {
|
||||
return
|
||||
}
|
||||
const tooltipInstance = ChartCarouselTooltip.getInstanceByContainer(chart.container)
|
||||
if (tooltipInstance && tooltipInstance.hasParentWithSwitchHidden(plot.chart.ele)) {
|
||||
return
|
||||
}
|
||||
// 处理 tooltip 与下拉菜单的显示冲突问题
|
||||
const viewTrackBarElement = document.getElementById('view-track-bar-' + chart.id)
|
||||
const event = plot.chart.interactions.tooltip?.context?.event
|
||||
|
||||
Reference in New Issue
Block a user