juliansteenbakker / community_charts

This project is a fork of google/charts.
Apache License 2.0
84 stars 34 forks source link

Feature: support hidden series onChanged callback #28

Open jasaw opened 3 months ago

jasaw commented 3 months ago

When data series is hidden or visible via the series legend, callback to notify which data series are hidden and which are visible so this user preference can be stored away and restored in the future via defaultHiddenSeries parameter.

Example usage:

      List<String> currentHiddenSeries = <String>[];

      charts.SeriesLegend<String>(
        hiddenSeriesOnChange: (List<String?>? hiddenSeries) {
          currentHiddenSeries = <String>[];
          if (hiddenSeries != null) {
            hiddenSeries.forEach((String? name) {
              if (name != null) {
                currentHiddenSeries.add(name);
              }
            });
          }
          // TODO: store currentHiddenSeries away in non-volatile so it can be restored in the future.
        },
        defaultHiddenSeries: currentHiddenSeries,
      );