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

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

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

ZedGraph 属性及基础教程

// Make the bars horizontal by setting bar base axis to Y myPane.BarBase = BarBase.Y; // Make the bars percent stack type myPane.BarType = BarType.PercentStack; // Fill the axis background with a color gradient myPane.AxisFill = new Fill( Color.White, Color.FromArgb( 255, 255, 166), 90F ); // Fill the legend background with a color gradient myPane.Legend.Fill = new Fill( Color.White, Color.FromArgb( 255, 255, 250), 90F ); // Fill the pane background with a solid color

myPane.PaneFill = new Fill( Color.FromArgb( 250, 250, 255) ); base.ZedGraphControl.AxisChange(); } }

}

using System;

using System.Drawing;

21 / 33

ZedGraph 属性及基础教程

using System.Collections; using ZedGraph;

namespace ZedGraph.Demo

{

///

/// Summary description for SimpleDemo. ///

public class StackedBarSampleDemo : DemoBase {

public StackedBarSampleDemo() : base( \Project Stacked Bar Chart Sample\Bar Sample\DemoType.Tutorial ) {

GraphPane myPane = base.GraphPane; // Set the title and axis labels myPane.Title = \Stats\ myPane.XAxis.Title = \Cats\ myPane.YAxis.Title = \

// Make up some data points

string[] labels = { \\\\\\}; double[] y = { 100, 115, 75, 22, 98, 40 }; double[] y2 = { 120, 175, 95, 57, 113, 110 }; double[] y3 = { 204, 192, 119, 80, 134, 156 };

// Generate a red bar with \1\in the legend

BarItem myCurve = myPane.AddBar( \null, y, Color.Red ); // Fill the bar with a red-white-red color gradient for a 3d look myCurve.Bar.Fill = new Fill( Color.Red, Color.White, Color.Red ); // Generate a blue bar with \2\in the legend myCurve = myPane.AddBar( \null, y2, Color.Blue ); // Fill the bar with a Blue-white-Blue color gradient for a 3d look myCurve.Bar.Fill = new Fill( Color.Blue, Color.White, Color.Blue );

22 / 33

ZedGraph 属性及基础教程

// Generate a green bar with \3\in the legend

myCurve = myPane.AddBar( \null, y3, Color.Green ); // Fill the bar with a Green-white-Green color gradient for a 3d look myCurve.Bar.Fill = new Fill( Color.Green, Color.White, Color.Green ); // Draw the X tics between the labels instead of at the labels myPane.XAxis.IsTicsBetweenLabels = true; // Set the XAxis labels

myPane.XAxis.TextLabels = labels; // Set the XAxis to Text type myPane.XAxis.Type = AxisType.Text;

// Set the bar type to stack, which stacks the bars by automatically accumulating the values myPane.BarType = BarType.Stack; base.ZedGraphControl.AxisChange(); } }

}

这两个图的区别就是基轴不同,一个是以X轴为基轴,一个是以Y轴为基轴,ZedGraph中有相应的属性,很方便的在两个轴之间转换。如下:

myPane.BarBase = BarBase.Y;

下面我主要说说myPane.BarType。

BarType是一个枚举,共有六项,分别为Cluster、ClusterHiLow、Overlay、SortedOverlay、Stack和PercentStack。

Cluster和ClusterHiLow是让多个同一个基类Bar依次排开,Cluster还可以使用来自IPointList的“Z”的值来定义每一个Bar的底部。

myPane.BarType = BarType.Cluster;或者myPane.BarType = BarType.ClusterHiLow;如下图:

23 / 33

ZedGraph 属性及基础教程

Overlay和SortedOverlay故名思意,就是柱形按坐标相互覆盖。不同之处在于Overlay是按照哪个先画哪个在前的原则(注意这里不是按后画把先画的柱形覆盖的原则,而是正好相反按先画在前原则)。 SortedOverlay是按位标的大小,按小的位标在前,大的位标在后的原则来绘图的。 如下两图,第一个是按Overlay,第二个是SortedOverlay。

24 / 33

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