#73 Improve efficiency of drawing many points

Bill Bauer

I ran into an inefficiency drawing many data points. It appears that ZedGraph pretty much ignores the clipping region, or rather resets it for it's own purposes when drawing. This isn't a problem unless you very often (>1Hz) add a point. GraphPane.Draw redraws all of the data points, which can be slow if you have 100,000 data points. Drawing all the points is useful, even if far beyond screen resolution, because you can see the range of values, detect anomolies, and zoom in on suspicious areas and see the actual data.

I solved this by only invalidating a small region that just included the added data points. I modified ZedGraph to record the ClipBounds in MasterPane, copy it into the GraphPane, and then SetClip to the intersection of the saved ClipBounds and the Chart rectangle before Drawing the Curve. In Line.cs DrawCurve I use the ClipBoards to modify minX and maxX, and the drawing logic takes care of the rest. I find I can add a data point to a chart with about 100,000 points at 4Hz using about 50% of a CPU.

Attached are the diffs between my patch and 5.1.5.

Please contact me if you have any questions.



  • Bill Bauer

    Bill Bauer - 2009-07-09
  • Tim Trolinger

    Tim Trolinger - 2013-07-24

    Hi Bill, I see its been over a year since you updated this. Hopefully you are still around. I was having this very issue (Invalidate(Rect) was drawing more than just the Rect) using ZedGraph in my VB.Net project and causing a huge performance issue when there are big number of points, so even though I am not a C# programmer, I made your recommended changes, recompiled Zedgraph and it seems to be running much better now!


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks