Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Legend Statistics] After toggling visibility of the series for stacked chart, the stats are not displayed for the series #2476

Closed
mbondyra opened this issue Jun 27, 2024 · 0 comments · Fixed by #2477
Assignees
Labels
bug Something isn't working :legend Legend related issue

Comments

@mbondyra
Copy link
Contributor

mbondyra commented Jun 27, 2024

Describe the issue
Main

When we have a stacked chart (bar, line, or area) and we disable the visibility of some series, the statistics for those series do not display in the legend.

Screenshot 2024-06-27 at 16 17 40

This behavior is inconsistent because we show statistics for invisible series in non-stacked charts.
The root cause is this line in the code: stacked_series_utils.ts#L61, which filters out the series, preventing them from displaying in the legend. We do that because otherwise the series ‘hang’ in the air when painting them because the invisible series are included in the calculations. This is how it looks if I remove the if (isFiltered) return line:

Screenshot 2024-06-27 at 16 55 19

Instead of this, I tried to sort the series to place invisible series on the top:

  const sortedDataSeries = dataSeries.reverse().sort(({ isFiltered }) => (isFiltered ? 1 : -1));
  const dataSeriesMap = sortedDataSeries.reduce<Map<SeriesKey, DataSeries>>((acc, curr) => {...

This way they won't impact stacking, but they can still display in the legend. However, it breaks some other cases.

Screenshot 2024-06-27 at 16 50 23

@nickofthyme could you advise? 🙏🏼

@mbondyra mbondyra added bug Something isn't working :legend Legend related issue labels Jun 27, 2024
@mbondyra mbondyra changed the title [Legend Statistics] After toggling visibility of the series for stacked chart, the stats are not displayed for this series [Legend Statistics] After toggling visibility of the series for stacked chart, the stats are not displayed for the series Jun 27, 2024
@nickofthyme nickofthyme self-assigned this Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working :legend Legend related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants