欢迎来到天天文库
浏览记录
ID:37936694
大小:46.50 KB
页数:13页
时间:2019-06-03
《ZedGraph画曲线柱状图》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、使用ZedGraph画曲线柱状图 刚接触到ZedGraph,到网上搜素到的方法基本上都是使用临时文件来存储图片,然后再显示,但是临时图片太多的话会占用大量的空间。很不划算。最后看到有人说把RenderMode="RawImage"就可以了,但是会出现乱码。如何解决呢?下面是我的方法。 新建一个目录,命名为bin,把文件ZedGraph.Web.dll,ZedGraph.dll拷到bin目录下面。建立文件tuppian.aspx。其内容为:<%@PageLanguage="C#"AutoEventWireup=
2、"true"CodeFile="tuppian.aspx.cs"Inherits="tuppian"%><%@Registerassembly="ZedGraph.Web"namespace="ZedGraph.Web"tagprefix="cc1"%><%--特别注意了:本页面不要有HTML代码,和asp.net代码。不然会出现乱码,RenderMode="RawImage"一定要设置RawImage,不然会报错。--%>3、"RenderMode="RawImage">tuppian.aspx.cs为:usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.W4、ebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Drawing;usingZedGraph;usingZedGraph.Web;publicpartialclasstuppian:System.Web.UI.Page{ DarwGrapClassdg=newDarwGrapClass(); protectedvoidPage_Load(objectsender,EventArgse) { } protectedoverridevo5、idOnInit(EventArgse) { InitializeComponent(); base.OnInit(e); } privatevoidInitializeComponent() { stringid=Request.QueryString["id"]; switch(id) { case"1": DrawLine(); bre6、ak; case"2": DrawPie(); break; default: DrawBar(); break; } } privatevoidDrawBar() { dg.Type=AnalyticsType.Bar; dg.Title="用户访问柱状图"; dg.XAxisT7、itle="月份"; dg.YAxisTitle="用户访问数量"; Randomrand=newRandom(); string[]aa={"企业1","企业2","企业3"}; for(inti=0;i<2;i++) { ZedGraph.PointPairListppl=newZedGraph.PointPairList(); for(intj=0;j<12;j++) { 8、 doublex=rand.Next(10); doubley=rand.NextDouble()*100; ppl.Add(x,y); //dg.NameList.Add((j+1).ToString()+"月");
3、"RenderMode="RawImage">tuppian.aspx.cs为:usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.W
4、ebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Drawing;usingZedGraph;usingZedGraph.Web;publicpartialclasstuppian:System.Web.UI.Page{ DarwGrapClassdg=newDarwGrapClass(); protectedvoidPage_Load(objectsender,EventArgse) { } protectedoverridevo
5、idOnInit(EventArgse) { InitializeComponent(); base.OnInit(e); } privatevoidInitializeComponent() { stringid=Request.QueryString["id"]; switch(id) { case"1": DrawLine(); bre
6、ak; case"2": DrawPie(); break; default: DrawBar(); break; } } privatevoidDrawBar() { dg.Type=AnalyticsType.Bar; dg.Title="用户访问柱状图"; dg.XAxisT
7、itle="月份"; dg.YAxisTitle="用户访问数量"; Randomrand=newRandom(); string[]aa={"企业1","企业2","企业3"}; for(inti=0;i<2;i++) { ZedGraph.PointPairListppl=newZedGraph.PointPairList(); for(intj=0;j<12;j++) {
8、 doublex=rand.Next(10); doubley=rand.NextDouble()*100; ppl.Add(x,y); //dg.NameList.Add((j+1).ToString()+"月");
此文档下载收益归作者所有