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

Conversation

zheyxu
Copy link

@zheyxu zheyxu commented Apr 28, 2022

click the legend and only keep the clicked legend. Greys others out

click the legend and only keep the clicked legend. Greys others out
@google-cla
Copy link

google-cla bot commented Apr 28, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

For more information, open the CLA check for this pull request.

@zheyxu
Copy link
Author

zheyxu commented Apr 28, 2022

charts_common/lib/src/chart/common/behavior/legend/series_legend.dart
/// 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);
}
}

It can be used for the long press. When user long press the legend, only the clicked ones are kept. And other legends are greyed out.

Copy link

@gjwgit gjwgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useful additional functionality that can then match longpress and double tap behaviour within the legend to common expectations as in plotly - i.e. toggle the display to show only the tapped series or all series.

Tested in simple flutter app - works as advertised.

@stuartmorgan
Copy link
Collaborator

This project is no longer maintained, and cannot accept any PRs. Community members interested in collaborating on a community-maintained fork can coordinate in this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants