Here's a question:
Once you create a TimeSeries with a name, can you change the name with a dynamic event such as a button click.
Or, do you have to redraw the whole graph?
Renaming TimeSeries Dynamically
I got this answer from SeanMcCrohan in another post:
The way to rename a TimeSeries is
1. remove all series from the dataset
2. add new TimeSeries with new name
The code would look something like this (inside an event such as getActionCommand). In this example, you can re-draw the graph with new name and datapoint.
--------------------------------------
this.dataset.removeAllSeries();
this.series = new TimeSeries("New Name", Millisecond.class);
this.dataset.addSeries(this.series);
this.series.add(new Millisecond(), newValue);
--------------------------------------
The way to rename a TimeSeries is
1. remove all series from the dataset
2. add new TimeSeries with new name
The code would look something like this (inside an event such as getActionCommand). In this example, you can re-draw the graph with new name and datapoint.
--------------------------------------
this.dataset.removeAllSeries();
this.series = new TimeSeries("New Name", Millisecond.class);
this.dataset.addSeries(this.series);
this.series.add(new Millisecond(), newValue);
--------------------------------------
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
You should be able to just call the setKey() method in the TimeSeries class and the chart should update automatically.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

