云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > ZedGraph控件属性及基础教程详解(2003)

ZedGraph控件属性及基础教程详解(2003)

  • 62 次阅读
  • 3 次下载
  • 2025/5/5 4:34:11

ZedGraph 属性及基础教程

public InitialSampleDemo() : base( \Project Initial Sample\, \Sample\DemoType.Tutorial ) 初始化基类的构造函数。基类重载了四个构造函数

public DemoBase( string description, string title, DemoType type ) {

ArrayList types = new ArrayList(); types.Add( type );

Init( description, title, types ); }

public DemoBase( string description, string title, DemoType type, DemoType type2 ) {

ArrayList types = new ArrayList(); types.Add( type ); types.Add( type2 );

Init( description, title, types ); }

public DemoBase( string description, string title, ICollection types ) {

Init( description, title, types ); }

private void Init( string description, string title, ICollection types ) {

this.description = description; this.title = title; this.types = types;

control = new ZedGraphControl(); }

函数中的变量含义如下: Description:对此结构的描述。

Title:在树形结构(TreeView)中显示的标题。

Types:要把此类显示在哪个树形结构的区域中。若有多个Types,则把此类分入不同的树形区域中。例如MasterPane Sample在Tutorial Sample和 Special Features两个区域都有。见图中的相应区域标注。

5 / 33

ZedGraph 属性及基础教程

myPane.Title = \Test Graph\\n(For CodeProject Sample)\ myPane.XAxis.Title = \X Axis\ myPane.YAxis.Title = \Y Axis\

分别指定这个Pane的title、XAxis和YAxis的标题。见上图。 PointPairList list1 = new PointPairList(); PointPairList list2 = new PointPairList(); for ( int i=0; i<36; i++ ) {

double x = (double) i + 5;

double y1 = 1.5 + Math.Sin( (double) i * 0.2 );

double y2 = 3.0 * ( 1.5 + Math.Sin( (double) i * 0.2 ) ); list1.Add( x, y1 ); list2.Add( x, y2 ); }

PointPairList类是一个集合类,继承自 System.Object

System.Collections.CollectionBase

ZedGraph.CollectionPlus

它是PointPair对象的集合,PointPair类是一个包含(X,Y)的坐标类。

6 / 33

ZedGraph 属性及基础教程

其中的for循环在为两个PointPairList复值。

LineItem myCurve = myPane.AddCurve( \list1, Color.Red, SymbolType.Diamond ); LineItem类是ZedGraph中的线条类.

myPane.AddCurve( \list1, Color.Red, SymbolType.Diamond );

的意思是将刚刚赋值的list以”Porsche”这个名字以红色和水晶形状画到Pane中,这个函数的返回值是一个LineItem。你可以通过myCurve这个变量来对它进行进一步的设定。其中SymbolType是个Enum,它枚举了12个可供使用的形状

最后一步就是刷新了。base.ZedGraphControl.AxisChange();

这样整个程序就完成了,简单吧,其实这是个简单的应该,以后会介绍更加复杂的用法和类库。

基本教程篇--第二节:ModInitialSampleDemo.cs介绍

为了讲解方便,我先附上源代码和效果图。

代码如下:

using System;

using System.Drawing; using System.Collections; using ZedGraph;

namespace ZedGraph.Demo

7 / 33

ZedGraph 属性及基础教程

{

///

/// Summary description for SimpleDemo. ///

public class ModInitialSampleDemo : DemoBase {

public ModInitialSampleDemo() : base( \Project Modified Initial Sample\ \Initial Sample\DemoType.Tutorial ) {

GraphPane myPane = base.GraphPane; // Set up the title and axis labels

myPane.Title = \Test Graph\\n(For CodeProject Sample)\ myPane.XAxis.Title = \X Axis\ myPane.YAxis.Title = \Y Axis\

// Make up some data arrays based on the Sine function PointPairList list1 = new PointPairList(); PointPairList list2 = new PointPairList(); for ( int i=0; i<36; i++ ) {

double x = (double) i + 5;

double y1 = 1.5 + Math.Sin( (double) i * 0.2 );

double y2 = 3.0 * ( 1.5 + Math.Sin( (double) i * 0.2 ) ); list1.Add( x, y1 ); list2.Add( x, y2 ); }

// Generate a red curve with diamond // symbols, and \in the legend

LineItem myCurve = myPane.AddCurve( \Color.Red, SymbolType.Diamond ); // Generate a blue curve with circle // symbols, and \in the legend

LineItem myCurve2 = myPane.AddCurve( \Color.Blue, SymbolType.Circle ); // Change the color of the title

8 / 33

搜索更多关于: ZedGraph控件属性及基础教程详解(2003) 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

ZedGraph 属性及基础教程 public InitialSampleDemo() : base( \Project Initial Sample\, \Sample\DemoType.Tutorial ) 初始化基类的构造函数。基类重载了四个构造函数 public DemoBase( string description, string title, DemoType type ) { ArrayList types = new ArrayList(); types.Add( type ); Init( description, title, types ); }

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com