記憶盒子

把記憶裝進(jìn)灰色的盒子,封裝起來,那年那月,重新拾起。

首頁(yè)搜索目錄
search
當(dāng)前主題: 軟件編程

實(shí)例演示C#利用dotnetcharting控件生成柱狀圖

作者:Kaka    時(shí)間:2009-6-7 10:27:34    瀏覽:    評(píng)論:1

    由于項(xiàng)目需要畫統(tǒng)計(jì)圖,經(jīng)討論,我們選用了dotnetcharting這個(gè)控件。dotnetcharting是一款非常棒的生成統(tǒng)計(jì)圖表的控件,開發(fā)人員只需要參考范例,掌握思路,就能夠自己自由的編寫代碼,實(shí)現(xiàn)各種各樣的統(tǒng)計(jì)效果圖。正版dotnetcharting是需要購(gòu)買的,價(jià)格目前官方網(wǎng)站上顯示是$395,相當(dāng)?shù)陌嘿F哦。不過中國(guó)人很聰明,現(xiàn)在到處可以下載破解版了。dotnetcharting目前已經(jīng)支持.net Framework 2.0, 3.0, and 3.5了,有c#和vb.net版本。相當(dāng)?shù)牟诲e(cuò)!

下面是幾個(gè)截圖,看看效果如何? 

(圖1) 2D柱狀圖

 

(圖2) 3D餅狀圖

 

(圖3) 股票走勢(shì)圖

dotnetcharting還能作出各種各樣的圖表出來,在此就不一一羅列了?,F(xiàn)附上(圖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

使用手冊(cè)可從官方網(wǎng)下載(E文):http://www.dotnetcharting.com

x

標(biāo)簽: Program  

※ 網(wǎng)站速度慢?試試網(wǎng)站自動(dòng)優(yōu)化工具 ※

  • 擴(kuò)展閱讀
上一篇: 速度令人震驚的文件搜索工具:Everything
下一篇: 驚嘆!天津真的出現(xiàn)了"麥田怪圈"!(Google Maps為證)

發(fā)表評(píng)論:

◎歡迎參與討論,請(qǐng)?jiān)谶@里發(fā)表您的看法、交流您的觀點(diǎn)。

訂閱博客                   QQ交流群(312716741)

  • 通過Google訂閱本站 通過鮮果訂閱本站 通過抓蝦訂閱本站
  • 通過QQ郵箱訂閱本站 通過Yahoo訂閱本站 通過有道訂閱本站

Search

最新評(píng)論及回復(fù)

最近留言

網(wǎng)站分類

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

Copyright @2009-2024 All Rights Reserved. 粵ICP備14028160號(hào)-1

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