[英]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. 我目前正在开发一个项目,该项目使用JFreeChart库将实时数据绘制为折线图。 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
我要寻找的效果的一个很好的例子可以在这里找到: 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. 我目前正在为图形使用内置的XYLineChart。
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. 在此示例中 ,
SwingWorker
的process()
实现使用通过后台线程的publish()
方法发送的值更新XYSeries
。 The enclosing ChartPanel
listens to the chart and updates itself in response. 封闭的
ChartPanel
侦听该图表并进行更新以响应自身。
If the calculation has no significant latency, use javax.swing.Timer
, as shown here . 如果计算没有显著的等待时间,使用
javax.swing.Timer
,如图所示这里 。
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 . 还考虑
XYSplineRenderer
, 在此引用并在 此处看到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.