样例代码j包括实时曲线图,多种线性图集中显示以及柱形图、饼形图、线形图等使用和介绍,并有代码注解,非常适合学习者。
public partial class Form3 : Form
{
Random ran = new Random();
PointPairList list1 = new PointPairList();
PointPairList list2 = new PointPairList();
LineItem myCurve;
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
this.zedGraphControl1.GraphPane.Title.Text = "动态折线图";
this.zedGraphControl1.GraphPane.XAxis.Title.Text = "时间";
this.zedGraphControl1.GraphPane.YAxis.Title.Text = "数量";
this.zedGraphControl1.GraphPane.XAxis.Type = ZedGraph.AxisType.DateAsOrdinal;
//开始的时候是空的,随着时间的推移才逐渐画满,可以在初始化的时候填几个Y坐标为0的点
for (int i = 0; i = 100)
{
list1.RemoveAt(0);
}
if (list2.Count >= 100)
{
list2.RemoveAt(0);
}
zedGraphControl1.GraphPane.XAxis.Scale.MaxAuto = true;
double x = (double)new XDate(DateTime.Now);
double y = ran.Next(100, 120);
double y2 = ran.Next(90, 150);
// int RandKey = ran.Next(100, 999);
list1.Add(x, y);