我有应用程序使用实时图表控件收到日期并在我的控件上显示:
这是我的控制:
MyObject obj...
Series series = new Series();
series.Color = Color.Blue;
series.ChartType = SeriesChartType.Spline;
series.BorderWidth = 2;
chart1.Series.Add(series);
chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.White;
chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.White;
chart1.ChartAreas[0].AxisX.IsStartedFromZero = true;
chart1.ChartAreas[0].AxisX.IntervalOffsetType = DateTimeIntervalType.Number
计时器打勾:
private void chartTimer_Tick(object sender, EventArgs e)
{
series.Points.Add(wf.BitsPerSecond * 0.000001);
chart1.ResetAutoValues();
}
我的问题是,几分钟后图表停止更新并停止前进,我不知道原因。
答案 0 :(得分:0)
一段时间后,您将有太多DataPoints
来显示。
从一开始就最好删除旧的:
private void chartTimer_Tick(object sender, EventArgs e)
{
series.Points.Add(wf.BitsPerSecond * 0.000001);
if (series.Points.Count > someLimit) series.Points.RemoveAt(0);
chart1.ResetAutoValues();
}