0
votes

I'm currently working on a project that plots real time data as a line graph using the JFreeChart library. It's working great, but I want to give it a little more elegance by plotting the data in a smooth animated manner, rather than plotting in discrete steps. A good example of the effect I'm looking for can be found here: http://www.highcharts.com/demo/line-basic

Notice how the lines are animated between plot points.

I'm currently using the inbuilt XYLineChart for my graphs.

Is there a simple (or existing) way to achieve this effect, or will I have to dig deep into the library to implement these changes manually?

1

1 Answers

1
votes

In this example, the process() implementation of a SwingWorker updates an XYSeries using values sent via the background thread's publish() method. The enclosing ChartPanel listens to the chart and updates itself in response.

If the calculation has no significant latency, use javax.swing.Timer, as shown here.

image

Addendum: What I'm looking for is a smooth animation of the line between each plot point.

There is no general substitute for the absence of data, but you can add points from a known function or interpolate based on existing data. Also consider XYSplineRenderer, cited here and seen here.

image