Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

update series_legend.dart--- add onlyKeepSerie #759

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class SeriesLegend<D> extends Legend<D> {
/// List of series IDs that should not be hideable.
List<String>? _alwaysVisibleSeries;

/// List of all series IDs.
List<String>? _allSeries;

/// Whether or not the series legend should show measures on datum selection.
late bool _showMeasures;

Expand Down Expand Up @@ -150,6 +153,9 @@ class SeriesLegend<D> extends Legend<D> {
// of hidden series.
final seriesIds = seriesList.map((MutableSeries<D> series) => series.id);

// ger the list of all ids
_allSeries = seriesIds.toList();

_hiddenSeriesList.removeWhere((String id) => !seriesIds.contains(id));
}

Expand All @@ -171,6 +177,18 @@ class SeriesLegend<D> extends Legend<D> {
}
}

/// Only keep data for a series on the chart by [seriesId].
///
/// The other entries in the legend for this series will be grayed out to indicate
/// that they are hidden.
@protected
void onlyKeepSeries(String seriesId) {
if (!isSeriesAlwaysVisible(seriesId)) {
_allSeries?.forEach((element) => _hiddenSeriesList.add(element));
_hiddenSeriesList.remove(seriesId);
}
}

/// Shows the data for a series on the chart by [seriesId].
///
/// The entry in the legend for this series will be returned to its normal
Expand Down