不用任何控件的VML统计图(2)-柱状图
来源:互联网 发布:青年文摘知乎 编辑:程序博客网 时间:2024/06/05 23:56
/*未经许可,不得转载!
Email:zcwmxn@sina.com
作者:周长武
*/
<html xmlns:v="urn:schemas-microsoft-com:vml">
<HEAD>
<STYLE>
v/:* { BEHAVIOR: url(#default#VML) }
</STYLE>
<script language="JavaScript" type="text/javascript">
MAXVALUE = 87
function drawLinesX(m)
{
count=0; //画横坐标
var textPoint = MAXVALUE/5;
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;text-align :
left;font-weight :bold;left:100;top:"+(py-50)+";WIDTH:400px;HEIGHT:200px;z-index:8'
coordsize='21600,21600' fillcolor='white'></v:shape>")
group1.insertBefore(newShape);
if(count%9==0)
{
var newText = document.createElement("<v:textbox id='tx"+ MAXVALUE +"'
inset='0pt,0pt,0pt,0pt' style='font-size:10pt;v-text-anchor:bottom-right-
baseline'></v:textbox>");
newShape.insertBefore(newText);
newText.innerText = MAXVALUE;
}
}
else//虚线
{
if(count%3==1 & MAXVALUE%2 == 0)
{
var newShape= document.createElement("<v:shape style='position:absolute;text-align :
left;font-weight :bold;left:100;top:"+(py-50)+";WIDTH:400px;HEIGHT:200px;z-index:8'
coordsize='21600,21600' fillcolor='white'></v:shape>")
group1.insertBefore(newShape);
var newText = document.createElement("<v:textbox id='tx"+ MAXVALUE/2 +"'
inset='0pt,0pt,0pt,0pt' style='font-size:10pt;v-text-anchor:bottom-right-
baseline'></v:textbox>");
newShape.insertBefore(newText);
newText.innerText = MAXVALUE/2;
}
var newStroke = document.createElement("<v:stroke dashstyle='dot' color='black'/>");
newLine.insertBefore(newStroke);
}
count++;
}
}
function drawLinesY(NameGroups,EveryValues)
{
var textPoint=1;
Name = NameGroups.split(",")
GROUPCOUNT = Name.length
for(var i=1;i<=GROUPCOUNT;i++){//为计算方便,i 从1开始
var py= 170 + i * 4200/GROUPCOUNT;
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='white-space:
nowrap;position:absolute;text-align:left;left:"+((i-1) * 4200/GROUPCOUNT +
(4200/2/GROUPCOUNT))+";top:2750;WIDTH:410px;HEIGHT:150px;z-index:18' coordsize='21600,21600'
fillcolor='white'></v:shape>")
group1.insertBefore(newShape);
var newText = document.createElement("<v:textbox id='ty"+Name[i-1]+"'
inset='3pt,0pt,3pt,0pt' style='font-size:9pt;v-text-anchor:bottom-right-
baseline'></v:textbox>");
newShape.insertBefore(newText);
newText.innerHTML=Name[i-1];
}
value = EveryValues.split(",")
for(var i=1;i<=value.length;i++)
drawBar(value[i-1],i,Name[i-1],i);
}
function drawBar(heighValue,t,departName,i)
{
var h = 2450 * (heighValue/MAXVALUE) - 50;
var px = 2750 - 2450 * (heighValue/MAXVALUE);
var py = (t-1) * 4200/GROUPCOUNT + (4200/2/GROUPCOUNT); //170 + (t-1) * 4200/n 表示每个
点开始的坐标,(4200/2/n)表示中间位置
var newShape= document.createElement("<v:rect style='border:0px solid
red;position:absolute;left:"+py+";top:"+px+";WIDTH:190px;HEIGHT:"+h+"px;z-index:9'
coordsize='21600,21600' fillcolor='#0099CC'></v:rect>")
group1.insertBefore(newShape);
var newShape= document.createElement("<v:shape style='white-space:
nowrap;position:absolute;text-align:left;left:"+ ( py+40) +";top:" + (px - 70)+
";WIDTH:410px;HEIGHT:150px;z-index:10' coordsize='21600,21600'></v:shape>")
group1.insertBefore(newShape);
var newText = document.createElement("<v:textbox id='ty"+Name[i-1]+"'
inset='3pt,0pt,3pt,0pt' style='font-size:9pt;v-text-anchor:bottom-right-baseline;font-
weight:bold'></v:textbox>");
newShape.insertBefore(newText);
newText.innerHTML=heighValue;
}
</script>
</HEAD>
<BODY>
<v:group ID="group1" style="WIDTH:800px;HEIGHT:500px" coordsize="4900,3000">
<v:line from="200,100" to="200,2700" style="Z-INDEX:8;POSITION:absolute"
strokeweight="1pt">
<v:stroke StartArrow="classic"/>
<v:shape style='position:absolute;text-align:left;font-weight:bold;left:10;white-space:
nowrap; top:0;z-index:8;' coordsize='21600,21600' fillcolor='white'>
<v:textbox inset='0pt,0pt,0pt,0pt'>需求数量</v:textbox>
</v:shape>
</v:line>
<v:line from="200,2700" to="4500,2700" style="Z-INDEX:8;POSITION:absolute"
strokeweight="1pt">
<v:stroke EndArrow="classic"/>
<v:shape style='position:absolute;text-align:left;font-weight:bold;left:680;white-space:
nowrap; top:14;z-index:8;' coordsize='21600,21600'>
<v:textbox inset='0pt,0pt,0pt,0pt'>部门</v:textbox>
</v:shape>
</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:rect>
<v:shape style='position:absolute;text-align:left;font-weight:bold;left:23;white-space:
nowrap; top:387px;' coordsize='21600,21600'>
<v:textbox inset='0pt,0pt,0pt,0pt'>0</v:textbox>
</v:shape>
<v:shape style="position:absolute;left:50;top:2650;WIDTH:1000px;HEIGHT:200px;z-index:8"
coordsize="21600,21600" fillcolor="white"/>
</v:group>
<br>
</BODY>
<script language="javascript" type="text/javascript">
drawLinesX(4350);
var xxx = "项目1,项目2,项目3,项目4,项目5,项目6"
var yyy = "13,28,87,32,56,2"
drawLinesY(xxx,yyy)
</script>
</HTML>
- 不用任何控件的VML统计图(2)-柱状图
- 不用任何控件的VML统计图(1)-饼图
- 不用任何控件的VML统计图(3)-折线图
- 用asp+vml实现的立体统计图(一)-----柱状图
- c#做的控件—用vml生成柱状图
- Android 柱状图 统计图的实现
- 简易的饼状图,柱状图,统计图
- VML-柱状图
- ASP+VML制作统计图的源程序
- ASP+VML制作统计图的源程序
- ASP+VML制作统计图的源程序
- ASP+VML制作统计图的源程序
- VML+Javascript实现的垂直柱状统计图
- VML+Javascript实现的垂直柱状统计图
- VML + VB实现线形统计图(2)
- vml 的饼图柱状图和线图
- asp+VML统计图
- 使用 Vml 制作立体柱状投票统计图的完整程序
- SOA实现八大陷阱
- WPF和Silverlight到底有什麼不同?
- Delphi程序员如何找到高薪的工作?[转]
- DIY狂人自制3D打印机 可打印食物
- 为什么有时Oracle 数据库不用索引来查找数据?
- 不用任何控件的VML统计图(2)-柱状图
- 网络会员制营销模式的七项功能
- ASP.NET 弹出对话框和页面之间传递值的经验总结
- 不用任何控件的VML统计图(3)-折线图
- linux上删除oracle数据库
- Java标准版的EJB Persistence(二)
- 一片天空
- Notepad++ v4.7.4
- 第十一課 文法