有谁能将此vbscript的函数翻成javascript,功德无量啊!

l_kk 2003-09-17 06:59:11
看到一篇好贴子,是用vbscript写的柱型体,折线图,饼图函数,谁来将他翻成javascript呀,可以方便大家调用。
http://expert.csdn.net/Expert/TopicView1.asp?id=2143612
...全文
55 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
l_kk 2003-09-23
  • 打赏
  • 举报
回复
好的。结贴,接分!

l_kk 2003-09-22
  • 打赏
  • 举报
回复
awaysrain(绝对零度) :我把饼图的照着你的样子翻了一下,调用的时候没报错,但也没出来效果——什么也没有,一片空白,帮我看看吧。
另:龚鸣(Passwordgm),谢谢你,就算是经你同意了,好么?:)。

pie.js
=============================================================================
function table3(total,table_x,table_y,all_width,all_height,table_type){
//'参数含义(传递的数组,横坐标,纵坐标,图表的宽度,图表的高度,图表的类型)
//'纯ASP代码生成图表函数3——饼图
//'作者:龚鸣(Passwordgm) QQ:25968152 MSN:passwordgm@sina.com Email:passwordgm@sina.com
//'本人非常愿意和ASP,VML,FLASH的爱好者在HTTP://topclouds.126.com进行交流和探讨
//'版本1.0 最后修改日期 2003-8-11
//'非常感谢您使用这个函数,请您使用和转载时保留版权信息,这是对作者工作的最好的尊重。
var tb_height=30;

var tmdColor1 = new Array();

tmdColor1[0] = "#d1ffd1";
tmdColor1[1] = "#ffbbbb";
tmdColor1[2] = "#ffe3bb";
tmdColor1[3] = "#cff4f3";
tmdColor1[4] = "#d9d9e5";
tmdColor1[5] = "#ffc7ab";
tmdColor1[6] = "#ecffb7";
tmdColor1[7] = "#d1ffd1";
tmdColor1[8] = "#ffbbbb";
tmdColor1[9] = "#ffe3bb";
tmdColor1[10] = "#cff4f3";
tmdColor1[11] = "#d9d9e5";
tmdColor1[12] = "#ffc7ab";
tmdColor1[13] = "#ecffb7";

var tmdColor2 = new Array();

tmdColor2[0] = "#00ff00";
tmdColor2[1] = "#ff0000";
tmdColor2[2] = "#ff9900";
tmdColor2[3] = "#33cccc";
tmdColor2[4] = "#666699";
tmdColor2[5] = "#993300";
tmdColor2[6] = "#99cc00";
tmdColor2[7] = "#00ff00";
tmdColor2[8] = "#ff0000";
tmdColor2[9] = "#ff9900";
tmdColor2[10] = "#33cccc";
tmdColor2[11] = "#666699";
tmdColor2[12] = "#993300";
tmdColor2[13] = "#99cc00";

var tb_color = new Array(tmdColor1,tmdColor2);

var total_no = total[0].length;
var totalpie=0;
for(var i=1; i<total_no;i++)
{
totalpie=totalpie+total[i][1];
}

var PreAngle=0;
for (var i=1; i<total_no;i++)
{
document.write( "<v:shape id='_x0000_s1025' alt='' style='position:absolute;left:"+table_x+"px;top:"+table_y+"px;width:"+all_width+"px;height:"+all_height+"px;z-index:1' coordsize='1500,1400' o:spt='100' adj='0,,0' path='m750,700ae750,700,750,700,"+int(23592960*PreAngle)+","+int(23592960*total[i][1]/totalpie)+"xe' fillcolor='"+tb_color[i][1]+"' strokecolor='#FFFFFF'><v:fill color2='"+tb_color[i][2]+"' rotate='t' focus='100%' type='gradient'/><v:stroke joinstyle='round'/><v:formulas/><v:path o:connecttype='segments'/></v:shape>"+CHR(13))
var PreAngle=PreAngle+total[i][1]/totalpie;
}

if (table_type=="A") {
document.write( "<v:rect id='_x0000_s1025' style='position:absolute;left:"+(table_x+all_width+20)+"px;top:"+(table_y+20)+"px;width:100px;height:"+(total_no*tb_height+20)+"px;z-index:1'/>");
for (var i=1; i<total_no;i++)
{
document.write( "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"+(table_x+all_width+25)+"px;top:"+(table_y+30+(i-1)*tb_height)+"px;width:60px;height:"+tb_height+"px;z-index:1'>");
document.write( "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>"+total[i][0]+"</td></tr></table></v:textbox></v:shape>");
document.write( "<v:rect id='_x0000_s1040' alt='' style='position:absolute;left:"+(table_x+all_width+80)+"px;top:"+(table_y+30+(i-1)*tb_height+3)+"px;width:30px;height:20px;z-index:1' fillcolor='"+tb_color[i][1]+"'><v:fill color2='"+tb_color[i][2]+"' rotate='t' focus='100%' type='gradient'/></v:rect>");
//'显示比例数
//' document.write( "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"+table_x+all_width+110+"px;top:"+table_y+30+(i-1)*tb_height+"px;width:60px;height:"+tb_height+"px;z-index:1'>"
//' document.write( "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>"+formatnumber(total[i][1]*100/totalpie,2,-1)+"%</td></tr></table></v:textbox></v:shape>");
}//end for
}//end if

if (table_type=="B")
{
var pie=3.14159265358979;
var TempPie=0;
for (var i=1; i<total_no;i++)
{
TempAngle=pie*2*(total[i][1]/(TotalPie*2)+TempPie);
var x1=table_x+all_width/2+cos(TempAngle)*all_width*3/8;
var y1=table_y+all_height/2-sin(TempAngle)*all_height*3/8;
var x2=table_x+all_width/2+cos(TempAngle)*all_width*3/4;
var y2=table_y+all_height/2-sin(TempAngle)*all_height*3/4;
if (x2>table_x+all_width/2)
{
var x3=x2+20;
var x4=x3;
}
else
{
var x3=x2-20;
var x4=x3-100;
}

document.write( "<v:oval id='_x0000_s1027' style='position:absolute;left:"+x1-2+"px;top:"+y1-2+"px;width:4px;height:4px; z-index:2' fillcolor='#111111' strokecolor='#111111'/>"+CHR(13));
document.write( "<v:line id='_x0000_s1025' alt='' style='position:absolute;left:0;text-align:left;top:0;z-index:1' from='"+x1+"px,"+y1+"px' to='"+x2+"px,"+y2+"px' coordsize='21600,21600' strokecolor='#111111' strokeweight='1px'></v:line>");
document.write( "<v:line id='_x0000_s1025' alt='' style='position:absolute;left:0;text-align:left;top:0;z-index:1' from='"+x2+"px,"+y2+"px' to='"+x3+"px,"+y2+"px' coordsize='21600,21600' strokecolor='#111111' strokeweight='1px'></v:line>");
document.write( "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"+x4+"px;top:"+y2-10+"px;width:100px;height:20px;z-index:1'>");
document.write( "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>"+total[i][0]+" "+formatnumber(total[i][1]*100/totalpie,2,-1)+"%</td></tr></table></v:textbox></v:shape>");
TempPie=TempPie+total[i][1]/TotalPie;
}//end for
}//end if

}//end fuction()

======================================================
调用页面
========================================================
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<!--[if !mso]>
<style>
v\:* { behavior: url(#default#VML) }
o\:* { behavior: url(#default#VML) }
.shape { behavior: url(#default#VML) }
</style>
<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script src="pie.js"></script>
<title></title>
<style>
TD { FONT-SIZE: 9pt}
</style></head>
<body topmargin=5 leftmargin=0 scroll=AUTO>
<script language=javascript>
var dataArray = new Array()
dataArray[0]=200
dataArray[1]=800
dataArray[2]=1000
dataArray[3]=600
dataArray[4]=1222
dataArray[5]=3213
dataArray[6]=8
var nameArray = new Array()
nameArray[0]="中国经营报"
nameArray[1]="招聘网"
nameArray[2]="51Job"
nameArray[3]="新民晚报"
nameArray[4]="新闻晚报"
nameArray[5]="南方周末"
nameArray[6]="羊城晚报"
var total= new Array(dataArray,nameArray)
table3(total,200,20,30,40,"A");
</script>
</body>
</html>
awaysrain 2003-09-22
  • 打赏
  • 举报
回复
修改完成,到这里去看代码吧

http://expert.csdn.net/Expert/topic/2287/2287838.xml?temp=.9312708
l_kk 2003-09-22
  • 打赏
  • 举报
回复
awaysrain(绝对零度):测试通过,谢谢!
好的,等你的代码。
awaysrain 2003-09-22
  • 打赏
  • 举报
回复
饼图的我已经修改好了,你看看有什么错误
如果你不是很着急的话就等一等,我全修改好后会把代码贴上来的
==========================================================
<script language=javascript>
function table3(total,table_x,table_y,all_width,all_height,table_type)
{
//参数含义(传递的数组,横坐标,纵坐标,图表的宽度,图表的高度,图表的类型)
//纯ASP代码生成图表函数3——饼图
//作者:龚鸣(Passwordgm) QQ:25968152 MSN:passwordgm@sina.com Email:passwordgm@sina.com
//本人非常愿意和ASP,VML,FLASH的爱好者在HTTP://topclouds.126.com进行交流和探讨
//版本1.0 最后修改日期 2003-8-11
//非常感谢您使用这个函数,请您使用和转载时保留版权信息,这是对作者工作的最好的尊重。

var tmdColor1 = new Array();

tmdColor1[0] = "#d1ffd1";
tmdColor1[1] = "#ffbbbb";
tmdColor1[2] = "#ffe3bb";
tmdColor1[3] = "#cff4f3";
tmdColor1[4] = "#d9d9e5";
tmdColor1[5] = "#ffc7ab";
tmdColor1[6] = "#ecffb7";

var tmdColor2 = new Array();

tmdColor2[0] = "#00ff00";
tmdColor2[1] = "#ff0000";
tmdColor2[2] = "#ff9900";
tmdColor2[3] = "#33cccc";
tmdColor2[4] = "#666699";
tmdColor2[5] = "#993300";
tmdColor2[6] = "#99cc00";

var tb_color = new Array(tmdColor1,tmdColor2);
var tb_height = 30;
var total_no = total[0].length;
var totalpie = 0;
for(var i=0;i<total_no;i++)
{
totalpie += total[1][i];
}
var PreAngle = 0;
for(var i=0;i<total_no;i++)
{
document.write("<v:shape id='_x0000_s1025' alt='' style='position:absolute;left:" + table_x + "px;top:" + table_y + "px;width:" + all_width + "px;height:" + all_height + "px;z-index:1' coordsize='1500,1400' o:spt='100' adj='0,,0' path='m750,700ae750,700,750,700," + parseInt(23592960*PreAngle) + "," + parseInt(23592960*total[1][i]/totalpie) + "xe' fillcolor='" + tb_color[0][i] + "' strokecolor='#FFFFFF'><v:fill color2='" + tb_color[1][i] + "' rotate='t' focus='100%' type='gradient'/><v:stroke joinstyle='round'/><v:formulas/><v:path o:connecttype='segments'/></v:shape>");
PreAngle += total[1][i] / totalpie;
}

if(table_type=="A")
{
document.write("<v:rect id='_x0000_s1025' style='position:absolute;left:" + (table_x + all_width + 20) + "px;top:" + (table_y + 20) + "px;width:100px;height:" + (total_no * tb_height + 20) + "px;z-index:1'/>");
for(var i=0;i<total_no;i++)
{
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (table_x + all_width + 25) + "px;top:" + (table_y+30+(i)*tb_height) + "px;width:60px;height:" + tb_height + "px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
document.write("<v:rect id='_x0000_s1040' alt='' style='position:absolute;left:" + (table_x + all_width + 80) + "px;top:" + (table_y + 30 + (i)*tb_height+3) + "px;width:30px;height:20px;z-index:1' fillcolor='" + tb_color[0][i] + "'><v:fill color2='" + tb_color[1][i] + "' rotate='t' focus='100%' type='gradient'/></v:rect>");
//显示比例数
//document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (table_x+all_width+110) + "px;top:" + (table_y+30+(i)*tb_height) + "px;width:60px;height:" + tb_height + "px;z-index:1'>");
//document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>" + Math.round(parseFloat(total[1][i]*100/totalpie)*100)/100 + "%</td></tr></table></v:textbox></v:shape>");
}
}

if(table_type == "B")
{
var pie = 3.14159265358979;
var TempPie = 0;
for(var i=0;i<total_no;i++)
{
var TempAngle = pie * 2 * (total[1][i] / (totalpie * 2) + TempPie);
var x1 = table_x + all_width/2 + Math.cos(TempAngle) * all_width * 3/8;
var y1 = table_y + all_height/2 - Math.sin(TempAngle) * all_height * 3/8;
var x2 = table_x + all_width/2 + Math.cos(TempAngle) * all_width * 3/4;
var y2 = table_y + all_height/2 - Math.sin(TempAngle) * all_height * 3/4;

if(x2>table_x + all_width/2)
{
x3 = x2 + 20;
x4 = x3;
}
else
{
x3 = x2 - 20;
x4 = x3 - 100;
}
document.write("<v:oval id='_x0000_s1027' style='position:absolute;left:" + (x1 - 2) + "px;top:" + (y1 - 2) + "px;width:4px;height:4px; z-index:2' fillcolor='#111111' strokecolor='#111111'/>");
document.write("<v:line id='_x0000_s1025' alt='' style='position:absolute;left:0;text-align:left;top:0;z-index:1' from='" + x1 + "px," + y1 + "px' to='" + x2 + "px," + y2 + "px' coordsize='21600,21600' strokecolor='#111111' strokeweight='1px'></v:line>");
document.write("<v:line id='_x0000_s1025' alt='' style='position:absolute;left:0;text-align:left;top:0;z-index:1' from='" + x2 + "px," + y2 + "px' to='" + x3 + "px," + y2 + "px' coordsize='21600,21600' strokecolor='#111111' strokeweight='1px'></v:line>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + x4 + "px;top:" + (y2 - 10) + "px;width:100px;height:20px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>" + total[0][i] + " " + Math.round(parseFloat(total[1][i] * 100/ totalpie)*100)/100 + "%</td></tr></table></v:textbox></v:shape>")
TempPie += total[1][i]/totalpie;
}
}
}
</script>
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<!--[if !mso]>
<style>
v\:* { behavior: url(#default#VML) }
o\:* { behavior: url(#default#VML) }
.shape { behavior: url(#default#VML) }
</style>
<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style>
TD { FONT-SIZE: 9pt}
</style></head>
<body topmargin=5 leftmargin=0 scroll=AUTO>

<script language=javascript>
var dataArray = new Array()
dataArray[0]=200
dataArray[1]=1200
dataArray[2]=900
dataArray[3]=600
dataArray[4]=1222
dataArray[5]=413
dataArray[6]=800
var nameArray = new Array()
nameArray[0]="中国经营报"
nameArray[1]="招聘网"
nameArray[2]="51Job"
nameArray[3]="新民晚报"
nameArray[4]="新闻晚报"
nameArray[5]="南方周末"
nameArray[6]="羊城晚报"
var total= new Array(nameArray,dataArray)

table3(total,200,40,250,250,"A");
table3(total,300,450,250,250,"B");
</script>
</body>
</html>


l_kk 2003-09-22
  • 打赏
  • 举报
回复
up
l_kk 2003-09-19
  • 打赏
  • 举报
回复
出来了,真高兴!我的IE也是6。0的,昨天不知为何出不来,我看看原因。谢谢awaysrain(绝对零度)!!!
awaysrain 2003-09-19
  • 打赏
  • 举报
回复
我试了,IE5也通过
awaysrain 2003-09-19
  • 打赏
  • 举报
回复
我这里IE6通过,我找个个IE5看看
===========================================
table1_A.js
===========================================



function table1(total,table_x,table_y,thickness,table_width,all_width,all_height,table_type){
//参数含义(传递的数组,横坐标,纵坐标,柱子的厚度,柱子的宽度,图表的宽度,图表的高度,图表的类型)
//纯ASP代码生成图表函数1——柱状图
//作者:龚鸣(Passwordgm) QQ:25968152 MSN:passwordgm@sina.com Email:passwordgm@sina.com
//本人非常愿意和ASP,VML,FLASH的爱好者在HTTP://topclouds.126.com进行交流和探讨
//版本2.0 最后修改日期 2003-7-22
//非常感谢您使用这个函数,请您使用和转载时保留版权信息,这是对作者工作的最好的尊重。

//======================================================================================
//经作者同意,awaysrain(绝对零度)2003年9月18日修改为JavaScript,
//======================================================================================

var tmdColor1 = new Array();

tmdColor1[0] = "#d1ffd1";
tmdColor1[1] = "#ffbbbb";
tmdColor1[2] = "#ffe3bb";
tmdColor1[3] = "#cff4f3";
tmdColor1[4] = "#d9d9e5";
tmdColor1[5] = "#ffc7ab";
tmdColor1[6] = "#ecffb7";

var tmdColor2 = new Array();

tmdColor2[0] = "#00ff00";
tmdColor2[1] = "#ff0000";
tmdColor2[2] = "#ff9900";
tmdColor2[3] = "#33cccc";
tmdColor2[4] = "#666699";
tmdColor2[5] = "#993300";
tmdColor2[6] = "#99cc00";

var tb_color = new Array(tmdColor1,tmdColor2);
var line_color = "#69f";
var left_width = 70;
var length = thickness/2;
var total_no = total[0].length;
var temp1 = 0;
var temp2,temp4,temp4;

for(var i = 0;i<total_no;i++)
{
if(temp1<total[0][i])
{
temp1 = total[0][i];
}
}

temp1 = parseInt(temp1.toString());

if(temp1>9)
{
temp2 = temp1.toString().substr(1,1)
if(temp2>4)
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+1)*Math.pow(10,(temp1.toString().length-1));
}
else
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+0.5)*Math.pow(10,(temp1.toString().length-1));
}
}
else
{
if(temp1>4)
temp3 = 10;
else
temp3 = 5;
}

temp4=temp3
document.write("<!--[if gte vml 1]><v:rect id='_x0000_s1027' alt='' style='position:absolute;left:" + (table_x+left_width) + "px;top:" + table_y + "px;width:" + all_width + "px;height:" + all_height + "px;z-index:-1' fillcolor='#9cf' stroked='f'><v:fill rotate='t' angle='-45' focus='100%' type='gradient'/></v:rect><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + (table_y+all_height) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + table_y + "px' to='" + (table_x+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");

switch (table_type)
{
case "A":

var table_space = (all_width-table_width*total_no)/total_no;
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px,"+ table_y + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-length) + "px' strokecolor='" + line_color + "'/><![endif]-->");

for(var i=0;i<=all_height-1;i+= all_height/5)
{
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width)+ "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-i) +"px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height-length-i) + "px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+(left_width-15)) + "px," + (table_y+i) + "px' to='" + (table_x+left_width) + "px," + (table_y+i) + "px'/><![endif]-->");
document.write("<!--[if gte vml 1]>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + table_x + "px;top:" + (table_y+i) + "px;width:" + left_width + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>" + temp4 + "</td></tr></table></v:textbox></v:shape><![endif]-->");
temp4 = temp4-temp3/5;
}
for(var i=0;i<total_no;i++)
{
var temp_space = table_x + left_width + table_space/2 + table_space * (i) + table_width*(i);
document.write("<v:rect id='_x0000_s1025' alt='' style='position:absolute;left:");
document.write(temp_space);
document.write("px;top:");
document.write(table_y+all_height*(1-(total[0][i]/temp3)));
document.write("px;width:" + table_width + "px;height:" + all_height*(total[0][i]/temp3) + "px;z-index:1' fillcolor='" + tb_color[1][i] + "'>");
document.write("<v:fill color2='" + tb_color[0][i] + "' rotate='t' type='gradient'/>")
document.write("<o:extrusion v:ext='view' backdepth='" + thickness + "pt' color='" + tb_color[1][i] + "' on='t'/>");
document.write("</v:rect>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + temp_space + "px;top:" + (table_y+all_height*(1-(total[0][i]/temp3))-table_width) + "px;width:" + (table_space+15) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (temp_space-table_space/2) + "px;top:" + (table_y+all_height+1) + "px;width:" + (table_space+table_width) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[1][i] + "</td></tr></table></v:textbox></v:shape>");
}
break;
}
}

====================================================
调用页面
====================================================
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<!--[if !mso]>
<style>
v\:* { behavior: url(#default#VML) }
o\:* { behavior: url(#default#VML) }
.shape { behavior: url(#default#VML) }
</style>
<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script src="table1_A.js"></script>
<title></title>
<style>
TD { FONT-SIZE: 9pt}
</style></head>
<body topmargin=5 leftmargin=0 scroll=AUTO>
<script language=javascript>
var dataArray = new Array()
dataArray[0]=200
dataArray[1]=800
dataArray[2]=1000
dataArray[3]=600
dataArray[4]=1222
dataArray[5]=3213
dataArray[6]=8
var nameArray = new Array()
nameArray[0]="中国经营报"
nameArray[1]="招聘网"
nameArray[2]="51Job"
nameArray[3]="新民晚报"
nameArray[4]="新闻晚报"
nameArray[5]="南方周末"
nameArray[6]="羊城晚报"
var total= new Array(dataArray,nameArray)
table1(total,200,20,20,30,400,200,"A");
</script>
</body>
</html>
l_kk 2003-09-18
  • 打赏
  • 举报
回复
有人么???
bullion 2003-09-18
  • 打赏
  • 举报
回复
楼主,那就要看你的本事了
l_kk 2003-09-18
  • 打赏
  • 举报
回复
对,是VML,但他是用vbscript生成的VML脚本,我是想谁来用javascript把他翻一下。
blues-star 2003-09-18
  • 打赏
  • 举报
回复
其实,那个是VML,
l_kk 2003-09-18
  • 打赏
  • 举报
回复
我这里运行错误,怎么回事?
将此代码保存为bar.html,运行时显示:
a runtime error has occurred,do you wish to debug? Line 1,Error:语法错误
=======================================================
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<!--[if !mso]>
<style>
v\:* { behavior: url(#default#VML) }
o\:* { behavior: url(#default#VML) }
.shape { behavior: url(#default#VML) }
</style>
<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style>
TD { FONT-SIZE: 9pt}
</style></head>
<body topmargin=5 leftmargin=0 scroll=AUTO>
<script src="a.js"></script>
<script language=javascript>
var dataArray = new Array()
dataArray[0]=200
dataArray[1]=800
dataArray[2]=1000
dataArray[3]=600
dataArray[4]=1222
dataArray[5]=3213
dataArray[6]=8
var nameArray = new Array()
nameArray[0]="中国经营报"
nameArray[1]="招聘网"
nameArray[2]="51Job"
nameArray[3]="新民晚报"
nameArray[4]="新闻晚报"
nameArray[5]="南方周末"
nameArray[6]="羊城晚报"
var total= new Array(dataArray,nameArray)
table1(total,200,20,20,30,400,200,"A");
</script>
</body>
</html>
l_kk 2003-09-18
  • 打赏
  • 举报
回复
对,对,得经作者同意。欧先尝尝鲜!谢谢awaysrain(绝对零度) !!!
awaysrain 2003-09-18
  • 打赏
  • 举报
回复
经作者同意,我修改了生成柱图的一部分,先放上来让大家看看效果,全部修改完后我会把代码贴上来
===========================================================================
<script language=javascript>
function table1(total,table_x,table_y,thickness,table_width,all_width,all_height,table_type){
//参数含义(传递的数组,横坐标,纵坐标,柱子的厚度,柱子的宽度,图表的宽度,图表的高度,图表的类型)
//纯ASP代码生成图表函数1——柱状图
//作者:龚鸣(Passwordgm) QQ:25968152 MSN:passwordgm@sina.com Email:passwordgm@sina.com
//本人非常愿意和ASP,VML,FLASH的爱好者在HTTP://topclouds.126.com进行交流和探讨
//版本2.0 最后修改日期 2003-7-22
//非常感谢您使用这个函数,请您使用和转载时保留版权信息,这是对作者工作的最好的尊重。

//======================================================================================
//经作者同意,awaysrain(绝对零度)2003年9月18日修改为JavaScript,
//======================================================================================

var tmdColor1 = new Array();

tmdColor1[0] = "#d1ffd1";
tmdColor1[1] = "#ffbbbb";
tmdColor1[2] = "#ffe3bb";
tmdColor1[3] = "#cff4f3";
tmdColor1[4] = "#d9d9e5";
tmdColor1[5] = "#ffc7ab";
tmdColor1[6] = "#ecffb7";

var tmdColor2 = new Array();

tmdColor2[0] = "#00ff00";
tmdColor2[1] = "#ff0000";
tmdColor2[2] = "#ff9900";
tmdColor2[3] = "#33cccc";
tmdColor2[4] = "#666699";
tmdColor2[5] = "#993300";
tmdColor2[6] = "#99cc00";

var tb_color = new Array(tmdColor1,tmdColor2);
var line_color = "#69f";
var left_width = 70;
var length = thickness/2;
var total_no = total[0].length;
var temp1 = 0;
var temp2,temp4,temp4;

for(var i = 0;i<total_no;i++)
{
if(temp1<total[0][i])
{
temp1 = total[0][i];
}
}

temp1 = parseInt(temp1.toString());

if(temp1>9)
{
temp2 = temp1.toString().substr(1,1)
if(temp2>4)
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+1)*Math.pow(10,(temp1.toString().length-1));
}
else
{
temp3 = (parseInt((temp1/(Math.pow(10,(temp1.toString().length-1)))).toString())+0.5)*Math.pow(10,(temp1.toString().length-1));
}
}
else
{
if(temp1>4)
temp3 = 10;
else
temp3 = 5;
}

temp4=temp3
document.write("<!--[if gte vml 1]><v:rect id='_x0000_s1027' alt='' style='position:absolute;left:" + (table_x+left_width) + "px;top:" + table_y + "px;width:" + all_width + "px;height:" + all_height + "px;z-index:-1' fillcolor='#9cf' stroked='f'><v:fill rotate='t' angle='-45' focus='100%' type='gradient'/></v:rect><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + (table_y+all_height) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width) + "px," + table_y + "px' to='" + (table_x+left_width) + "px," + (table_y+all_height) + "px'/><![endif]-->");

switch (table_type)
{
case "A":

var table_space = (all_width-table_width*total_no)/total_no;
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px,"+ table_y + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-length) + "px' strokecolor='" + line_color + "'/><![endif]-->");

for(var i=0;i<=all_height-1;i+= all_height/5)
{
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width)+ "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+left_width+length) + "px," + (table_y+all_height-i) +"px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px," + (table_y+all_height-length-i) + "px' to='" + (table_x+all_width+left_width) + "px," + (table_y+all_height-length-i) + "px' strokecolor='" + line_color + "'/><![endif]-->");
document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+(left_width-15)) + "px," + (table_y+i) + "px' to='" + (table_x+left_width) + "px," + (table_y+i) + "px'/><![endif]-->");
document.write("<!--[if gte vml 1]>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + table_x + "px;top:" + (table_y+i) + "px;width:" + left_width + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>" + temp4 + "</td></tr></table></v:textbox></v:shape><![endif]-->");
temp4 = temp4-temp3/5;
}
for(var i=0;i<total_no;i++)
{
var temp_space = table_x + left_width + table_space/2 + table_space * (i) + table_width*(i);
document.write("<v:rect id='_x0000_s1025' alt='' style='position:absolute;left:");
document.write(temp_space);
document.write("px;top:");
document.write(table_y+all_height*(1-(total[0][i]/temp3)));
document.write("px;width:" + table_width + "px;height:" + all_height*(total[0][i]/temp3) + "px;z-index:1' fillcolor='" + tb_color[1][i] + "'>");
document.write("<v:fill color2='" + tb_color[0][i] + "' rotate='t' type='gradient'/>")
document.write("<o:extrusion v:ext='view' backdepth='" + thickness + "pt' color='" + tb_color[1][i] + "' on='t'/>");
document.write("</v:rect>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + temp_space + "px;top:" + (table_y+all_height*(1-(total[0][i]/temp3))-table_width) + "px;width:" + (table_space+15) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (temp_space-table_space/2) + "px;top:" + (table_y+all_height+1) + "px;width:" + (table_space+table_width) + "px;height:18px;z-index:1'>");
document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[1][i] + "</td></tr></table></v:textbox></v:shape>");
}
break;
}
}
</script>
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<!--[if !mso]>
<style>
v\:* { behavior: url(#default#VML) }
o\:* { behavior: url(#default#VML) }
.shape { behavior: url(#default#VML) }
</style>
<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style>
TD { FONT-SIZE: 9pt}
</style></head>
<body topmargin=5 leftmargin=0 scroll=AUTO>
<script language=javascript>
var dataArray = new Array()
dataArray[0]=200
dataArray[1]=800
dataArray[2]=1000
dataArray[3]=600
dataArray[4]=1222
dataArray[5]=3213
dataArray[6]=8
var nameArray = new Array()
nameArray[0]="中国经营报"
nameArray[1]="招聘网"
nameArray[2]="51Job"
nameArray[3]="新民晚报"
nameArray[4]="新闻晚报"
nameArray[5]="南方周末"
nameArray[6]="羊城晚报"
var total= new Array(dataArray,nameArray)
table1(total,200,20,20,30,400,200,"A");
</script>
</body>
</html>
bota 2003-09-17
  • 打赏
  • 举报
回复
up
swlswl27 2003-09-17
  • 打赏
  • 举报
回复
观注!
eva 2003-09-17
  • 打赏
  • 举报
回复
up
eva 2003-09-17
  • 打赏
  • 举报
回复
up
加载更多回复(1)

87,918

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧