ASP+SGC實現柱狀圖

來源:互聯網
上載者:User
很久以前寫的東西了

SGC是Structured Graphic Control(結構化圖形控制項)的縮寫,它是Microsoft Internet Explorer中的一組建立和處理向量圖形的ActiveX控制項。使用SGC建立圖表的步驟如下:

 

 

 

 

1)        插入CLASSID屬性為CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6的OBJECT標記,此操作代表對SGC的引用。同時設定OBJECT標記的style屬性確定圖表的顯示樣式;

 

 

 

 

2)        通過插入一系列PARAM標記繪製圖表,PARAM標記是OBJECT的子標記,它的基本文法是:<PARAM NAME="Linexxxx" VALUE="method(parameters)">,其中,“xxxx”必須是形如“0001”、“0002”的整數序列,“method(parameters)”指定了操作要以哪些參數執行哪個方法。在SGC中,可用的方法分為四類:繪製基於點陣的向量形狀,控制線條效果,控制填充效果和其它方法。結合使用這四種方法可以方便地實現圖表主體、座標、圖例等的繪製。至於圖表標題,可以直接使用HTML中的常用標記在SGC對象的外部體現。

 

 

 

diaocha.asp:

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="conndiaocha.asp" -->
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conndiaocha_STRING
Recordset1.Source = "SELECT * FROM diaocha"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<html>
<head>
<title>調查</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../includes/ao.CSS" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
dim score(4)
dim yscore(4)
dim tscore(4)
Recordset1.MoveFirst
dim total
For i=1 to 3
 score(i)=Recordset1("票數")
 tscore(i)=score(i)
 total=total+score(i)
 Recordset1.MoveNext
 If Recordset1.Eof then Exit For
Next
average=int(total/3)
tscore(4)=average
score(4)=average
dim max
max=0
For i=1 to 4
 If max<score(i) then max=score(i)
Next
For i=1 to 4
 score(i)=int(80/max*score(i))
Next
For i=1 to 4
 If score(i)>=400 then
  yscore(i)=0-(score(i)-40)
 else
  yscore(i)=40-score(i)
 End IF
Next
%>
<OBJECT ID=SCORE STYLE="POSITION:absolute;width:120;height:80;left:-2px;top:9px" CLASSID="CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6">
  <PARAM NAME='Line0001' VALUE='PolyLine(2,-40,-40,-40,40,0)'>
<PARAM NAME='Line0002' VALUE='SetFillStyle(3)'>
<PARAM NAME='Line0003' VALUE='SetHatchFill(1)'>
<PARAM NAME='Line0004' VALUE='SetFillColor(204,0,0,204,0,0)'>"
<%
Response.write "<PARAM NAME='Line0005' VALUE='Rect(" & -30 & "," & yscore(1) & "," & 10 & "," & score(1) & ",0)'>"
%>
<PARAM NAME='Line0006' VALUE='SetFillStyle(4)'>
<PARAM NAME='Line0007' VALUE='SetHatchFill(11)'>
<PARAM NAME='Line0008' VALUE='SetFillColor(204,0,66,204,0,66)'>
<%
Response.write "<PARAM NAME='Line0009' VALUE='Rect(" & -10 & "," & yscore(2) & "," & 10 & "," & score(2) & ",0)'>"
%>
<PARAM NAME='Line0010' VALUE='SetFillStyle(5)'>
<PARAM NAME='Line0011' VALUE='SetHatchFill(1)'>
<PARAM NAME='Line0012' VALUE='SetFillColor(204,0,204,204,0,204)'>
<%
Response.write "<PARAM NAME='Line0013' VALUE='Rect(" & 10 & "," & yscore(3) & "," & 10 & "," & score(3) & ",0)'>"
%>
<PARAM NAME='Line0014' VALUE='SetFillStyle(6)'>
<PARAM NAME='Line0015' VALUE='SetHatchFill(1)'>
<PARAM NAME='Line0016' VALUE='SetFillColor(255,66,33,255,66,33)'>
<%
Response.write "<PARAM NAME='Line0017' VALUE='Rect(" & 30 & "," & yscore(4) & "," & 10 & "," & score(4) & ",0)'>"
%>
<PARAM NAME='Line0018' VALUE='PolyLine(2,-40,39,120,40,0)'>
</OBJECT>
<div id="Layer1" style="position:absolute; width:224px; height:79px; z-index:1; left: 14px; top: 104px">
  <table width="50%" border="1" height="35" bordercolor="#FFFFFF" cellpadding="0" cellspacing="0">
    <tr>
      <td class="font9" bgcolor="#CC0000" width="10%">&nbsp;</td>
      <td class="font9" width="90%">整體布局(<%=tscore(1)%>)</td>
    </tr>
    <tr>
      <td class="font9" bgcolor="#CC0066" width="10%">&nbsp;</td>
      <td class="font9" width="90%">美工製作(<%=tscore(2)%>)</td>
    </tr>
    <tr>
      <td class="font9" bgcolor="#CC00CC" width="10%">&nbsp;</td>
      <td class="font9" width="90%">應用程式(<%=tscore(3)%>)</td>
    </tr>
    <tr>
      <td class="font9" bgcolor="#FF6633" width="10%">&nbsp;</td>
      <td class="font9" width="90%">平均票數(<%=tscore(4)%>)</td>
    </tr>
  </table>
 
  <br>
  &nbsp;&nbsp;&nbsp;<a href="javascript:window.close()">關閉視窗</a> </div>
</body>
</html>
<%
Recordset1.Close()
%>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.