Has anyone tried to hide a series by clicking on its legend entry?
I could only think of adding hide JCheckboxes on the chart's right click menu that toggled the visibility.
Is there a better way to do this?
Click on Legend To Hide Series
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
You can add a ChartMouseListener to the ChartPanel and look out for LegendItemEntities. If you have the JFreeChart Developer Guide (and thus the demo source code), check out MouseListenerDemo3.java.
From there, you can hide a series either by physically removing it from the dataset, or setting the visibility flag in the renderer (not all renderers support this yet).
From there, you can hide a series either by physically removing it from the dataset, or setting the visibility flag in the renderer (not all renderers support this yet).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

