六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

用ASP制作餅圖、柱狀圖等

[摘要]我們工作中經常需要將數據轉化成柱狀圖,餅圖等,以方便直觀的分析數據, 這里給大家介紹一個ASP中制作餅圖、柱狀圖的組件:csDrawGraph,csdgt.zip,因為是組件,所以我們在使用之前需要用REGSVR32.EXE 注冊一下,csDrawGraph,可以在ASP中創建餅圖,柱狀圖以及線圖...

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

看看如下的柱狀圖,餅圖如何生成的例子:

用ASP制作餅圖、柱狀圖等用ASP制作餅圖、柱狀圖等
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:

 <%@ language=vbscript %>
<%
  '利用數據庫中的數據生成線圖。
  '根據4個不同的值分別生成4條線。
  '在X軸上顯示星期的名稱。

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

  '利用下面的語句創建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

  '關閉數據庫連接
  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格式發送到瀏覽器
  Response.ContentType = "image/gif"
  Response.BinaryWrite Chart.GIFLine
  Response.End
%>

結果如圖所示:用ASP制作餅圖、柱狀圖等





主站蜘蛛池模板: 亚洲欧美国产精品专区久久 | 四虎在线永久 | 色无极在线观看 | 日韩免费在线观看 | 午夜视频在线观看免费观看在线观看 | 天天爱天天做久久天天狠狼 | 日本大片久久久高清免费看 | 日韩小视频在线播放 | 中文字幕精品波多野结衣 | 亚洲欧美自拍另类图片色 | 亚洲伦理在线观看 | 天天爱天天做久久天天狠狼 | 亚洲日韩中文字幕一区 | 一二三四日本高清观看视频 | 欧美无专区 | 亚洲图片欧美 | 亚洲图区欧美 | 亚洲国产成人影院播放 | 色综合网址| 日韩色视频在线观看 | 夜色1网站 | 日本理论片免费观看在线视频 | 视频一区二区在线观看 | 在线视频一区二区 | 午夜一区二区三区 | 在线天堂中文在线网 | 一级毛片一片毛 | 四虎国产永久在线观看 | 中文字幕视频在线观看 | 亚洲成人高清 | 一级做a爰片久久毛片毛片 一级做a爰片久久毛片看看 | 视频在线一区二区 | 青青青视频在线免费观看 | 亚洲第一区精品日韩在线播放 | 午夜a今| 窝窝女人体国产午夜视频 | 伊人久久大香网 | 日韩一级片在线免费观看 | 日韩免费一区二区三区 | 亚洲欧美一区二区三区在线观看 | 四虎在线播放免费永久视频 |