上海疫情最新结果/单页网站seo如何优化
前面有一篇文章介绍ZedGraph的官网,以及控件的使用文档。
https://blog.csdn.net/weixin_40314351/article/details/114273114
现在,通过一个案例了解ZedGraph的常用属性。话不多数,直接上图。
这个是官网的一个案例,实现了多个Y轴同时在使用。
public partial class Form1 : Form{GraphPane myPane ;PointPairList vlist ;PointPairList alist ;PointPairList dlist ;PointPairList elist ;YAxis yAxis3;Y2Axis yAxis4;public Form1(){InitializeComponent();InitZedGraph();btnNew.Click += new EventHandler(btnNew_Click);}#region 初始化图表控件private void InitZedGraph(){myPane = myZedgraph.GraphPane;myPane.Title.Text = "Domonstration of Multi Y Graph";myPane.XAxis.Title.Text = "Time,s";myPane.YAxis.Title.Text = "Velocity, m/s";myPane.Y2Axis.Title.Text = "Acceleration, m/s2";vlist = new PointPairList();alist = new PointPairList();dlist = new PointPairList();elist = new PointPairList();for (int i = 0; i < 30; i++){double time = (double)i;double acceleration = 2.0;double velocity = acceleration * time;double distance = acceleration * time * time / 2.0;double energy = 100.0 * velocity * velocity / 2.0;alist.Add(time, acceleration);vlist.Add(time, velocity);elist.Add(time, energy);dlist.Add(time, distance);}//generate a red curve with diamond symbols, and "Velocity" in the legendLineItem myCurve = myPane.AddCurve("Velocity", vlist, Color.Red, SymbolType.Diamond);myCurve.Symbol.Fill = new Fill(Color.White); // fill the symbols with white//generate a blue curve with circle symbols , and "Acceleration" in the legendmyCurve = myPane.AddCurve("Acceleration", alist, Color.Blue, SymbolType.Circle);myCurve.Symbol.Fill = new Fill(Color.White); //fill the symbols with whitemyCurve.IsY2Axis = true; // associate this curve with Y2 axis//generate a green curve with square symbols, and "Distance" in the legendmyCurve = myPane.AddCurve("Distance", dlist, Color.Green, SymbolType.Square);myCurve.Symbol.Fill = new Fill(Color.White); //fill the symbols with whitemyCurve.YAxisIndex = 1; // Associate this curve with the second axis//generate a Black curve with triangle symbols, and "Energy" in the legendmyCurve = myPane.AddCurve("Energy", elist, Color.Black, SymbolType.Triangle);myCurve.Symbol.Fill = new Fill(Color.White); // fill the symbols with whitemyCurve.IsY2Axis = true; // Associate this curve with the Y2 axismyCurve.YAxisIndex = 1; // Associate this curve with the second Y2 axis//show the x axis gridmyPane.XAxis.MajorGrid.IsVisible = true;//make the Y axis scale redmyPane.YAxis.Scale.FontSpec.FontColor = Color.Red;myPane.YAxis.Title.FontSpec.FontColor = Color.Red;//turn off the opposite tics so the Y Tics don't show up on the Y2 axismyPane.YAxis.MajorTic.IsOpposite = false;myPane.YAxis.MinorTic.IsOpposite = false;// don't display the y zero linemyPane.YAxis.MajorGrid.IsZeroLine = false;//Align the Y axis labels so they are flush to the axismyPane.YAxis.Scale.Align = AlignP.Inside;myPane.YAxis.Scale.Max = 100;//enable the Y2 Axis displaymyPane.Y2Axis.IsVisible = true;//make the Y2 Axis scale bluemyPane.Y2Axis.Scale.FontSpec.FontColor = Color.Blue;myPane.Y2Axis.Title.FontSpec.FontColor = Color.Blue;//turn off the opposite tics so the Y2 tics don't show up on the Y axismyPane.Y2Axis.MajorTic.IsOpposite = false;myPane.Y2Axis.MinorTic.IsOpposite = false;//display the Y2 axis grid linesmyPane.Y2Axis.MajorGrid.IsVisible = true;myPane.Y2Axis.Scale.Align = AlignP.Inside; //align the Y2 axis labels so they are flush to the axismyPane.Y2Axis.Scale.Min = 1.5;myPane.Y2Axis.Scale.Max = 3;//create a second Y axis, greenyAxis3 = new YAxis("Distance, m");myPane.YAxisList.Add(yAxis3);yAxis3.Scale.FontSpec.FontColor = Color.Green;yAxis3.Title.FontSpec.FontColor = Color.Green;yAxis3.Color = Color.Green;//turn off the opposite tics so the Y2 tics don't show up on the Y axisyAxis3.MajorTic.IsInside = false;yAxis3.MinorTic.IsInside = false;yAxis3.MajorTic.IsOpposite = false;yAxis3.MinorTic.IsOpposite = false;yAxis3.Scale.Align = AlignP.Inside; //align the Y2 axis labels so they are flush to the axisyAxis4 = new Y2Axis("Energy");yAxis4.IsVisible = true;myPane.Y2AxisList.Add(yAxis4);//turn off the opposite tics so the Y2 tics don't show up on the y axisyAxis4.MajorTic.IsInside = false;yAxis4.MinorTic.IsInside = false;yAxis4.MajorTic.IsOpposite = false;yAxis4.MinorTic.IsOpposite = false;//Align the Y2 axis labels so they are flush to the axisyAxis4.Scale.Align = AlignP.Inside;yAxis4.Type = AxisType.Log;yAxis4.Scale.Min = 100;//fill the axis background with a gradientmyPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);myZedgraph.AxisChange();}#endregion}