开发者

How to scale the x axis of a chart to only show the last 60 seconds of data

I have a chart on a windows form using c#. I am outputting data to the chart dynamically using:

Chart1.Series["Roll"].Points.AddXY(TimeStamp, roll);
Chart1.Series["Pitch"].Points.AddXY(TimeStamp, pitch);

I am wondering how to set the scale of the X axis to 开发者_StackOverflowbe a set interval size. I want the Chart to only show data for say the last 60 seconds.


Once you reach 60 points, you can remove points and have it recalculate the axis min/max, as in Chart control X axis growing and growing and it looks like it not moving . Alternatively, you can just tell it the new min/max, something like:

Axis xaxis = Chart1.ChartAreas[0].AxisX;
xaxis.Minimum = xaxis.Maximum - 60;

Might also need a call to Chart1.ResetAutoValues(); and/or xaxis.IntervalType = Seconds; before changing the minimum to get things to work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜