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

2009-05-12 14:49:49来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

我们工作中经常需要将数据转化成柱状图,饼图等,以方便直观的分析数据, 这里给大家介绍一个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

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:asp控制xml数据库的6段非常的经典代码

下一篇:ASP进阶:验证身份证号是否正确的代码