Skip to content

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

Closed
@mbondyra

Description

@mbondyra

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? 🙏🏼

Metadata

Metadata

Assignees

Labels

:legendLegend related issuebugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions