国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

用ASP制作餅圖、柱狀圖等_ASP教程

2024-05-04 11:03:44
字體:
供稿:網(wǎng)友

推薦:利用ASP將HTML格式數(shù)據(jù)傳輸給Excel 的技巧
學習如何建立ASP頁面將HTML數(shù)據(jù)流傳送到Execl電子表格,并且在IE中顯示Execl電子表格。到目前為止,有好幾種方法可以使用ASP技術來創(chuàng)立Excel數(shù)據(jù)表格,你還可以利用服務器端Excel 8.0 VBA組

我們工作中經(jīng)常需要將數(shù)據(jù)轉(zhuǎn)化成柱狀圖,餅圖等,以方便直觀的分析數(shù)據(jù), 這里給大家介紹一個ASP中制作餅圖、柱狀圖的組件:csDrawGraph,csdgt.zip,因為是組件,所以我們在使用之前需要用REGSVR32.EXE 注冊一下,csDrawGraph,可以在ASP中創(chuàng)建餅圖,柱狀圖以及線圖,其支持的格式有GIF, PNG, JPG and BMP.

chartdemo.asp

以下為引用的內(nèi)容:
<%@ language=vbscript %>
<html>
<head>
<title>csDrawGraph Demonstration</title>
</head>
<body bgcolor="#FFFFFF">
<P>This simple demonstration shows two graphs using the same data. The first is
a bar chart:</P>
<P align="center"><IMG src="chartimages.asp?Type=Bar" width="400" height="300">
</P>
<P align="left">The second is a pie chart. The background colour is set to light
grey to show the overall size of the image.</P>
<P align="center"><IMG src="chartimages.asp?Type=Pie" width="400" height="300">
</P>
</body>
</html>

chartimages.asp

以下為引用的內(nèi)容:

<%@ language=vbscript %>

<%
Response.Expires = 0
Response.Buffer = true
Response.Clear
Response.ContentType = "Image/Gif"

Set Chart = Server.CreateObject("csDrawGraphTrial.Draw")


Chart.AddData "NO> 1", 17, "ff0000"
Chart.AddData "NO> 2", 28, "00ff00"
Chart.AddData "NO> 3", 5, "0000ff"

If Request.QueryString("Type") = "Pie" Then
Chart.Title = "Sample Pie Chart"
Chart.BGColor = "eeeeee"
Chart.LabelBGColor = "eeeeee"
Chart.TitleBGColor = "eeeeee"
Response.BinaryWrite Chart.GifPie
Else
Chart.Title = "Sample Bar Chart"
Response.BinaryWrite Chart.GifBar
End If

Response.End
%>

程序很簡單,再些不詳細說明,下面看一個將數(shù)據(jù)庫中的數(shù)據(jù)轉(zhuǎn)換到圖表的例子:

lines.asp:

以下為引用的內(nèi)容:

<html>
<head>
<title>Line graph showing all the results</title>

</head>

<body>
<table align=center width=400>
<tr><td colspan=4><img src="gif_lines.asp" width=400 height=300></td></tr>
</table>
<p>Links to the other result pages:</p>
<p><a href=barsbyday.asp>Bar chart showing all results for any one day</a>.</p>
<p><a href=barsbycolour.asp>Bar charts showing results for each colour separately</a>.</p>
</body>
</html>


gif_lines.asp:

以下為引用的內(nèi)容:
<%@ language=vbscript %>
<%
'利用數(shù)據(jù)庫中的數(shù)據(jù)生成線圖。
'根據(jù)4個不同的值分別生成4條線。
'在X軸上顯示星期的名稱。

Response.Expires = 0
Response.Buffer = true
Response.Clear

'利用下面的語句創(chuàng)建chart對象,版本不同會有所差異。
'Set Chart = Server.CreateObject("csDrawGraph.Draw")
Set Chart = Server.CreateObject("csDrawGraphTrial.Draw")

ConnectionString = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & _
Server.Mappath("data.mdb")
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open ConnectionString
Set RS = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM Table1 ORDER BY Day"
RS.Open SQL, DBConn

While Not RS.Eof
Chart.AddPoint CInt(RS("Day")), CInt(RS("Red")), "ff0000", "Red"
Chart.AddPoint CInt(RS("Day")), CInt(RS("Blue")), "0000ff", "Blue"
Chart.AddPoint CInt(RS("Day")), CInt(RS("Green")), "00ff00", "Green"
Chart.AddPoint CInt(RS("Day")), CInt(RS("Yellow")), "ffff00", "Yellow"
Chart.AddXValue CInt(RS("Day")), RS("DayName")
RS.MoveNext
Wend

'關閉數(shù)據(jù)庫連接
RS.Close
DBConn.Close

'下面設置組件屬性
'X軸坐標從1開始而不是0。(XOffset = 1)

Chart.Title = "All the combined results"
Chart.TitleX = 100
Chart.YAxisText = "Total for each day"
Chart.OriginY = 220
Chart.XOffset = 1
Chart.XTop = 7
Chart.XGrad = 1
Chart.UseXAxisLabels = true
Chart.LineWidth = 2
Chart.PointSize = 3
Chart.PointStyle = 1

'最后圖片以GIF格式發(fā)送到瀏覽器
Response.ContentType = "image/gif"
Response.BinaryWrite Chart.GIFLine
Response.End
%>


分享:ASP快速開發(fā)方法之數(shù)據(jù)操作
這是我自己的心得,給大家作個參考。我的目的是讓開發(fā)變得簡單,盡可能少地考慮實現(xiàn)語句,更多地把精力用于思考業(yè)務邏輯。希望我的文章對大家有所啟發(fā)和幫助。好吧,讓我們進入正題:先

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 舒兰市| 金沙县| 天津市| 和田市| 商丘市| 铜陵市| 南郑县| 荣昌县| 汽车| 清水县| 栾城县| 文成县| 微山县| 山阴县| 兰西县| 新密市| 濉溪县| 汽车| 民权县| 哈巴河县| 油尖旺区| 怀集县| 巴马| 肥城市| 沂南县| 辉县市| 襄城县| 重庆市| 石泉县| 泽普县| 思茅市| 蒙自县| 洪湖市| 临汾市| 新源县| 凭祥市| 土默特左旗| 台前县| 安陆市| 灯塔市| 石家庄市|