ASP进阶:用ASP制作统计饼图、柱状图等_ASP教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:WebClass入门(1)
1.WebClass 简介: WebClass 是一个VB组件,驻留在WEB SERVER 上,并对浏览器的输入做出响应。 对用户来说,一个 IIS 应用程序好象是由一系列的HTML页面组成。对开发者来说, 一个 IIS 应用程

我们工作中经常需要将数据转化成柱状图,饼图等,以方便直观的分析数据, 这里给大家介绍一个ASP中制作饼图、柱状图的组件:csDrawGraph,csdgt.zip,因为是组件,所以我们在使用之前需要用REGSVR32.EXE 注册一下,csDrawGraph,可以在ASP中创建饼图,柱状图以及线图,其支持的格式有GIF, PNG, JPG and BMP.

chartdemo.asp

<%@ 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

<%@ 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
%>

程序很简单,再些不详细说明,下面看一个将数据库中的数据转换到图表的例子:

lines.asp:

<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:

分享:IIS6.0 ASP 错误解析
事 件 ID 描 述 0100 内存不足。无法分配所需的内存。

共2页上一页12下一页
来源:模板无忧//所属分类:ASP教程/更新时间:2008-08-22
相关ASP教程