mschart - Poor interaction/cursor performance for larger data sets

407 views Asked by At

I am using mschart to display 10 lines with up to 60,000 points of data each. There is a single ChartArea and an individual Series for each line, set as type FastLine.

Initial performance is very good, with the chart loading almost instantly. The problems start when any sort of interaction is required. In my case this means CursorX position / selection is changed. The GUI thread goes to ~100% usage (a whole core) until the cursor stops moving. During this time the graph updates sporadically. No additional code or functions are being called.

After profiling the application to see where all of the CPU time is being used, it would appear that every time the cursor is moved the whole chart has to be redrawn. All 10 * 60,000 points of data. While this is reasonable with just a few thousand points of data to draw, it doesn't scale very well at all. Changing the cursors Interval value doesn't seem to make any difference.

Are there any changes I can make to fix / avoid this performance issue? If not, can you recommend any other charting libraries?

//EDIT//

As requested, here is some test code that displays the same issues as mentioned. All that is required is a chart called chart1 exists. Setting CursorX.IsUserEnabled and CursorX.IsUserSelectionEnabled to true allows for the (problematic) interactions to take place:

public MainForm()
{
    //
    // The InitializeComponent() call is required for Windows Forms designer support.
    //
    InitializeComponent();

    //Set up chart and add values
    ChartArea ca = chart1.ChartAreas.Add("Data");
    ca.AxisX.IsMarginVisible = false;
    ca.CursorX.Interval = 0.001;
    ca.CursorX.IsUserEnabled = true;
    ca.CursorX.IsUserSelectionEnabled = true;
    ca.AxisX.ScaleView.Zoomable = false;

    for (int i = 0; i < 10; i++)
    {
        Series s = new Series("Series_" + i.ToString());
        s.ChartArea = ca.Name;
        s.ChartType = SeriesChartType.FastLine;

        for (int p = 0; p < _maxPoints; p++)
        {
            double x = p / 100.0; //(10ms steps)
            double y = p * (1 + i);

            s.Points.AddXY(x, y);
        }

        chart1.Series.Add(s);
    }
}

The larger the value for _maxPoints, the worse the problem becomes.

0

There are 0 answers