怎樣在ASP裡面建立統計圖表

來源:互聯網
上載者:User
下面給出了一個通用的函數及其用例,請參考。
 <%
REM 首先我們設計一個ShowCart函數,其中
REM aValues 是一個數值數組
REM aLables 是橫座標的標號
REM strTitle是這個統計圖的標題
REM strXAxisLable X軸的標籤
REM strYAxisLable Y軸的標籤
Sub ShowChart(ByRef aValues, ByRef aLabels, ByRef strTitle, ByRef strXAxisLabel, ByRef strYAxisLabel)
' 你可以隨便改變的圖形常數
' 單位是螢幕像素點
Const GRAPH_WIDTH = 450 ' 圖形寬度
Const GRAPH_HEIGHT = 250 ' 圖形
Const GRAPH_BORDER = 5 ' 座標線寬度
Const GRAPH_SPACER = 2 ' 統計條之間的距離
Const TABLE_BORDER = 0
' 變數聲明
Dim I
Dim iMaxValue
Dim iBarWidth
Dim iBarHeight
' 取得aValues最大值
iMaxValue = 0
For I = 0 To UBound(aValues)
If iMaxValue < aValues(I) Then iMaxValue = aValues(I)
Next 'I
' 計算每條圖形的寬度
iBarWidth = (GRAPH_WIDTH (UBound(aValues) + 1)) - GRAPH_SPACER
' 開始繪圖
%>
<TABLE BORDER='<%= TABLE_BORDER %>' CELLSPACING='0' CELLPADDING='0'>
<TR>
<TD COLSPAN='3' ALIGN='center'><H2><%= strTitle %></H2></TD>
</TR>
<TR>
<TD VALIGN='center'><B><%= strYAxisLabel %></B></TD>
<TD VALIGN='top'>
<TABLE BORDER='<%= TABLE_BORDER %>' CELLSPACING='0' CELLPADDING='0'>
<TR>
& nbsp; &n bsp; <TD ROWSPAN='2'><IMG SRC='./images/spacer.gif' BORDER='0' WIDTH='1' HEIGHT='<%= GRAPH_HEIGHT %>'></TD>
<TD VALIGN='top' ALIGN='right'><%= iMaxValue %> </TD>
& nbsp; </TR>
<TR>
<TD VALIGN='bottom' ALIGN='right'>0 </TD>
</TR>
</TABLE>
</TD>
<TD>
<TABLE BORDER='<%= TABLE_BORDER %>' CELLSPACING='0' CELLPADDING='0'>
<TR>
<TD VALIGN='bottom'><IMG SRC='./images/spacer_black.gif' BORDER='0' WIDTH='<%= GRAPH_BORDER %>' HEIGHT='<%= GRAPH_HEIGHT %>'></TD>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.