.Net Chart Control Auto Scroll / Disable Auto Scale

I am currently creating an application that displays streaming data. I can get and add data points to the chart only in order, but after adding each point, the chart zooms to automatically include all data points (i.e., the points come together as more are added). How to disable this?

Ideally, I would like the graph to simply scroll along the x axis, rather than setting the scale every time a point was added. What is the best way to do this?

Here is the code that I use to add a data point when data arrives at the serial port:

chart1.Series["Series1"].Points.AddY(parsed);

The chart is only the default fast line chart. Here are screenshots of a graph that displays data over time. As you can see, it simply compresses the graph over time, and not just leaves the scale alone and scrolls to the right. After a few secondsAfter a few more seconds

+3
source share
2 answers

This will disable auto scaling:

chart1.ChartAreas[0].AxisY.ScaleBreakStyle.Enabled = false;
chart1.ChartAreas[0].AxisY.Maximum = 0.3;
chart1.ChartAreas[0].AxisY.Minimum = -0.3;
0
source

Iv'e did it as follows:

Editing is a layout that adds points on each timer, the minimum and maximum values ​​increase, therefore, the part shown increases and thus the scroll effect occurs.

private void mockTimerTick(object sender, EventArgs e)
{
        int i;

        if (isRunning)
            return;

        lock (_syncObj)
        {
            isRunning = true;
            for (i = currentOffset; i < samplesPerSegment + currentOffset; i++)
            {
                _series.Points.AddXY(mockPoints[i].X, mockPoints[i].Y);

                if (i >= _chart.ChartAreas["ChartArea1"].AxisX.Maximum)
                {
                    _chart.ChartAreas["ChartArea1"].AxisX.Maximum++;
                    _chart.ChartAreas["ChartArea1"].AxisX.Minimum++;
                    _chart.ChartAreas["ChartArea1"].AxisX.ScaleView.Scroll(_chart.ChartAreas["ChartArea1"].AxisX.Maximum);

                }               
            }
            isRunning = false;
        }

        currentOffset = i;
}
0
source

All Articles