Fon
Fon

Reputation: 36

Scala - Updating JFreeChart with Swing

Is there a way to update a chart based on the user input on text field? I'm not familiar with both Swing and JFreeChart but I need to virtualize some data. So far I'm able to display simple graph but only with hardcoded data.

Thank you

Upvotes: 0

Views: 118

Answers (1)

0__
0__

Reputation: 67300

Yes, of course that is possible. First of all, I recommend looking at Scala-Chart which is a nice wrapper around JFreeChart.

JFreeChart lets you alter and update any parameter. For example if you have a data-set, you can clear it and add new data, you can readjust the axes, etc. Here is an example from a project I'm working on, where a "series" (JFreeChart speak) is removed from a "dataset", then a new series is calculated and added again:

https://github.com/iem-projects/sysson/blob/70829bf80ad22dfc0b6020e00dd07397b100e401/src/main/scala/at/iem/sysson/gui/impl/PlotChartImpl.scala#L222

Upvotes: 3

Related Questions