Search code examples
time-seriesjfreechart

Clearing a series and keep others in JFreeChart


I'm using JFreeChart to create a chart that has 6 TimeSeries in it.
Problem: When I call .clear() on one of those series all others get hidden:

    this.Series1.clear();

Question: What should I do to clear a series without others disappear?

Before calling .clear() on the "Red" series.
enter image description here

After calling .clear() on the "Red" series.
enter image description here


Solution

  • I get the expected result using either of these:

    dataset.removeSeries(0);
    dataset.getSeries(0).clear();
    

    You may need to verify that each TimeSeries is a distinct instance.