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(); }
}
}我用以上代码实现了zedGraph曲线图的绘制,但是我要在里面画两条曲线,用不同的颜色表示,请问下该如何添加,本人C#菜鸟,多谢各位大侠帮忙!!
{
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(); }
}
}我用以上代码实现了zedGraph曲线图的绘制,但是我要在里面画两条曲线,用不同的颜色表示,请问下该如何添加,本人C#菜鸟,多谢各位大侠帮忙!!
可以的。可能是你当时用的版本太低了吧。
ZedGraph还可以导出emf的图片格式。