Click here to Skip to main content
11,647,170 members (68,946 online)
Click here to Skip to main content

Tagged as

Speedup MSChart Clear Data Points

, 30 Apr 2012 MIT 7.3K 3
Rate this:
Please Sign up or sign in to vote.
Problem StatementClearing data points in MSChart is known to be very slow. SolutionHowever, there is a work around for this problem.Suggested work around from link stated

Problem Statement

Clearing data points in MSChart is known to be very slow.


However, there is a work around for this problem. Suggested work around from link stated above is as below:

    public void ClearPointsQuick()
        while (Points.Count > 0)
            Points.RemoveAt(Points.Count - 1);
        Points.Clear(); //NOTE 1

Extension method implementation is as below:

    internal static class MSChartExtension
        public static void ClearPoints(this Series sender)
            while (sender.Points.Count > 0)
                sender.Points.RemoveAt(sender.Points.Count - 1);
            sender.Points.Clear(); //NOTE 1

(NOTE 1) I added one additional line Points.Clear() at the end of the function to ensure the chart axis updated correctly on next plot. Without adding this line, I observed that previous axis settings will be used when plotting new data points right after calling ClearPoints().

See Also

MSChart Extension: An extension package for MSChart component which contains this fixes and others features.

Revision History

31/03/2012: Added additional line to force axis update on next plot (NOTE 1).
12/03/2012: Initial released.


This article, along with any associated source code and files, is licensed under The MIT License


About the Author

Code Artist
Software Developer (Senior)
Malaysia Malaysia

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150804.2 | Last Updated 30 Apr 2012
Article Copyright 2012 by Code Artist
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid