ASP+VML自动生成实时行情走势图

数据库为 test.mdb,其中表[pric]记录某段时期的商品和价格信息(假设每天收集一次各商品的价格)

该表包括如下几个字段
price(价格) shang_id(对应的商品ID) p_time(该价格的时间);具体数据请自行输入;现根据该价格信息生成某商品在某年某月的价格行情走势图(曲线图,非柱状图)。


<!--tu.asp开始-->
<% if request("tyr")="" or request("tmon")="" or request("shid")="" or not isnumeric(request("tyr")) or not isnumeric(request("tmon")) or not isnumeric(request("shid")) then
response.write "参数错误,请确认您输入了正确的网址。"
response.end
end if
dim conn,constr,db
db="test.mdb"
set conn=Server.CreateObject("ADODB.Connection")
constr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &server.MapPath(db)
conn.open constr
if err then
  err.clear
  conn.close
  set conn=nothing
  response.write "暂时无法访问数据库,请稍候再试。"
  response.end
end if

'以上为连接数据库部分

set rstemp=conn.execute("select top 1 price,p_time from [pric] where shang_id="&request("shid")&" and year(p_time)="&request("tyr")&" and month(p_time)="&request("tmon")&" order by price desc")
ttop=rstemp(0)
set rs=server.createobject("adodb.recordset")
sql="select price,p_time,shang_id from [pric] where shang_id="&request("shid")&" and year(p_time)="&request("tyr")&" and month(p_time)="&request("tmon")&""
rs.open sql,conn,1,1
i=0
do while not rs.eof and i<=31
pric=rs("price")
i=i+1
k=200+80*i
j=cint(2200-(pric/ttop)*2000)
tzb=tzb&k&","&j&" "
rs.movenext
loop %>
<html xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<title>行情图</title>
<STYLE>
v/:* { Behavior: url(#default#VML) }
</STYLE>
</head>
<body topmargin="0" leftmargin="0">
<v:group ID="group1" style="WIDTH:240pt;HEIGHT:300pt" coordsize="2400,3000">
<v:line from="200,100" to="200,2100" style="Z-INDEX:8;POSITION:absolute" strokeweight="1pt">
<v:stroke StartArrow="classic"/>
</v:line>
<v:line from="200,2100" to="2680,2100" style="Z-INDEX:8;POSITION:absolute" strokeweight="1pt">
<v:stroke EndArrow="classic"/>
</v:line>
<v:rect style="WIDTH:3000px;HEIGHT:2400px" coordsize="21600,21600" fillcolor="white" strokecolor="black" />
<v:PolyLine filled="false" Points="<%=tzb%>" style="position:relative"/>
<v:stroke StartArrow="Oval" EndArrow="Classic" dashstyle="Dot" />
</v:PolyLine>
</group>
</body>
</html>
<!--tu.asp结束-->

该页网址后应跟上相应的参数tyr;tmon;shid分边表示所查询的年、月以及商品ID;例如:
test.asp?tyr=2004&tmon=10&shid=1
表示所查询的是ID为1的商品于2004年10月的价格走势图。

最终的图形显示效果如下:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值