您好我正在使用动态折线图来显示一些随机浮动值。
在显示折线图一段时间后,线图显示图表将变为此图像:
这是我添加用于更新图值的代码:
series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series1.XValueType = ChartValueType.Time;
series1.MarkerSize = 5;
series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
series1.Name = deviceid;
chart1.Series.Add(series1);
series1.ToolTip = "Name";
series1.Points.AddXY(DateTime.Now.ToOADate(), po);// po will have some floating point value
double removeBefore = DateTime.Now.AddSeconds((double)(4) * (-1)).ToOADate();
while (series1.Points[0].XValue < removeBefore)
{
series1.Points.RemoveAt(0);
}
chart1.ChartAreas[0].AxisX.Minimum = series1.Points[0].XValue;
chart1.ChartAreas[0].AxisX.Maximum = DateTime.FromOADate(series1.Points[0].XValue).AddSeconds(5).ToOADate();
chart1.Invalidate();
series1.Name = "Name";
答案 0 :(得分:-1)
这个问题迟到但可能会帮助其他人: 系列名称上的尾随空格将导致&#34; Cross&#34;,因此在这种情况下,如果deviceid是&#34; 1&#34;而不是&#34; 1&#34;然后图表将不会显示