zoukankan      html  css  js  c++  java
  • zedgraph基本教程篇第三节、第四节DateAxisSampleDemo.cs和TextAxisSampleDemo.cs介绍

     

    第三节、第四节DateAxisSampleDemo.cs和TextAxisSampleDemo.cs介绍      

            由于这两个例子很简单也很相似,所以决定还是放到一起来写。按照惯例还是先给出代码和图示。
     
    代码如下:
    DateAxisSampleDemo:
    using System;
    using System.Drawing;
    using System.Collections;

    using ZedGraph;

    namespace ZedGraph.Demo
    {
    ///<summary>
    /// Summary description for SimpleDemo.
    ///</summary>
    public class DateAxisSampleDemo : DemoBase
    {

    public DateAxisSampleDemo() : base( "Code Project Date Axis Sample",
    "Date Axis Sample", DemoType.Tutorial )
    {
    GraphPane myPane
    = base.GraphPane;

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

    // Make up some data points based on the Sine function
    PointPairList list = new PointPairList();
    for ( int i=0; i<36; i++ )
    {
    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;

    base.ZedGraphControl.AxisChange();
    }
    }
    }

    TextAxisSampleDemo:
    using System;
    using System.Drawing;
    using System.Collections;

    using ZedGraph;

    namespace ZedGraph.Demo
    {
    ///<summary>
    /// Summary description for SimpleDemo.
    ///</summary>
    public class TextAxisSampleDemo : DemoBase
    {

    public TextAxisSampleDemo() : base( "Code Project Text Axis Sample",
    "Text Axis Sample", DemoType.Tutorial )
    {
    GraphPane myPane
    = base.GraphPane;

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

    // Make up some data points
    string[] labels = { "USA", "Spain\nMadrid", "Qatar", "Morocco", "UK", "Uganda",
    "Cambodia", "Malaysia", "Australia", "Ecuador" };
    double[] y = new double[10];
    for ( int i=0; i<10; i++ )
    y[i]
    = Math.Sin( (double) i * Math.PI / 2.0 );

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

    //Make the curve smooth
    myCurve.Line.IsSmooth = true;

    // Set the XAxis to Text type
    myPane.XAxis.Type = AxisType.Text;
    // Set the XAxis labels
    myPane.XAxis.TextLabels = labels;
    // Set the labels at an angle so they don't overlap
    myPane.XAxis.ScaleFontSpec.Angle = 40;

    base.ZedGraphControl.AxisChange();
    }
    }
    }

    看到前两节的介绍,这里的代码就应该很简单了,我要说的只有两个类XDate和TextLabel这个属性。
    首先XDate就相当于msdn中的DateTime这个类,是个时间日期类,也是具有多个构造函数,XDate(
    1995, 5, i+11 )是按年月日来初始化的。
    第二个就是TextLabel属性,它主要是把Label的内容显示在Pane上。如TextAxisSampleDemo的X轴。


    本文来自CSDN博客,转载请标明出处:http:
    //blog.csdn.net/tjvictor/archive/2006/11/25/1413781.aspx
  • 相关阅读:
    Oracle中merge into的使用
    ORACLE闪回操作 .
    Xmanager远程连接rel5 linux
    ORACLE EXPDP/IMPDP命令使用详细 .
    Oracle Hint
    Oracle中Union与Union All的区别
    关于文件不能访问,IIS提示MIME类型没有错误的解决方法
    当葱头碰上豆瓣酱时
    唯美之希望
    【出行贴士】全国旅游最佳时间
  • 原文地址:https://www.cnblogs.com/beeone/p/2006256.html
Copyright © 2011-2022 走看看