110,567
社区成员
发帖
与我相关
我的任务
分享
namespace Quxian
{
public partial class FormQuxian : Form
{
Random ran = new Random();
PointPairList list = new PointPairList();
LineItem myCurve;
public FormQuxian()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
zedGraphControl1.GraphPane.XAxis.Scale.MaxAuto = true;
double x = (double)new XDate(DateTime.Now);
double y = ran.NextDouble();
list.Add(x, y);
this.zedGraphControl1.AxisChange();
this.zedGraphControl1.Refresh();
if (list.Count >= 40)
{
list.RemoveAt(0);
}
}
private void button3_Click(object sender, EventArgs e)
{
GraphPane myPane = zedGraphControl1.GraphPane;
myPane.CurveList.Clear();
this.zedGraphControl1.AxisChange();
this.zedGraphControl1.Refresh();
this.zedGraphControl1.GraphPane.Title.Text = "实时浓度曲线图";
this.zedGraphControl1.GraphPane.XAxis.Title.Text = "时间";
this.zedGraphControl1.GraphPane.YAxis.Title.Text = "浓度(mg/L)";
this.zedGraphControl1.GraphPane.XAxis.Type = ZedGraph.AxisType.DateAsOrdinal;
DateTime dt = DateTime.Now;
myCurve = zedGraphControl1.GraphPane.AddCurve("My Curve", list, Color.Red, SymbolType.None);
this.zedGraphControl1.AxisChange();
this.zedGraphControl1.Refresh();
}
}
}