最高效的方式来绘制数千个数据点与WPF? [英] Most performant way to graph thousands of data points with WPF?

查看:1904
本文介绍了最高效的方式来绘制数千个数据点与WPF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一张图表,显示财务数据。表现还不错,而我画显示为与的PathFigure A连接线采用的PathGeometry 一起小于10.000分和 LineSegment 秒。但现在我需要显示高达100.000点,在同一时间(无需滚动)和它已经与50.000分的很慢。我在想 StreamGeometry ,但我不知道,因为它基本上是一样的的PathGeometry stroring的信息字节流。没有任何一个有一个想法,让这个更高性能或也许有人甚至做了一些已经差不多?

编辑:这些数据一旦绘制的点不会改变,所以如果有可能的优化它,请让我知道(线段被冻结现在)

编辑:我试过StreamGeometry。创建图形花更长的时间由于某种原因,但是这不是问题。绘制所有点后绘制的图表上依然为previous方法一样慢。我认为这只是太多的数据点WPF来处理。

编辑:我已经试验了一下,我发现性能进行了一些改进通过转换其为previously双为int以prevent WPF的抗锯齿子像素线的坐标。

编辑:感谢您的所有建议,以减少线段数量的响应。我已经减少了他们顶多两倍的水平分辨率为加强线路和最多的水平分辨率为简单的线条和性能pretty的好了。

解决方案

我会考虑下采样您要呈现的点数。您可能有50000点的数据,但你不可能能够满足他们所有的屏幕上;即使你在一台显示器绘制的每一个点,你就需要 10万水平分辨率像素绘制他们!即使在D3D这是很多画。

既然你更可能有类似2,048像素,你不妨降低你作图点并画出适合到屏幕上只有一对夫妇一千绿党的近似曲线。如果例如用户的图形的时间框架,包括10000点,然后作图之前下采样那些万点至1000。有很多的技巧,你可以尝试,从简单的平均,中位数,邻居高斯卷积(我的建议)双三次插值绘制任意数量的点更大的大于1/2的屏幕分辨率将只是浪费

随着用户放大的曲线图的一部分,则可以重新取样来获得更高的分辨率和更精确的曲线拟合。

I have written a chart that displays financial data. Performance was good while I was drawing less than 10.000 points displayed as a connected line using PathGeometry together with PathFigure and LineSegments. But now I need to display up to 100.000 points at the same time (without scrolling) and it's already very slow with 50.000 points. I was thinking of StreamGeometry, but I am not sure since it's basically the same as a PathGeometry stroring the information as byte stream. Does any one have an idea to make this much more performant or maybe someone has even done something similar already?

EDIT: These data points do not change once drawn so if there is potential optimizing it, please let me know (line segments are frozen right now).

EDIT: I tried StreamGeometry. Creating the graphic took even longer for some reason, but this is not the issue. Drawing on the chart after drawing all the points is still as slow as the previous method. I think it's just too many data points for WPF to deal with.

EDIT: I've experimented a bit and I noticed that performance improved a bit by converting the coordinates which were previously in double to int to prevent WPF anti-aliasing sub-pixel lines.

EDIT: Thanks for all the responses suggesting to reduce the number of line segments. I have reduced them to at most twice the horizontal resolution for stepped lines and at most the horizontal resolution for simple lines and the performance is pretty good now.

解决方案

I'd consider downsampling the number of points you are trying to render. You may have 50,000 points of data but you're unlikely to be able to fit them all on the screen; even if you charted every single point in one display you'd need 100,000 pixels of horizontal resolution to draw them all! Even in D3D that's a lot to draw.

Since you are more likely to have something like 2,048 pixels, you may as well reduce the points you are graphing and draw an approximate curve that fits onto the screen and has only a couple thousand verts. If for example the user graphs a time frame including 10000 points, then downsample those 10000 points to 1000 before graphing. There are numerous techniques you could try, from simple averaging to median-neighbor to Gaussian convolution to (my suggestion) bicubic interpolation. Drawing any number of points greater than 1/2 the screen resolution will simply be a waste.

As the user zooms in on a part of a graph, you can resample to get higher resolutions and more accurate curve fitting.

这篇关于最高效的方式来绘制数千个数据点与WPF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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