Detecting when chart rendering is complete, and/or speeding up chart rendering

Dec 1, 2009 at 5:03 PM


I've been using the chart component, and I've noticed that when I generate a chart with a non-trivial amount of data, the rendering take sa fair amount of time. E.g. if I have 5 line series each with about 3 years worth of daily observations (i.e., around 1000 data poitns per series), generating the chart takes about 8-12 seconds on my system, during which time my app's UI freezes up.

In my current scenario this delay in itself is not a problem, but I'd like to at least show some appropriate UI during this time -- say, a wait cursor -- and I'm having trouble detecting when the rendering is complete, so I don't know when to remove the wait cursor. The code that generates the data and sets up the chart runs very fast, so I can't just wrap a wait cursor around that. But I haven't been able to find any event etc. on any of the chart components that indicates when the rendering is done, so I don't know when to remove my wait cursor. Is there some way to detect that, either through the chart or through WPF itself?

Also, some very superficial profiling suggests that the delays might be at least partly due to the data point animations. Is there an easy way (i.e. without recompiling the toolkit) to disable these animations? I haven't been able to find anything in the templates for this, it looks like all the animation is done in code. Or have I missed something? In fact I don't even need the data points at all -- I'm only displaying the plot lines, and I've styled the data points to be invisible -- so if there were a way to suppress data points altogether that might help too.

Any thoughts on any of this would be much appreciated.

Thanks in advance for any help!

Dec 1, 2009 at 6:52 PM

UPDATE: After posting this I looked around some more, and it looks like this is a general WPF issue -- WPF rendering happens on a special rendering thread, and there's no documented way to detect "rendering complete."

A few sources (see below) suggested using Dispatcher.Invoke with a low priority (I used Background, but presumably any priority lower than Render would work), and this seems to do the trick, and appears to be the best approach that's currently available.