fix: respect series.hidden flag on initial render by emptying collapsed series data - #5248
fix: respect series.hidden flag on initial render by emptying collapsed series data#5248waterWang wants to merge 1 commit into
Conversation
…ed series data The series.hidden config option was being tracked in collapsedSeriesIndices global state (via getSeriesAfterCollapsing), but the actual series data was not being emptied before rendering. This caused hidden series to still be drawn (visible) on the chart, even though the legend labels correctly showed them as dimmed. The fix follows the same pattern used in LegendHelpers._getSeriesBasedOnCollapsedState, which is already called when a series is hidden/risen via legend interaction: empty the data array for all indices tracked in collapsedSeriesIndices and ancillaryCollapsedSeriesIndices. Fixes apexcharts#5213
|
Thanks for the PR! I tried to reproduce this on current The reason is that I think #5213 (reported on 5.10.4) was fixed by other work since then.
|
Description
The
series.hiddenconfig option was being tracked incollapsedSeriesIndicesglobal state viagetSeriesAfterCollapsing(), but the actual series data was not being emptied before rendering. This caused hidden series to still be drawn (visible) on the chart, even though the legend labels correctly showed them as dimmed.Root Cause
When a user sets
hidden: trueon a series config, thecreate()method inapexcharts.jsiterates through the series and callsgetSeriesAfterCollapsing()for each hidden series. This correctly adds the index tocollapsedSeriesIndices, but the cloned series data returned by the function is still passed toparseData()with all values intact. The rendering pipeline then draws the SVG paths for those series, and while the CSS classapexcharts-series-collapsed(opacity: 0) is added, the paths are still present in the DOM.Fix
Empty the data array for all indices tracked in
collapsedSeriesIndicesandancillaryCollapsedSeriesIndicesafter the initialforEachloop. This follows the same pattern already used inLegendHelpers._getSeriesBasedOnCollapsedState(), which is called when a series is hidden/risen via legend interaction.Testing
hidden: trueon one or more seriesFixes #5213