柱状图的VML显示效果,很有意思的哟 - 中国WEB开发者网络 (http://www.webasp.net) -- 网页特效 (http://www.webasp.net/javascript/) --- 柱状图的VML显示效果,很有意思的哟 (http://www.webasp.net/javascript/1/720.htm) |
| -- 发布日期: 2005-07-01 |
| <!-- 网页特效代码由[中国WEB开发者网络:http://www.ChinaWebDev.com]提供! --> <!-- 要实现此效果需要 1 个步骤: --> <!-- 第 1 步: --> <!-- 把下面的代码加到<BODY></BODY>区域中: --> <center><font color=red face="隶书" size=6>VML赏析一</font></center> <BR> <STYLE> v\:* { BEHAVIOR: url(#default#VML) } </STYLE> <center> <script> function drawLinesX(m) { count=0; //画横坐标 var textPoint=1; for(var i=1;i<=10;i++){ var py=2750-i*245; var strTo=m+" "+py; var newLine = document.createElement("<v:line from='200 "+py+"' to='"+strTo+"' style='position:absolute;z-index:8'></v:line>"); group1.insertBefore(newLine); if(count%2!=0){ var newStroke = document.createElement("<v:stroke color='#c0c0c0'>"); newLine.insertBefore(newStroke); var newShape= document.createElement("<v:shape style='position:absolute;left:0;top:"+(py-50)+";WIDTH:1000px;HEIGHT:200px;z-index:8' coordsize='21600,21600' fillcolor='white'></v:shape>") group1.insertBefore(newShape); var newText = document.createElement("<v:textbox id='tx"+textPoint+"' inset='3pt,0pt,3pt,0pt' style='font-size:10pt;v-text-anchor:bottom-right-baseline'></v:textbox>"); newShape.insertBefore(newText); newText.innerText=textPoint; textPoint++; } else { var newStroke = document.createElement("<v:stroke dashstyle='dot' color='black'/>"); newLine.insertBefore(newStroke); } count++; } } function drawLinesY(n) { var textPoint=1; for(var i=1;i<=n;i++){ var py=170+i*300; var newLine = document.createElement("<v:line from='"+py+" 2700' to='"+py+" 2750' style='position:absolute;z-index:8'></v:line>"); group1.insertBefore(newLine); var newStroke = document.createElement("<v:stroke color='black'>"); newLine.insertBefore(newStroke); var newShape= document.createElement("<v:shape style='position:absolute;left:"+(py-50)+";top:2750;WIDTH:200px;HEIGHT:150px;z-index:8' coordsize='21600,21600' fillcolor='white'></v:shape>") group1.insertBefore(newShape); var newText = document.createElement("<v:textbox id='ty"+textPoint+"' inset='3pt,0pt,3pt,0pt' style='font-size:9pt;v-text-anchor:bottom-right-baseline'></v:textbox>"); newShape.insertBefore(newText); newText.innerHTML=textPoint; textPoint++; } } function drawBar(v,t) { var h=v*245-50; var px=2750-v*245; var py=170+t*300; var newShape= document.createElement("<v:rect style='position:absolute;left:"+py+";top:"+px+";WIDTH:190px;HEIGHT:"+h+"px;z-index:9' coordsize='21600,21600' fillcolor='blue'></v:rect>") group1.insertBefore(newShape); } function drawBars() { drawBar(6,1); drawBar(5,2); drawBar(6,3); drawBar(8,4); drawBar(3,5); drawBar(1,6); drawBar(9,7); drawBar(2,8); drawBar(6,9); drawBar(5,10); drawBar(7,11); drawBar(3,12); } </script> <body onload="drawLinesX(4500);drawLinesY(13)"> <button onclick="drawBars()">显示柱状图</button><br><br> <v:group ID="group1" style="WIDTH:700px;HEIGHT:500px" coordsize="4900,3500"> <v:line from="200,100" to="200,2700" style="Z-INDEX:8;POSITION:absolute" strokeweight="1pt"> <v:stroke StartArrow="classic"/> </v:line> <v:line from="200,2700" to="4500,2700" style="Z-INDEX:8;POSITION:absolute" strokeweight="1pt"> <v:stroke EndArrow="classic"/> </v:line> <v:rect style="WIDTH:4600px;HEIGHT:2900px" coordsize="21600,21600" fillcolor="white" strokecolor="black"> <v:shadow on="t" type="single" color="silver" offset="4pt,3pt"></v:shadow> </v:rect> <v:shape style="position:absolute;left:50;top:2650;WIDTH:1000px;HEIGHT:200px;z-index:8" coordsize="21600,21600" fillcolor="white"> <v:textbox id="text1" inset="3pt,0pt,3pt,0pt" align="center" style="font-size:10pt;v-text-anchor:bottom-center-baseline">0</v:textbox> </v:shape> </v:group><br> |
| webasp.net |