这回主要介绍Chart图表的使用。
我们使用的Chart图表用两条曲线来显示,一条是作为温度的显示,一条是作为湿度的显示。
在Chart图表的属性里面,我们可以通过在里面设置相关属性进行设置,我们也可以通过代码设置。
下面我演示一下我通过代码的设置:
private void InitChart()//更新chart
{
//定义图表区域
this.chart1.ChartAreas.Clear();
ChartArea chartArea1 = new ChartArea("C1");
this.chart1.ChartAreas.Add(chartArea1);
//定义存储和显示点的容器
this.chart1.Series.Clear();
Series series1 = new Series("湿度曲线");
series1.ChartArea = "C1";
this.chart1.Series.Add(series1);
Series series2 = new Series("温度曲线");
series2.ChartArea = "C1";
this.chart1.Series.Add(series2);
//设置图表显示样式
this.chart1.ChartAreas[0].AxisY.Minimum = 0;
this.chart1.ChartAreas[0].AxisY.Maximum = 80;//刻度
this.chart1.ChartAreas[0].AxisY.Interval = 5;//间隔
this.chart1.ChartAreas[0].AxisX.I