用ZedGraph控件画统计分析图(精品)

上传人:hs****ma 文档编号:554724228 上传时间:2023-04-25 格式:DOC 页数:13 大小:478.50KB
返回 下载 相关 举报
用ZedGraph控件画统计分析图(精品)_第1页
第1页 / 共13页
用ZedGraph控件画统计分析图(精品)_第2页
第2页 / 共13页
用ZedGraph控件画统计分析图(精品)_第3页
第3页 / 共13页
用ZedGraph控件画统计分析图(精品)_第4页
第4页 / 共13页
用ZedGraph控件画统计分析图(精品)_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《用ZedGraph控件画统计分析图(精品)》由会员分享,可在线阅读,更多相关《用ZedGraph控件画统计分析图(精品)(13页珍藏版)》请在金锄头文库上搜索。

1、用ZedGraph控件画统计分析图由于朋友需要把C1WebChart.替换掉,改用开源的ZedGraph控件.以下做一个示例,供大家参考:步骤如下:1、添加ZedGraph控件。如下图: 2、添加到控制面版。如下图:3、制作用户控件。 a 建立一个命名为: DrawGrap.ascx 用户控件。 b 通过控制面版,把ZedGraphWeb拖到默认页面。 如下图: c 生成代码(DrawGrap.ascx)如下: d 生成代码(DrawGrap.ascx.cs)如下:usingSystem;usingSystem.Data;usingSystem.Configuration;usingSyste

2、m.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Drawing;usingZedGraph;usingZedGraph.Web;usingSystem.Collections.Generic;/*/显示统计图形类型/publicenumAnalyticsType.Lin

3、e,/折线图Bar,/柱状图Pie/饼图;publicpartialclassDrawGrap:System.Web.UI.UserControl.PrivateAttribute#regionPrivateAttribute/*/默认颜色种类/privateListdefaultColors=newList();/*/统计的个数/privateintCount;#endregionPublicProperty#regionPublicProperty/*/统计图的名称/publicstringTitle;/*/横轴的名称(饼图不需要)/publicstringXAxisTitle;/*/纵轴

4、的名称(饼图不需要)/publicstringYAxisTitle;/*/显示的曲线类型:Line,Bar,Pie/publicAnalyticsTypeType;/*/折线图和柱状图的数据源/publicListDataSource=newList();/*/饼图的数据源/publicListScaleData=newList();/*/各段数据的颜色/publicListColors=newList();/*/各段数据的名称/publicListNameList=newList();/*/用于柱状图,每个圆柱体表示的含义/publicListLabelList=newList();#end

5、regionprotectedvoidPage_Load(objectsender,EventArgse).zedGraphControl.RenderGraph+=newZedGraph.Web.ZedGraphWebControlEventHandler(zedGraphControl_RenderGraph);privatevoidInitDefaultColors().defaultColors.Add(Color.Red);defaultColors.Add(Color.Green);defaultColors.Add(Color.Blue);defaultColors.Add(Co

6、lor.Yellow);defaultColors.Add(Color.YellowGreen);defaultColors.Add(Color.Brown);defaultColors.Add(Color.Aqua);defaultColors.Add(Color.Cyan);defaultColors.Add(Color.DarkSeaGreen);defaultColors.Add(Color.Indigo);/*/如果属性为空则初始化属性数据/privatevoidInitProperty().InitDefaultColors();if(string.IsNullOrEmpty(Ti

7、tle).Title=未命名统计图;if(string.IsNullOrEmpty(XAxisTitle).XAxisTitle=横轴;if(string.IsNullOrEmpty(YAxisTitle).YAxisTitle=纵轴;if(Type=AnalyticsType.Pie).Count=ScaleData.Count;else.Count=DataSource.Count;if(Colors.Count=0|Colors.Count!=Count).Randomr=newRandom();inttempIndex=0;ListtempIndexList=newList();for(inti=0;iCount;i+).tempIndex=r.Next(defaultColors.Count);if(tempIndexList.Contains(tempIndex).i-;else.tempIndexList.Add(tempIndex);Colors.Add(defaultColorstempIndex);if(NameList.Count=0).if(Type=AnalyticsType.Bar).for(inti=0;iDataSource0.Count;i+).NameList.Add(第+i.ToString()+组);else

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号