Skip to content

Commit 1ae6e64

Browse files
authored
Merge pull request #4931 from apexcharts/revert-4929-fix/tooltip-active-state-blink
Revert "Fix tooltip stability for smoother chart interaction"
2 parents 7b3acb9 + 38acc84 commit 1ae6e64

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/modules/tooltip/Tooltip.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -529,19 +529,19 @@ export default class Tooltip {
529529
syncedCharts = this.ctx.getSyncedCharts()
530530
}
531531

532-
const isStickyTooltip =
532+
let isStickyTooltip =
533533
w.globals.xyCharts ||
534534
(w.config.chart.type === 'bar' &&
535535
!w.globals.isBarHorizontal &&
536536
this.tooltipUtil.hasBars() &&
537537
this.tConfig.shared) ||
538538
(w.globals.comboCharts && this.tooltipUtil.hasBars())
539539

540-
const isInteractionInProcess = (e.type === 'mousemove' || e.type === 'touchmove' || e.type === 'mouseup')
541-
const isInteractionEnd = (e.type === 'mouseout' || e.type === 'touchend')
542-
const isChartContextTarget = w.globals.dom.baseEl.contains(e.relatedTarget)
543-
544-
if (isInteractionInProcess) {
540+
if (
541+
e.type === 'mousemove' ||
542+
e.type === 'touchmove' ||
543+
e.type === 'mouseup'
544+
) {
545545
// there is no series to hover over
546546
if (
547547
w.globals.collapsedSeries.length +
@@ -555,9 +555,10 @@ export default class Tooltip {
555555
xcrosshairs.classList.add('apexcharts-active')
556556
}
557557

558-
const hasYAxisTooltip = this.yaxisTooltips.includes(true)
559-
560-
if (this.ycrosshairs !== null && hasYAxisTooltip) {
558+
const hasYAxisTooltip = this.yaxisTooltips.filter((b) => {
559+
return b === true
560+
})
561+
if (this.ycrosshairs !== null && hasYAxisTooltip.length) {
561562
this.ycrosshairs.classList.add('apexcharts-active')
562563
}
563564

@@ -567,10 +568,10 @@ export default class Tooltip {
567568
) {
568569
this.handleStickyTooltip(e, clientX, clientY, opt)
569570
} else {
570-
const isHeatmap = w.config.chart.type === 'heatmap'
571-
const isTreemap = w.config.chart.type === 'treemap'
572-
573-
if (isHeatmap || isTreemap) {
571+
if (
572+
w.config.chart.type === 'heatmap' ||
573+
w.config.chart.type === 'treemap'
574+
) {
574575
let markerXY = this.intersect.handleHeatTreeTooltip({
575576
e,
576577
opt,
@@ -581,8 +582,8 @@ export default class Tooltip {
581582
x = markerXY.x
582583
y = markerXY.y
583584

584-
tooltipEl.style.left = `${x}px`
585-
tooltipEl.style.top = `${y}px`
585+
tooltipEl.style.left = x + 'px'
586+
tooltipEl.style.top = y + 'px'
586587
} else {
587588
if (this.tooltipUtil.hasBars()) {
588589
this.intersect.handleBarTooltip({
@@ -611,7 +612,7 @@ export default class Tooltip {
611612

612613
w.globals.dom.baseEl.classList.add('apexcharts-tooltip-active')
613614
opt.tooltipEl.classList.add('apexcharts-active')
614-
} else if (!isChartContextTarget && isInteractionEnd) {
615+
} else if (e.type === 'mouseout' || e.type === 'touchend') {
615616
this.handleMouseOut(opt)
616617
}
617618
}

0 commit comments

Comments
 (0)