由于項(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