Skip to content

Commit

Permalink
fix #4794; jumping tooltp over bars in shadow DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Nov 10, 2024
1 parent cfb7ef0 commit 78f5dd5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
7 changes: 4 additions & 3 deletions src/modules/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ class Filters {
})

if (!shadowAttr.noUserSpaceOnUse) {
el.filterer().node.setAttribute('filterUnits', 'userSpaceOnUse')
el.filterer()?.node?.setAttribute('filterUnits', 'userSpaceOnUse')
}

// this scales the filter to a bigger size so that the dropshadow doesn't crops
this._scaleFilterSize(el.filterer().node)
this._scaleFilterSize(el.filterer()?.node)
}

// appends dropShadow to the filter object which can be chained with other filter effects
Expand Down Expand Up @@ -131,7 +131,7 @@ class Filters {
}

// this scales the filter to a bigger size so that the dropshadow doesn't crops
this._scaleFilterSize(el.filterer().node)
this._scaleFilterSize(el.filterer()?.node)

return el
}
Expand All @@ -152,6 +152,7 @@ class Filters {
}

_scaleFilterSize(el) {
if (!el) return
const setAttributes = (attrs) => {
for (let key in attrs) {
if (attrs.hasOwnProperty(key)) {
Expand Down
8 changes: 4 additions & 4 deletions src/modules/tooltip/Intersect.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ class Intersect {
e,
opt,
})
if (barXY.j === null && barXY.barHeight === 0 && barXY.barWidth === 0) {
return // bar was not hovered and didn't receive correct coords
}

i = barXY.i
let j = barXY.j

Expand Down Expand Up @@ -192,10 +196,6 @@ class Intersect {
10
)

const isReversed = w.globals.isMultipleYAxis
? w.config.yaxis[seriesIndex] && w.config.yaxis[seriesIndex].reversed
: w.config.yaxis[0].reversed

if (x + ttCtx.tooltipRect.ttWidth > w.globals.gridWidth) {
x = x - ttCtx.tooltipRect.ttWidth
} else if (x < 0) {
Expand Down
6 changes: 2 additions & 4 deletions src/modules/tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export default class Tooltip {
onSeriesHover(opt, e) {
// If a user is moving their mouse quickly, don't bother updating the tooltip every single frame

const targetDelay = 100
const targetDelay = 20
const timeSinceLastUpdate = Date.now() - this.lastHoverTime
if (timeSinceLastUpdate >= targetDelay) {
// The tooltip was last updated over 100ms ago - redraw it even if the user is still moving their
Expand Down Expand Up @@ -876,9 +876,7 @@ export default class Tooltip {
if (this.barSeriesHeight > 0) {
// hover state, activate snap filter
let graphics = new Graphics(this.ctx)
let paths = w.globals.dom.Paper.find(
`.apexcharts-bar-area[j='${j}']`
)
let paths = w.globals.dom.Paper.find(`.apexcharts-bar-area[j='${j}']`)

// de-activate first
this.deactivateHoverFilter()
Expand Down

0 comments on commit 78f5dd5

Please sign in to comment.