ZedGraph橫座標顯示日期

Image:dateaxis.png

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /> 

 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();

  }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章