我有一个应用程序,每次温度变化时都从串口获取温度数据。该值存储在一个变量中,并显示在一个文本框中。 我想在图表中显示温度与时间的关系。 我已经设置了以下图表,但我不知道从哪里开始更新温度线与每秒的时间。图动态更新
InitializeComponent();
//Chart
chart1.ChartAreas.Add("areas");
chart1.ChartAreas["areas"].AxisX.Minimum = 0;
chart1.ChartAreas["areas"].AxisX.Interval = 1;
chart1.ChartAreas["areas"].AxisY.Minimum = 0;
chart1.ChartAreas["areas"].AxisY.Maximum = 250;
chart1.ChartAreas["areas"].AxisY.Interval = 10;
chart1.ChartAreas["areas"].AxisX.Title = "Time [s]";
chart1.ChartAreas["areas"].AxisY.Title = "Temperature [°C]";
chart1.Series.Add("Temperature");
chart1.Series["Temperature"].Color = Color.Red;
chart1.Series["Temperature"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
chart1.Titles.Add("Extruder Temperature");
//this two lines are only to see something in the graph
chart1.Series["Temperature"].Points.AddXY(0, 20);
chart1.Series["Temperature"].Points.AddXY(1, 50);
}
我想我需要更新的“点”和“价值”(0,20),通过变量替换值,但如果我这样做,我在图中,我只有一点无法显示以前的值。作为初学者,我将不胜感激。
您使用的是Windows Forms还是WPF? – jle 2013-04-22 07:26:43
@jle我正在使用Windows窗体 – FeliceM 2013-04-22 07:51:22