Skip to content

Commit

Permalink
fix #1339; tooltip.enabledOnSeries bugfix in irregular time series
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Aug 1, 2024
1 parent c0de809 commit 2ae9e1a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
7 changes: 0 additions & 7 deletions src/assets/apexcharts.css
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,6 @@ rect.legend-mouseover-inactive,
padding-bottom: 4px
}

.apexcharts-tooltip-series-group-hidden {
opacity: 0;
height: 0;
line-height: 0;
padding: 0 !important
}

.apexcharts-tooltip-y-group {
padding: 6px 0 5px
}
Expand Down
17 changes: 13 additions & 4 deletions src/modules/tooltip/Labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Labels {
if (w.config.tooltip.custom !== undefined) {
this.handleCustomTooltip({ i, j, y1, y2, w })
} else {
this.toggleActiveInactiveSeries(shared)
this.toggleActiveInactiveSeries(shared, i)
}

let values = this.getValuesToPrint({
Expand Down Expand Up @@ -376,17 +376,26 @@ export default class Labels {
typeof val === 'undefined' ||
val === null ||
w.globals.ancillaryCollapsedSeriesIndices.indexOf(t) > -1 ||
w.globals.collapsedSeriesIndices.indexOf(t) > -1
w.globals.collapsedSeriesIndices.indexOf(t) > -1 ||
(Array.isArray(ttCtx.tConfig.enabledOnSeries) &&
ttCtx.tConfig.enabledOnSeries.indexOf(t) === -1)
) {
ttItemsChildren[0].parentNode.style.display = 'none'
} else {
ttItemsChildren[0].parentNode.style.display =
w.config.tooltip.items.display
}
} else {
if (
Array.isArray(ttCtx.tConfig.enabledOnSeries) &&
ttCtx.tConfig.enabledOnSeries.indexOf(t) === -1
) {
ttItemsChildren[0].parentNode.style.display = 'none'
}
}
}

toggleActiveInactiveSeries(shared) {
toggleActiveInactiveSeries(shared, i) {
const w = this.w
if (shared) {
// make all tooltips active
Expand All @@ -397,7 +406,7 @@ export default class Labels {

// enable the first tooltip text group
let firstTooltipSeriesGroup = w.globals.dom.baseEl.querySelector(
'.apexcharts-tooltip-series-group'
`.apexcharts-tooltip-series-group-${i}`
)

if (firstTooltipSeriesGroup) {
Expand Down
15 changes: 5 additions & 10 deletions src/modules/tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,12 @@ export default class Tooltip {
const tooltipEl = this.getElTooltip()
for (let i = 0; i < ttItemsCnt; i++) {
let gTxt = document.createElement('div')
gTxt.classList.add('apexcharts-tooltip-series-group')

gTxt.classList.add(
'apexcharts-tooltip-series-group',
`apexcharts-tooltip-series-group-${i}`
)
gTxt.style.order = w.config.tooltip.inverseOrder ? ttItemsCnt - i : i + 1
if (
this.tConfig.shared &&
this.tConfig.enabledOnSeries &&
Array.isArray(this.tConfig.enabledOnSeries)
) {
if (this.tConfig.enabledOnSeries.indexOf(i) < 0) {
gTxt.classList.add('apexcharts-tooltip-series-group-hidden')
}
}

let point = document.createElement('span')
point.classList.add('apexcharts-tooltip-marker')
Expand Down

0 comments on commit 2ae9e1a

Please sign in to comment.