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

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

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

ZedGraph 属性及基础教程

myPane.FontSpec.FontColor = Color.Green; // Add gridlines to the plot, and make them gray myPane.XAxis.IsShowGrid = true; myPane.YAxis.IsShowGrid = true;

myPane.XAxis.GridColor = Color.LightGray; myPane.YAxis.GridColor = Color.LightGray;

// Move the legend location

base.Pane.Legend.Position = ZedGraph.LegendPos.Bottom; // Make both curves thicker myCurve.Line.Width = 2.0F; myCurve2.Line.Width = 2.0F; // Fill the area under the curves

myCurve.Line.Fill = new Fill( Color.White, Color.Red, 45F ); myCurve2.Line.Fill = new Fill( Color.White, Color.Blue, 45F ); // Increase the symbol sizes, and fill them with solid white myCurve.Symbol.Size = 8.0F; myCurve2.Symbol.Size = 8.0F;

myCurve.Symbol.Fill = new Fill( Color.Red ); myCurve2.Symbol.Fill = new Fill( Color.White ); // Add a background gradient fill to the axis frame myPane.AxisFill = new Fill( Color.White, Color.FromArgb( 255, 255, 210), -45F ); // Add a caption and an arrow

TextItem myText = new TextItem( \23F, 7F ); myText.FontSpec.FontColor = Color.Red; myText.Location.AlignH = AlignH.Center; myText.Location.AlignV = AlignV.Top; myPane.GraphItemList.Add( myText );

ArrowItem myArrow = new ArrowItem( Color.Red, 12F, 7F, 5F, 20F, 8F ); myPane.GraphItemList.Add( myArrow ); base.ZedGraphControl.AxisChange();

9 / 33

ZedGraph 属性及基础教程

} }

}

我们可以看到,这个例子和第一节中的例子大部分都相同,我在这只讲它们不同的地方,和不好懂的地方。 和第一节的图相比,本节的图在Pane上添加了Grid的显示,其功能要归功于如下代码:

myPane.XAxis.IsShowGrid = true; myPane.YAxis.IsShowGrid = true;

myPane.XAxis.GridColor = Color.LightGray; myPane.YAxis.GridColor = Color.LightGray;

代码一目了然,我就不用多解释什么了,要说的是注意在ZedGraph中,很多都是有缺省值的,IsShowGrid的缺省值就是false,所以第一节中没有对此项进行设置就没有显示Grid。

上节我就已经说过

LineItem myCurve = myPane.AddCurve( \Color.Red, SymbolType.Diamond ); myCurve接收myPane.AddCurve的返回值后就可以对里面的线图作近一步的描述,

myCurve.Line.Width = 2.0F;、myCurve.Line.Fill = new Fill( Color.White, Color.Red, 45F ); 和myCurve.Symbol.Fill = new Fill( Color.Red );

就是其中的三个应用,一个是Line的宽度,第二个表示Line要填充下面的区域,以45度角从左到右从白到红的填充,第三个表示线图上的符号被填充成什么颜色的。效果见下图:

关于Legend的类请见下图:

base.Pane.Legend.Position = ZedGraph.LegendPos.Bottom;

10 / 33

ZedGraph 属性及基础教程

就是显示Pane中的图形的名字,它里面也有很多属性和方法,如果大家写上base.Pane.Legend.IsVisible = false ;那么就可以隐藏图形的名字。

TextItem类的主要方法是在Pane中显示一个textbox的文本框,见上图 ArrowItem类的主要方法是在Pane上显示一个箭头,

ArrowItem myArrow = new ArrowItem( Color.Red, 12F, 7F, 5F, 20F, 8F ); 构造函数的参数含义分别为颜色,箭头的大小,箭头的起始(x,y),终止(x,y)。

基本教程篇--第三节、第四节DateAxisSampleDemo.cs和TextAxisSampleDemo.cs介绍

由于这两个例子很简单也很相似,所以决定还是放到一起来写。按照惯例还是先给出代码和图示。

11 / 33

ZedGraph 属性及基础教程

代码如下:

DateAxisSampleDemo:

using System;

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

namespace ZedGraph.Demo

{

12 / 33

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