WPF图表/实时数据可视化 [英] WPF charting/visualization of realtime data

查看:1058
本文介绍了WPF图表/实时数据可视化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试找出在WPF中将实时数据呈现为折线图的适当方法。我实际上是指从USB设备收集的数据,该设备以大约40Hz的速率生成数据。我以异步方式以40Hz读取了多个(最多7个)数据流。

I've been trying to figure out what is the appropriate way to render real-time data as a line graph in WPF. And by real-time I actually mean, data that is being collected from a USB device that generates data at a rate of approximately 40Hz. There are multiple (up to 7) streams of data that I'm reading at 40Hz in an asynchronous fashion.

我尝试使用两种现成的解决方案( WPF工具包图表和Swordfish图表),几乎研究了Dynamic Data Visualization组件,但在阅读了他们论坛上的一些评论后放弃了。似乎现成的制图解决方案适合静态图表,而我实际上需要类似于Windows Task Manager的东西-只是速度更快,而且数据点更多。

I've tried using two off-the shelf solutions (WPF Toolkit charting and Swordfish charts) and almost looked into the Dynamic Data Visualization component but gave up on it after reading some comments on their forum. It seems that off-the-shelf charting solutions are geared towards static charts and I actually need something similar to the Windows Task Manager - only much faster and with way more data points.

当前,我已经推出了自己的解决方案,该解决方案到目前为止似乎效果最好,但是我感觉我缺少一些东西,因为似乎我应该能够从中获得更好的性能。

Currently, I've rolled my own solution which seems to work the best so far but I have a feeling that I'm missing something because it seems that I should be able to get better performance out of it.

要求是它应该能够在滑动窗口中处理大约10000点的恒定范围-随着新数据的进入(频率为40Hz),旧数据被推到左侧超出可见范围。而且它需要维持此速率至少20-30分钟(每个数据流总计约75-10万点)。

The requirements are that it should be able to handle a constant range of about 10000 points in a sliding window - as new data comes in (at 40Hz), old data get's pushed to the left outside of the visible range. And it needs to sustain this rate for at least 20 - 30 minutes (a total of about 75 - 100 thousand points per data stream).

我当前的自定义实现是基于从Shape继承并为DefinigGeometry使用StreamingGeometry的组件。来自设备的数据通过队列传递到组件,以提高性能,这是由于其固有的突发效应所致,并且在出队操作之后,该组件无效。

My current custom implementation is a based on a component that inherits from Shape and uses a StreamingGeometry for the DefinigGeometry. The data coming in from the device is passed to the component via a queue to improve performance due to the inherent "bursting effect" and after a dequeue operation, the component is invalidated.

所以,我的问题是,我是在正确的道路上还是我完全错了?在WPF中完成这种数据可视化的最有效方法是什么?

So, my question is, am I on the right path or am I completely wrong? What is the most efficient way to accomplish such data visualization in WPF? Any help or hints would be greatly appreciated.

推荐答案


披露:我拥有ABT软件并已开发科学图,并且为 WriteableBitmapEx 开源库

不幸的是,您没有丢失任何东西。 WPF / Silverlight中的保留模式渲染引擎在此类工作中表现不佳。我曾在许多从Windows Forms升级到WPF的系统上工作,在该系统中,该 GPU加速框架的渲染性能使客户端感到非常失望!

Unfortunately you're not missing anything. The retained mode rendering engine in WPF / Silverlight delivers poor performance for this type of work. I've worked on a number of systems that were upgraded from Windows Forms to WPF where the client was sorely dissapointed by the rendering performance of this "GPU Accelerated" framework!

无论如何,有一种方法。使用即时模式渲染。签出WriteableBitmap或InteropBitmap类。 WriteableBitmapEx 。 com / rel = nofollow> Rene Schulte ,我为此做出了贡献。 WriteableBitmapEx提供了一些低级绘制功能(GDI样式),可直接绘制到位图。这样可提供出色的性能和低内存占用(是的,MS的精美框架被一对经过良好优化的for循环和指向字节数组的指针所击败)。

Anyway, there is a way. Use immediate mode rendering. Check out the WriteableBitmap or InteropBitmap classes. There is an excellent open source library out there called WriteableBitmapEx by Rene Schulte which I have contributed towards. WriteableBitmapEx provides some low-level drawing functions (GDI style) for drawing directly to bitmap. This delivers fantastic performance and low memory footprint (yes MS's fancy framework is beaten by a couple of well optimised for-loops and pointer to byte array).

如果您要查找的是特定的第三方图表组件,请尝试 SciChart 。 SciChart是我自己开发的组件,旨在填补超高性能WPF或Silverlight科学/股票图表的空白。它使用专有的重采样算法来减少绘图,即时模式渲染以及大量其他优化操作(例如对象池和资源重用)之前的数据集,从而为非常大的数据集提供了平滑的刷新率和较低的内存占用。

If it is a specific third party chart component you're looking for, try SciChart. SciChart is a component I have developed myself which seeks to fill the gap for ultra high performance WPF or Silverlight scientific / stock charts. It uses proprietary resampling algorithms to reduce the dataset before drawing, immediate mode rendering and a host of other optimisations such as object pooling and resource re-use, resulting in smooth refresh rates for very large datasets and low memory footprint.

单击上面链接上的性能演示(需要Silverlight 4)。目前,SciChart能够以大约5FPS的速度渲染1,000,000个数据点(取决于目标硬件),相当于每秒5,000,000个数据点。商业许可证将于2012年第一季度提供。

Click on the performance demo on the link above (requires Silverlight 4). Currently SciChart is able to render 1,000,000 datapoints at around 5FPS (depending on target hardware), equivalent to 5,000,000 datapoints per second. A commercial license will be available in Q1 2012.

这篇关于WPF图表/实时数据可视化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆