记忆盒子

把记忆装进灰色的盒子,封装起来,那年那月,重新拾起。

首页搜索目录
search
当前主题: 软件编程

实例演示C#利用dotnetcharting控件生成柱状图

作者:Kaka    时间:2009-6-7 10:27:34    浏览:    评论:1

    由于项目需要画统计图,经讨论,我们选用了dotnetcharting这个控件。dotnetcharting是一款非常棒的生成统计图表的控件,开发人员只需要参考范例,掌握思路,就能够自己自由的编写代码,实现各种各样的统计效果图。正版dotnetcharting是需要购买的,价格目前官方网站上显示是$395,相当的昂贵哦。不过中国人很聪明,现在到处可以下载破解版了。dotnetcharting目前已经支持.net Framework 2.0, 3.0, and 3.5了,有c#和vb.net版本。相当的不错!

下面是几个截图,看看效果如何? 

(图1) 2D柱状图

 

(图2) 3D饼状图

 

(图3) 股票走势图

dotnetcharting还能作出各种各样的图表出来,在此就不一一罗列了。现附上(图1)的代码:

C#

<%@ Page Language="C#" Description="dotnetCHARTING Component"%>
<%@ Register TagPrefix="dotnet"  Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>


<script runat="server">

SeriesCollection getRandomData()
{
 SeriesCollection SC = new SeriesCollection();
 Random myR = new Random();
 for(int a = 0; a < 4; a++)
 {
  Series s = new Series();
  s.Name = "Series " + a;
  for(int b = 0; b < 5; b++)
  {
   Element e = new Element();
   e.Name = "E " + b;
   e.YValue = myR.Next(50);
   s.Elements.Add(e);
  }
  SC.Add(s);
 }

 // Set Different Colors for our Series
 SC[0].DefaultElement.Color = Color.FromArgb(49,255,49);
 SC[1].DefaultElement.Color = Color.FromArgb(255,255,0);
 SC[2].DefaultElement.Color = Color.FromArgb(255,99,49);
 SC[3].DefaultElement.Color = Color.FromArgb(0,156,255);
 return SC;
}


void Page_Load(Object sender,EventArgs e)
{
 // Set the title.
 Chart.Title="My Chart";


 // Set the x axis label
 Chart.ChartArea.XAxis.Label.Text="X Axis Label";

 // Set the y axis label
 Chart.ChartArea.YAxis.Label.Text="Y Axis Label";

 // Set the directory where the images will be stored.
 Chart.TempDirectory="temp";

 // Set the bar shading effect
 Chart.ShadingEffect = true;

 // Set he chart size.
 Chart.Width = 600;
 Chart.Height = 350;

 // Add the random data.
 Chart.SeriesCollection.Add(getRandomData());
   
   
}
</script>
<HTML><HEAD><TITLE>Gallery Sample</TITLE></HEAD>
<BODY>
<DIV align=center>
 <dotnet:Chart id="Chart"  runat="server"/>
</DIV>
</BODY>
</BODY>
</HTML>

 

vb.net

<%@ Page Language="VB" Description="dotnetCHARTING Component"%>
<%@ Register TagPrefix="dotnet"  Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>


<script runat="server">


Function getRandomData() As SeriesCollection

   Dim SC As New SeriesCollection()
   Dim myR As New Random()
   Dim a As Integer
   For a = 0 To 3
      Dim s As New Series()
      s.Name = "Series " & a
      Dim b As Integer
      For b = 0 To 4
         Dim e As New Element()
         e.Name = "E " & b
         e.YValue = myR.Next(50)
         s.Elements.Add(e)
      Next b
      SC.Add(s)
   Next a
  
 
   SC(0).DefaultElement.Color = Color.FromArgb(49, 255, 49)
   SC(1).DefaultElement.Color = Color.FromArgb(255, 255, 0)
   SC(2).DefaultElement.Color = Color.FromArgb(255, 99, 49)
   SC(3).DefaultElement.Color = Color.FromArgb(0, 156, 255)
   Return SC
End Function 'getRandomData

 

Sub Page_Load(sender As [Object], e As EventArgs)
   ' Set the title.
   Chart.Title = "My Chart"
  
  
   ' Set the x axis label
   Chart.ChartArea.XAxis.Label.Text = "X Axis Label"
  
   ' Set the y axis label
   Chart.ChartArea.YAxis.Label.Text = "Y Axis Label"
  
   ' Set the directory where the images will be stored.
   Chart.TempDirectory = "temp"
  
   ' Set the bar shading effect
   Chart.ShadingEffect = True
  
   ' Set he chart size.
   Chart.Size = "600x350"

  
   ' Add the random data.
   Chart.SeriesCollection.Add(getRandomData())
End Sub 'Page_Load
   
   

</script>
<HTML><HEAD><TITLE>Gallery Sample</TITLE></HEAD>
<BODY>
<DIV align=center>
 <dotnet:Chart id="Chart"  runat="server"/>
</DIV>
</BODY>
</BODY>
</HTML>

 

破解版下载地址:http://files.cnblogs.com/dreamof/dotnetcharting.rar

使用手册可从官方网下载(E文):http://www.dotnetcharting.com

加入本站QQ群(312716741),交流分享网站建设、优化、SEO技术。。。

 

  • 扩展阅读
上一篇: 速度令人震惊的文件搜索工具:Everything
下一篇: 惊叹!天津真的出现了"麦田怪圈"!(Google Maps为证)

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

订阅博客                   QQ交流群(312716741)

  • 通过Google订阅本站 通过鲜果订阅本站 通过抓虾订阅本站
  • 通过QQ邮箱订阅本站 通过Yahoo订阅本站 通过有道订阅本站

Search

最新评论及回复

最近留言

网站分类

Powered By Z-Blog 1.8 Walle Build 91204 Designed by Han'space

Copyright @2009 All Rights Reserved. 粤ICP备09073737号

Powered By Z-Blog 1.8 Walle Build 91204
Copyright @2009 All Rights Reserved.