使用ZedGraph制作联动图表

先上图

代码中都是通过设置图标属性来完成图标的创建的,思路很清晰,进而也说明图标内部功能很强大。

public class SynchronizedPanes : DemoBase
 {

  public SynchronizedPanes()
   : base( "A demo that shows how multiple GraphPanes can be synchronized to scroll together." +
      "  Test it by zooming in on one pane (all panes will zoom together).  Then, scroll to" +
      " see all panes move together.",
      "Synchronized Panes Demo", DemoType.Line )
  {

   //MasterPane包括了一系列GraphPane,以一种形式组织它们
   MasterPane master = base.MasterPane;

   master.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45.0f );
   master.PaneList.Clear();

   master.Title.IsVisible = true;
   master.Title.Text = "Synchronized Graph Demo";

   master.Margin.All = 10;
   master.InnerPaneGap = 0;

   ColorSymbolRotator rotator = new ColorSymbolRotator();

   for ( int j = 0; j < 3; j++ )
   {
    // Create a new graph with topLeft at (40,40) and size 600x400
    GraphPane myPaneT = new GraphPane( new Rectangle( 40, 40, 600, 400 ),
     "Case #" + ( j + 1 ).ToString(),
     "Time, Days",
     "Rate, m/s" );

    myPaneT.Fill.IsVisible = false;

    myPaneT.Chart.Fill = new Fill( Color.White, Color.LightYellow, 45.0F );
    myPaneT.BaseDimension = 3.0F;
    myPaneT.XAxis.Title.IsVisible = false;
    myPaneT.XAxis.Scale.IsVisible = false;
    myPaneT.Legend.IsVisible = false;
    myPaneT.Border.IsVisible = false;
    myPaneT.Title.IsVisible = false;
    myPaneT.XAxis.MajorTic.IsOutside = false;
    myPaneT.XAxis.MinorTic.IsOutside = false;
    myPaneT.XAxis.MajorGrid.IsVisible = true;
    myPaneT.XAxis.MinorGrid.IsVisible = true;
    myPaneT.Margin.All = 0;
    if ( j == 0 )
     myPaneT.Margin.Top = 20;
    if ( j == 2 )
    {
     myPaneT.XAxis.Title.IsVisible = true;
     myPaneT.XAxis.Scale.IsVisible = true;
     myPaneT.Margin.Bottom = 10;
    }

    if ( j > 0 )
     myPaneT.YAxis.Scale.IsSkipLastLabel = true;

    // This sets the minimum amount of space for the left and right side, respectively
    // The reason for this is so that the ChartRect's all end up being the same size.
    myPaneT.YAxis.MinSpace = 60;
    myPaneT.Y2Axis.MinSpace = 20;

    // Make up some data arrays based on the Sine function
    double x, y;
    PointPairList list = new PointPairList();
    for ( int i = 0; i < 36; i++ )
    {
     x = (double)i + 5 + j * 3;
     y = 3.0 * ( 1.5 + Math.Sin( (double)i * 0.2 + (double)j ) );
     list.Add( x, y );
    }

    LineItem myCurve = myPaneT.AddCurve( "Type " + j.ToString(),
     list, rotator.NextColor, rotator.NextSymbol );
    myCurve.Symbol.Fill = new Fill( Color.White );

    master.Add( myPaneT );
   }

   using ( Graphics g = base.ZedGraphControl.CreateGraphics() )
   {
    ZedGraphControl z1 = base.ZedGraphControl;

    master.SetLayout( g, PaneLayout.SingleColumn );
    z1.AxisChange();

    z1.IsAutoScrollRange = true;
    z1.IsShowHScrollBar = true;
    z1.IsShowVScrollBar = true;
    z1.IsSynchronizeXAxes = true;

   }

   base.ZedGraphControl.AxisChange();
  }
 }



  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值