Can WPF render a line path with 300,000 points on it in a performance-sensitive environment?

后端 未结 6 1372
一个人的身影
一个人的身影 2020-12-23 23:39

A simple XY line graph: The X axis will represent the complete range of possible rating percentages, from 0% on one end to 100% on the other. Specifically, the X value will

相关标签:
6条回答
  • 2020-12-23 23:53

    If you aren't using .NET 3.5 SP1 just don't use any of the shader effects. Otherwise there isn't much you need to do as a WPF developer to ensure it uses hardware acceleration.

    0 讨论(0)
  • 2020-12-23 23:55

    IMHO, Paul seems to be on the right track, check out the sections on map smoothing, some of the examples use results from the Florida 2000 election results (~9M votes 18+M total people) for data sets.

    Along the lines of the thread from AgileJon, somewhat, I would use simply manually emit a bitmap if no straight forward technique was available to better depect your data set. I render visualizations of scatter plots that are easially 16 000 000 (16 Million+) in seconds, full 32bit ARGB pallette.

    You seem to of remarked "But going back to bitmaps seems like a giant step backwards", I would not be so quick to say that, the universe is bound by physical limits.

    I referred another post to this codeproject article, which does many tens of thousands of 3D plots + animation etc...

    0 讨论(0)
  • 2020-12-23 23:59

    It might be worth having a look at the WPF DynamicDataDisplay library. I've been using it recently and haven't any problems with large amounts of data. It's only an early version (0.3 in fact) so there's not much documentation, but it does have samples showing how to use it. Hopefully that'll be enough to get you started.

    The SimulationSample generates lots of data, so that should be a good place to start.

    0 讨论(0)
  • 2020-12-24 00:12

    I just stumbled upon this post and am building a line graph control myself that needs to be very performant as we update the points on our lines in a real-time manner.

    If performance and number of Visual(s) are what you are after ... I doubt you will find a more performant approach than programming directly against WPF's Visual layer (links: 1, 2). My initial results from using this approach have been very positive.

    This will be even more performant than overriding OnRender as it will encourage you to take advantage of WPF's retained mode drawing subsystem (where all the drawing instructions are cached).

    That is, if all you have to update is a point on the line, then updating the point will force the line Visual to update but won't force the rest of the graph (axes, gridlines, ...) to update ... as the drawing instructions for these are retained and will be reused (since they aren't updating).

    Chapter 14 in Pro WPF in C# 2008 by Matthew MacDonald has a great section (titled 'Visuals') on programming against WPF's Visual layer. Chapter 2 of WPF Control Development Unleashed also has section on page 13 where he discusses how a DrawingVisual approach would be perfect for a charting component. Finally, Charles Petzold wrote a MSDN Magazine article where the best overall solution to a scatter plot was a DrawingVisual approach.

    (Now, I know that your question mentioned the axes will also be updating ... and so my answer is really for the general case ... but I still think that this approach will be the most performant ... as only the things that need updating ... will update.)

    0 讨论(0)
  • 2020-12-24 00:13

    I do not know the answer, but coding up a quick test shouldn't take much longer than it did for you to post. Also, see this thread for a similar discussion.

    0 讨论(0)
  • 2020-12-24 00:18

    If you want it to be fast, the best way is to derive from Control and implement OnRender - normally this isn't necessary, but for your application it might be.

    Also, let's take a step back - the screen you're rendering to certainly isn't 300k pixels across; before you go to render, reduce the buffer by averaging n nodes into one until you've got something closer to the resolution of the actual device, then draw it on-screen.

    0 讨论(0)
提交回复
热议问题