一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

asp 曲线图生成实例代码

时间:2022-07-02 23:04:12 编辑:袖梨 来源:一聚教程网




曲线统计




<%
'''''''''''''''''''''''''''''''''''''''''''''
' 功能:asp读取数据库教程中数据生成统计折线图
' 开发:wangsdong
' 地址:www.111com.net
' 支持原创,保留此信息,谢谢
'''''''''''''''''''''''''''''''''''''''''''''
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,"曲线统计图","时间","元")
%>

asp代码

<%
dim ConnStr
dim conn
'on error resume next
m=1
If m=1 Then
db="111.mdb"
 path=Server.MapPath(DB)
 set conn=server.createobject("adodb.Connection")
 connstr="provider=Microsoft.Jet.OLEDB.4.0;Data Source="&path
 conn.Open connstr
else
 ConnStr= "Provider = Sqloledb; User ID = " & "sa" & "; Password = " & "fuckchc" & "; Initial Catalog = " & "tianyipt" & "; Data Source = " & "server" & ";"
 ConnStr= "Provider = Sqloledb; User ID = " & "sa" & "; Password = " & "" & "; Initial Catalog = " & "aaaa" & "; Data Source = " & "localhost" & ";"
 'ConnStr= "Provider = Sqloledb; User ID = " & "sa" & "; Password = " & "" & "; Initial Catalog = " & "mydb" & "; Data Source = " & "localhost" & ";"
 Set conn = Server.CreateObject("ADODB.Connection")
 conn.open ConnStr
End if

Set rs=server.CreateObject("adodb.recordset")


'┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
'┃                                                  ┃
'┃ 摘 要: 统计图--曲线图                                 ┃
'┃ 作 者: 翁云兵                                      ┃
'┃ 创建日期:2004年12月01日                               ┃
'┃ 完成日期:2004年11月03日                              ┃
'┃                                                  ┃
'┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
'参数含义(数组,横坐标,纵坐标,图表的宽度,图表的高度,图表标题,X轴单位,Y轴单位)
function table1(stat_array,table_left,table_top,all_width,all_height,table_title,X_unit,Y_unit)
dim bg_color(10)
bg_color(1)="#ff1919"
bg_color(2)="#ffff19"
bg_color(3)="#1919ff"
bg_color(4)="#19ff19"
bg_color(5)="#fc0"
bg_color(6)="#3cc"
bg_color(7)="#ff19ff"
bg_color(8)="#993300"
bg_color(9)="#f60"
bg_color(10)="#ff8c19"
if X_unit <> "" then
X_unit = X_unit
end if
if Y_unit <> "" then
Y_unit = Y_unit
end if
num1 = ubound(stat_array,1)
line_temp=split(stat_array(0,1),",")
num2 = ubound(line_temp,1)+1
dim line_code
redim line_code(num1,num2)
for j=1 to num2
line_code(0,j) = line_temp(j-1)
next
for i=1 to num1
line_temp = split(stat_array(i,1),",")
line_code(i,0) = stat_array(i,2)
for j=1 to num2
line_code(i,j) = cdbl(line_temp(j-1))
next
next
value_Max=0
for i=1 to num1
for j=1 to num2
if value_Max next
next
value_Max = cint(value_Max)
value_Max_str =cstr(value_Max)
if value_Max>9 then
temp=mid(value_Max_str,2,1)
if temp>4 then
temp2=(int(value_Max/(10^(len(value_Max_str)-1)))+1)*10^(len(value_Max_str)-1)
else
temp2=(int(value_Max/(10^(len(value_Max_str)-1)))+0.5)*10^(len(value_Max_str)-1)
end if
else
if value_Max>4 then temp2=10 else temp2=5
end if
item_hight = temp2/5
item_/(num2-1)
response.Write ""
response.Write " "
response.Write "
"
response.Write ""
response.Write " "
response.Write " "
response.Write "

"
response.Write " "
response.Write " "
response.Write " "
response.Write "
"&table_title&"
"
response.Write " "
response.Write " "
response.Write " "
response.Write " "
response.Write "
"
response.Write " "
response.Write " "
response.Write " "
response.Write "
"
for i=1 to num1
if i=1 then
displaystr=""
else
displaystr="none"
end if
response.Write "
"
response.Write " "
response.Write " "
response.Write "
"
response.Write " "
response.Write " "
response.Write "
"&stat_array(i,2)&"
"
response.Write "
"
response.Write "
"
next
response.Write " "
response.Write " "
response.Write " "
response.Write "
"&Y_unit&"
"
response.Write "
"
response.Write " "
response.Write "
"&X_unit&"
"
response.Write "
"
for i=0 to 4
response.Write " "
response.Write " "
response.Write " "
response.Write " "
response.Write " "
response.Write "
"
response.Write " "
response.Write "
"&item_hight*(5-i)&"
"
response.Write "
"
next
response.Write " "
response.Write " "
response.Write " "
for j=0 to num2-1
response.Write " "
response.Write " "
response.Write " "
response.Write " "
response.Write "
"&line_code(0,j+1)&"
"
response.Write "
"
next
for i=1 to num1
if i=1 then
displaystr=""
else
displaystr="none"
end if
response.Write "
"
for j=0 to num2-2
this_hight1 = cint(line_code(i,j+1)/(5*item_hight)*10000)
this_hight2 = cint(line_code(i,j+2)/(5*item_hight)*10000)
'线条样式
response.Write " "
response.Write " "
response.Write "
"
next
response.Write "
"
next
response.Write ""
end function
%>

热门栏目