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 item click does not update series visibility property #515

Open
AndrasJanurik opened this issue Mar 30, 2018 · 1 comment
Open

Legend item click does not update series visibility property #515

AndrasJanurik opened this issue Mar 30, 2018 · 1 comment

Comments

@AndrasJanurik
Copy link

Clicking a legend item it will toggle the series visibility on the screen, which is the proper operation.
But it does not actually update the visible property of the series, so calling isVisible() will still return true after hiding a series.

Simple workaround
Just adding the following legend item click listener will work around the problem:

chart.addLegendItemClickListener(event -> ((AbstractSeries) event.getSeries()).setVisible(!((AbstractSeries) event.getSeries()).isVisible()));

@echarlus
Copy link

echarlus commented Jun 3, 2019

Just stumbled across the same issue with charts 4.1.0. I was wondering if it was on purpose ... I solved the issue using a trick similar to yours ...
Fixing it in the code seems pretty easy (Chart.java in onSeriesHide & onSeriesShow). One needs to ensure that resolved Series is an instance of AbstractSeries and then call setVisible accordingly ... I'll submit a pull request for this...

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

No branches or pull requests

2 participants