ZedGraph横坐标显示日期

Image:dateaxis.png

 

 private void CreateGraph( ZedGraphControl zgc )
  {
            GraphPane myPane = zgc.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "My Test Date Graph";
            myPane.XAxis.Title.Text = "Date";
            myPane.YAxis.Title.Text = "My Y Axis";

            myPane.YAxis.Scale.Min = 0;
            myPane.YAxis.Scale.Max = 2;

            // Make up some data points based on the Sine function
            PointPairList list = new PointPairList();
            for (int i = 0; i < 36; i++)
            {
                XDate xd = new XDate(1995, 5, i + 11);

                //string str = ToString(xd, "d-MMM");

                double x = (double)new XDate(1995, 5, i + 11);
                double y = Math.Sin((double)i * Math.PI / 15.0);
                list.Add(x, y);
            }

            // Generate a red curve with diamond
            // symbols, and "My Curve" in the legend
            LineItem myCurve = myPane.AddCurve("My Curve",
               list, Color.Red, SymbolType.Diamond);

            // Set the XAxis to date type
            myPane.XAxis.Type = AxisType.Date;

            //X坐标时间显示格式
            myPane.XAxis.Scale.Format = "d-MMM";

            //坐标点时间显示格式

            zgc.PointDateFormat = "yyyy-MM-dd";

            // Calculate the Axis Scale Ranges
            zgc.AxisChange();

  }

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值