最近兩天在做統計的時候,在網上找到生成折線圖的代碼,但是我現在要從數據庫中讀取數據生成折線圖,找了好久,沒有找到,最後還是自己動手去寫,經過這兩天的測試,搞定了,現在發出來與大家共享。
< !-- #include file="adoconn.ASP" -->
<Html xmlns:v="urn:schemas-microsoft-com:vml" XMLns:o="urn:schemas-microsoft-com:office:Office">
<head>
<title>曲線統計</title>
<STYLE>
v\:* { Behavior: url(#default#VML) }
o\:* { behavior: url(#default#VML) }
</STYLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
var showit = new Array(10);
function moveon(iteam,lineit){
temp=eval(iteam)
templine=eval(lineit)
if(showit[1]){
rec1.style.display = "";
line_1.style.display = "";
}else{
rec1.style.display = "none";
line_1.style.display = "none";
}
temp.style.display = "";
templine.style.display = "";
}
function moveout(iteam,lineit,i){
temp=eval(iteam)
templine=eval(lineit)
if (showit[i]){
temp.style.display = "";
templine.style.display = "";
}else{
temp.style.display = "none";
templine.style.display = "none";
}
}
function clickit(i){
if (showit[i]){
showit[i]=false
}else{
showit[i]=true
}
}
-->
</script>
</head>
<body>
< %
'''''''''''''''''''''''''''''''''''''''''''''
' 功能:ASP讀取數據庫中數據生成統計折線圖
' 開發:wangsdong
' 地址:www.ASPprogram.cn
' 支持原創,保留此信息,謝謝
'''''''''''''''''''''''''''''''''''''''''''''
date1=cdate("2008-01-01 00:00:00")
date2=cdate("2008-12-31 23:59:59")
sql="select sum(m_value) as t,m_month from table1 where m_time>=#"&date1&"# and m_time<=#"&date2&"# group by m_month"
rs.open sql,conn,1,1
if rs.eof then
else
redim total(1,2)
s=""
v1=""
do while not rs.eof
s=s&","&rs("m_month")&"月"
v1=v1&","&rs("t")
rs.movenext
loop
total(0,1)=right(s,len(s)-1)
total(1,1)=right(v1,len(v1)-1)
total(1,2)="2008年業績圖"
end if
rs.close
set rs=nothing
call table1(total,20,20,700,350,"曲線統計圖","時間","元")
% >
</body>
</Html>