Animate plot on JFreeChart line graph

那年仲夏 提交于 2019-12-11 18:08:33

问题


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:


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.



来源:https://stackoverflow.com/questions/19065053/animate-plot-on-jfreechart-line-graph

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!