第一范文网 - 专业文章范例文档资料分享平台

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

来源:用户分享 时间:2025/6/5 7:47:33 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

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) 的文档
ZedGraph控件属性及基础教程详解(2003).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c8zxw00bd304ddq343gyz_2.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top