Remove series from DefaultBoxAndWhiskerCategoryDataset?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
mminer
Posts: 11
Joined: Wed Jun 06, 2007 8:11 pm

Remove series from DefaultBoxAndWhiskerCategoryDataset?

Post by mminer » Fri Jun 08, 2007 4:59 pm

I would like to remove a series from a DefaultBoxAndWhiskerCategoryDataset, but there appears to be no way to do this. Any suggestions? In other datasets like TimeSeriesCollection there's methods to get the index of a particular series and remove it, but not so for this particular dataset. I'd prefer not to resort to creating a new dataset for each series, as it sort of defeats the purpose of having a dataset in the first place.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Jun 12, 2007 5:32 pm

It would be possible to add removeColumn() and removeRow() methods as in DefaultCategoryDataset, but it will also need the cached minimumRangeValue and maximumRangeValue attributes to be updated. I added the following feature request, and will hopefully get to it eventually (patches are welcome in the mean time, of course):

http://sourceforge.net/tracker/index.ph ... tid=365494
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

mminer
Posts: 11
Joined: Wed Jun 06, 2007 8:11 pm

Post by mminer » Tue Jun 12, 2007 6:56 pm

Thanks, I'll keep an eye out for those methods in future versions. In the meantime I'm storing each series in a HashMap which represents a dataset. When I add a series to the chart it's added to the HashMap, after which the map is sent to a function called remakeDataset(), which constructs and returns a new dataset. I chose to do this because I'm actually working with several different types of datasets (four, to be exact), and each one handles the removal of series somewhat differently. It's not terribly elegant, but it works. The key for each HashMap entry is a description of the series, which makes it easy to locate the specific series I want to remove.

Locked