From 2ae9e1ab194c3226e9f80ae69a9f22cf2c4b97b0 Mon Sep 17 00:00:00 2001 From: Juned Chhipa Date: Thu, 1 Aug 2024 12:34:39 +0530 Subject: [PATCH] fix #1339; tooltip.enabledOnSeries bugfix in irregular time series --- src/assets/apexcharts.css | 7 ------- src/modules/tooltip/Labels.js | 17 +++++++++++++---- src/modules/tooltip/Tooltip.js | 15 +++++---------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/assets/apexcharts.css b/src/assets/apexcharts.css index f25a5b1ca..03335b720 100644 --- a/src/assets/apexcharts.css +++ b/src/assets/apexcharts.css @@ -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 } diff --git a/src/modules/tooltip/Labels.js b/src/modules/tooltip/Labels.js index 439a7fe08..05cde9551 100644 --- a/src/modules/tooltip/Labels.js +++ b/src/modules/tooltip/Labels.js @@ -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({ @@ -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 @@ -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) { diff --git a/src/modules/tooltip/Tooltip.js b/src/modules/tooltip/Tooltip.js index 9650d95d9..ac9fea9fa 100644 --- a/src/modules/tooltip/Tooltip.js +++ b/src/modules/tooltip/Tooltip.js @@ -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')