11-07-2013 03:29 PM - edited 11-07-2013 03:30 PM
I can't get WPF Graph (MS2013) to work with Cursors AND the Zoom GraphInteraction (zoom with mouse). The zoom rectangle redraws so slowly that app is unusable, sometimes even hanging for long enough to get the "(Not Responding)" title from windows. WPF is supposed to redraw at 60 fps, but I'm getting < 1 fps when I use more than a couple cursors. How can I use both mouse-zoom and ~100 cursors at the same time?
The attached csproj is based on the Charting example. I pre-load 4 plots with 900 data points each, and add 90 cursors and set the Graph DefaultInteraction to Zoom. When you try to mouse-zoom on a region, the zoom rectangle doesn't appear right away, and while holding left mouse down the rectangle redraws VERY slowly (< 1 fps), not usable.
I've tried switching to Raster and marking the Cursors as ReadOnly, but it doesn't help. I've considered implementing my own mouse zoom (app has a sample Resize control just to test performance of a simple one), but it feels silly to disable native zoom just to implement same. I'm actually having similar performance issues with mouse zoom rectangle (~ 5 fps redraw) without cursors, but this behavior is simpler to reproduce. In our application, we frequently plot 4 channel datasets with 500K points and 100+ read-only cursors.
Any tips / workarounds / advice would be really appreciated!!
-David
Solved! Go to Solution.
11-08-2013 02:24 PM
The issue is due to the large number of cursors, each of which is generating its own visuals and recalculating its position on every update to the graph. Since the zoom visual is in the same layer as the cursors, layout is also being performed on the cursors each time the zoom visual is resized.
Instead of using a hundred individual cursors to annotate each point, I would recommend using a single custom object to render annotations for all points. Attached is a quick mockup (which further reduces the number of visuals generated with the help of a custom point shape that includes the vertical crosshair). Adding an instance of the AnnotatingCursor
to the Children
collection of the graph will mark every tenth point with a diamond.
11-11-2013 06:07 PM
Thanks Paul. I really like the idea of using a single derived cursor that renders multiple lines on the plot area. I think this will work well for us.
Can you explain some of what else is being calculated while the zoom selction rectangle is visible? Cursors aside (and solved, thank you), our test users feel like the yellow zoom rectangle feels "clunky." I'm talking about the rectangle that is visible while the mouse is still down and being dragged to select the region to zoom in on. Frequently, we get high cpu usage and the rectangle redraws at less than 5 fps.
Thanks very much for the example cursor code!!
-David
11-12-2013 12:56 PM
In the current implementation, whenever an object in one layer needs to update its layout, all objects in that layer (or in certain circumstances, all elements in the control) get redrawn. One of our main goals for the next release is improving layout performance.
If the "clunkiness" you are experiencing is due to slow layout, then you may be interested in the attached custom zoom mockup I tried before creating the annotating cursor. You can use this in place of the standard Zoom
for the DefaultInteraction
property or Interactions
collection. It temporarily moves the interaction visual to a separate panel out of the scope of normal control layout, performing manual size updates to get it to display appropriately.
Please note that, unlike the annotating cursor, this mockup relies on implementation details of the current release of the WPF controls. We intentionally left many of the underlying primitive types with minimal documentation, as we may change them in the future. In the current implementation, we use RegionPanel and element hosts to perform the layout for many of our controls. Although these exact members may be removed in a later release, we do plan to provide equivalent functionality and stabilize the primitive API over time.
Besides that caveat, I hope you find this useful.