教程中国
PHOTOSHOP CS9.0中文版 MAYA 8.5 FOR WINDOWS Corel Painter v9.0 Flash MX2004 中文版 Illustrator cs2 中文版
VC++6.0含sp6 中英文版 VB6.0 +sp6 简体中文版 Borland Delphi 7汉化版 MSDN for vb6.0中文版 Visual Studio 2005简体
教程中国下属 文件存储共享专家BIBIDU.COM 提供大型软件,教材,源码,电影,音乐,图书等下载 更多精品请点此进入
  您目前所在位置: 教程中国 >> 编程基地 >> ASP >> 用ASP及VML实现股票走势图 RSS订阅
用ASP及VML实现股票走势图
教程(视频,书籍)下载:  ASP.NET AutoCAD 数据库 C# ASP java photoshop 网页设计 delphi 3dmax Flash C++ VB 张孝祥 实例   更多请进入BIBIDU搜索
IT搜索引擎   
-->
<HTML XMLns:v>
<HEAD>
<STYLE>
v\:*{behavior:url(#default#VML);}
*{font-size:12px}
</STYLE>
</HEAD>
<BODY topmargin=0 leftmargin=0 bgcolor=#D7EEFF>

<DIV id=showdiv style="font-size:12px; Color:RED; DISPLAY: none; LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-LEFT: 2px; PADDING-RIGHT: 2px; PADDING-TOP: 2px; POSITION: absolute; TABLE-LAYOUT: fixed; TOP: 0px; WHITE-SPACE: nowrap; Z-INDEX: 500"></DIV>
<script language="javascript">
<!--
//加速alt,title的显示
var oldtext="abc";

function window.onload(){
try{myid2.height=window.document.body.scrollHeight}
catch(e){}
}

function document.onmousemove(){
try{
if(event.srcElement.getAttribute('onMOver')){
showdiv.style.left=event.x-3;showdiv.style.top=event.y+document.body.scrollTop+18;if(event.srcElement.onMOver!=oldtext){oldtext=event.srcElement.onMOver;showdiv.innerText=oldtext;showdiv.style.backgroundColor='#FFF6FF'};if(showdiv.style.display=='none')showdiv.style.display=''
if(showdiv.style.posLeft+300>screen.width){showdiv.style.posLeft=520}
}
else{
if(showdiv.style.display=='')showdiv.style.display='none';}
}
catch(e){}
}
//-->
</SCRIPT>

<?XML:namespace prefix=v />
<%
'连接数据库
set conn=Server.CreateObject("Adodb.Connection")
connStr="Provider=SQLOLEDB;Data Source=(local);database=DBName;uid=user;pwd=pass;"
conn.Open connStr

'初始化,定义变量
BoardID=int(Request("BoardID"))
if Request("BoardID")="" then BoardID=1
PicWidth=720
PicHeight=300

'显示股票列表下拉菜单
sql="Select * from Board where BoardID in (Select BoardID From Stocks)"
set RsBoard=conn.execute(sql)
StockStr="<select onchange=""location.replace('Trend.ASP?BoardID='+this.value)"">"
do while not RsBoard.eof
if RsBoard("BoardID")=BoardID then
ChkStr=" selected"
else
ChkStr=""
end if
StockStr=StockStr&"<option value="&RsBoard("BoardID")&ChkStr&">"&RsBoard("BoardName")&"</option>"
RsBoard.movenext
loop
set RsBoard=nothing
StockStr=StockStr&"<select>"
response.write StockStr

'打开股票走势表
sql="Select * from StocksTrend where BoardID="&BoardID&" and CalTime>getDate()-1 and Day(CalTime)=Day(getDate()) order by ID"
set rs=Server.CreateObject("Adodb.Recordset")
rs.Open sql,conn,1,1

'获取股票价格列表至数组,并计算最高最低价
Rec=rs.RecordCount
redim Price(Rec)
Highest=0
Lowest=9999
for i=1 to Rec
Price(i)=rs("Price")
if Price(i)>Highest then Highest=Price(i)
if Price(i)<Lowest then Lowest=Price(i)
rs.movenext
next
set rs=nothing

'画时间点,间隔6小时
for i=0 to 24 step 6
X=Round(i/24*PicWidth)
DrawLine X,PicHeight,X,PicHeight+5,"#808080"
Printword X,PicHeight+15,i&":00"
next

'画走势图边框
DrawLine 0,0,PicWidth,0,"#000000"
DrawLine 0,0,0,PicHeight,"#000000"
DrawLine PicWidth,0,PicWidth,PicHeight,"#000000"
DrawLine 0,PicHeight,PicWidth,PicHeight,"#000000"

'画四等分线
DrawLine 0,PicHeight*1/4,PicWidth,PicHeight*1/4,"#AAAAAA"
DrawLine 0,PicHeight*2/4,PicWidth,PicHeight*2/4,"#AAAAAA"
DrawLine 0,PicHeight*3/4,PicWidth,PicHeight*3/4,"#AAAAAA"

'标明四等分线价格
Printword PicWidth+15, 0/4*PicHeight, FormatNumber(Highest-(Highest-Lowest)*0/4,2,-1,0,0)
Printword PicWidth+15, 1/4*PicHeight, FormatNumber(Highest-(Highest-Lowest)*1/4,2,-1,0,0)
Printword PicWidth+15, 2/4*PicHeight, FormatNumber(Highest-(Highest-Lowest)*2/4,2,-1,0,0)
Printword PicWidth+15, 3/4*PicHeight, FormatNumber(Highest-(Highest-Lowest)*3/4,2,-1,0,0)
Printword PicWidth+15, 4/4*PicHeight, FormatNumber(Highest-(Highest-Lowest)*4/4,2,-1,0,0)

'画走势图
for i=1 to Rec
if i=1 then
SX=0
SY=0
else
SX=X
SY=Y
end if
Y=PicHeight-Round((Price(i)-Lowest)/(Highest-Lowest)*PicHeight)
X=Round((i-1)*5)
DrawPrice SX,SY,X,Y,Price(i),"#000000"
next

'自定义函数:画线
function DrawLine(SX,SY,X,Y,C)
%><v:line style="POSITION:absolute;LEFT:10;TOP:10" from="<%=SX%>,<%=SY%>" to="<%=X%>,<%=Y%>" strokecolor="<%=C%>" strokeweight="1pt"></v:line><%
response.write vbcrlf
end function

'自定义函数:画线(带alt提示功能)
function DrawPrice(SX,SY,X,Y,Price,C)
%><v:line onMOver="<%=Price%>" style="POSITION:absolute;LEFT:10;TOP:10" from="<%=SX%>,<%=SY%>" to="<%=X%>,<%=Y%>" strokecolor="<%=C%>" strokeweight="1pt"></v:line><%
response.write vbcrlf
end function

'显示文本(默认红色)
function Printword(X,Y,word)
%><SPAN style="LEFT:<%=X%>;TOP:<%=Y%>;COLOR:RED;FONT-FAMILY:宋体;POSITION:absolute"><%=word%></SPAN><%
response.write vbcrlf
end function
%>


来源:upschool.com.cn
作者:
关键字:用ASP
发表日期:2005-11-19

网页显示有限 阅读全文请下载本文完整版WORD文档

上一篇:获得汉字字符串的首字母   下一篇:图片下拉选择器的制作


2009-1-8 22:05:24
本文的相类似文章
  • 用ASP批量更新SQL SERVER数据.
  • 用ASP编写的俄罗斯方块游戏
  • linux上使用ASP
  • 用ASP、VB和XML建立互联网应用程序(1)
  • 用ASP、VB和XML建立互联网应用程序(2)
  • 用ASP、VB和XML建立互联网应用程序(3)
  • 用ASP、VB和XML建立互联网应用程序(4)
  • 使用ASP建立Http组件
  • 利用ASP.NET框架创建网站登陆
  • [图文]用ASP.NET在网页上显示缩略图
  • 在学习中进步 在进步中成长 教程中国相随您的成长之路
    华腾联合科技股份有限公司版权所有
    广告联系:Rosibo@163.com