简体   繁体   中英

Animate plot on JFreeChart line graph

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?

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 .

图片

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 .

图片

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM