Skip to content

Commit

Permalink
fixes #4683; use correct series names for legend hover
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Sep 4, 2024
1 parent 7b34c3c commit e524061
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/modules/Series.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class Series {
const w = this.w

const targetElement = this.getSeriesByName(seriesName)
let realIndex = parseInt(targetElement.getAttribute('data:realIndex'), 10)
let realIndex = parseInt(targetElement?.getAttribute('data:realIndex'), 10)

let allSeriesEls = w.globals.dom.baseEl.querySelectorAll(
`.apexcharts-series, .apexcharts-datalabels, .apexcharts-yaxis`
Expand Down Expand Up @@ -168,7 +168,7 @@ export default class Series {
allSeriesEls[se].classList.add(this.legendInactiveClass)
}

if (seriesEl !== null) {
if (seriesEl) {
if (!w.globals.axisCharts) {
seriesEl.parentNode.classList.remove(this.legendInactiveClass)
}
Expand All @@ -181,6 +181,10 @@ export default class Series {
if (yaxisEl !== null) {
yaxisEl.classList.remove(this.legendInactiveClass)
}
} else {
for (let se = 0; se < allSeriesEls.length; se++) {
allSeriesEls[se].classList.remove(this.legendInactiveClass)
}
}
}

Expand All @@ -196,7 +200,7 @@ export default class Series {
if (e.type === 'mousemove') {
let realIndex = parseInt(targetElement.getAttribute('rel'), 10) - 1

this.highlightSeries(w.config.series[realIndex].name)
this.highlightSeries(w.globals.seriesNames[realIndex])
} else if (e.type === 'mouseout') {
for (let se = 0; se < allSeriesEls.length; se++) {
allSeriesEls[se].classList.remove(this.legendInactiveClass)
Expand Down

0 comments on commit e524061

Please sign in to comment.