I have a 2D line plot done with XY line chart using the JFreeChart
library. Now, I would like to delete a series when the user clicks over that series line. Is it possible to do that? How should I do it?
In outline,
Add a ChartMouseListener
to determine the ChartEntity
that represents the selected series, as shown here; you can get the series index from the XYItemEntity
.
Use one of the removeSeries()
methods of XYSeriesCollection
to remove the chosen series.