`

『vml+javascript』统计图表之树状图 【转】

阅读更多
<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(绝对零度)修改为javascript。
//    最后修改日期 2003-9-22,测试环境为IE 6.0.2500.1106
//    因本人水平有限,修改中难免有错误,请大家及时指正。  
//***************************************************************************************
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;
case "B":
 var table_space = (all_height - 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+all_height-length) + "px' to='" + (table_x+left_width+all_width) + "px," + (table_y+all_height-length) + "px' strokecolor='" + line_color + "'/><![endif]-->");
 for(var i=0;i<=all_width-1;i +=all_width/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+i) + "px," + (table_y+all_height-length) + "px' to='" + (table_x+left_width+length+i) + "px," + (table_y+all_height) + "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+i) + "px," + (table_y+all_height-length) + "px' to='" + (table_x+left_width+length+i) + "px," + table_y + "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+i+all_width/5) + "px," + (table_y+all_height) + "px' to='" + (table_x+left_width+i+all_width/5) + "px," + (table_y+all_height+15) + "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+left_width+i+all_width/5-left_width) + "px;top:" + (table_y+all_height) + "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_space/2 + table_space * i + table_width * i;
  document.write("<v:rect id='_x0000_s1025' alt='' style='position:absolute;left:");
  document.write(table_x + left_width);
  document.write("px;top:");
  document.write(table_y + temp_space);
  document.write("px;width:" + all_width * (total[0][i] / temp3) + "px;height:" + table_width + "px;z-index:1' fillcolor='" + tb_color[1][i] + "'>");
  document.write("<v:fill color2='" + tb_color[0][i] + "' rotate='t' angle='-90' focus='100%' 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:" + (table_x + left_width + all_width * (total[0][i] / temp3) + thickness / 2) + "px;top:" + (table_y + temp_space) + "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:" + table_x + "px;top:" + (table_y + temp_space) + "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'>" + total[1][i] + "</td></tr></table></v:textbox></v:shape>");
 }
 
 }
}
</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");
table1(total,200,320,20,20,400,250,"B")
</script>
分享到:
评论
1 楼 lordhong 2008-06-19  
WML?????

相关推荐

    vml+javascript直接在浏览器中绘制动态曲线图实例(源码-+Think in vml +vml+极道教程)

    在“vml+javascript直接在浏览器中绘制动态曲线图实例”中,我们主要学习如何通过JavaScript与VML结合,在不支持SVG(Scalable Vector Graphics)的老版IE浏览器中绘制动态曲线图。SVG是另一种更现代的矢量图形标准...

    vml+javascript直接在web页面绘制动态曲线

    vml+javascript直接在web页面绘制动态曲线

    用VML+JavaScript写的一个通用统计图表

    在这个"用VML+JavaScript写的一个通用统计图表"项目中,开发者利用VML的强大图形绘制能力和JavaScript的动态性,构建了一个适用于多种统计需求的图表库。这种图表库可以用来显示各种类型的统计数据,如柱状图、折线...

    vml+javascript直接在浏览器中绘制动态曲线图实例(源码-+Think+in+vml++vml+极道教程)

    这个"vml+javascript直接在浏览器中绘制动态曲线图实例"提供了源码,可以帮助我们理解如何使用VML和JavaScript实现这一功能。首先,我们需要在HTML页面中定义VML的命名空间,并设置CSS样式以便在IE浏览器中正确显示...

    vml+javascript实现的3d柱状图(仅适用于ie)

    本主题聚焦于一种特定的技术,即使用VML(Vector Markup Language)和JavaScript来创建3D柱状图,这是一种针对IE浏览器的解决方案。在本文中,我们将深入探讨这些技术及其在实现3D柱状图中的应用。 首先,我们来看...

    用vml+JAVASCRIPT写的 广东省各县分布图 颜色可根据值而变

    在这个特定的案例中,"用vml+JAVASCRIPT写的 广东省各县分布图 颜色可根据值而变" 提供了一个利用Vector Markup Language (VML) 和JavaScript实现的动态广东省各县分布图。下面将详细介绍这个项目中的关键技术点。 ...

    vml+javascript高效曲线画图

    在JavaScript的帮助下,我们可以利用VML来实现高效地绘制曲线图表,尤其适用于处理大量数据点的情况,如描述中提到的“可以支持几万个点”。这种技术在数据可视化、统计报告和仪表盘等场景中非常有用。 在...

    Javascript + VML + SVG 工作流设计器

    SVG(Scalable Vector Graphics)是另一种矢量图形标准,它基于XML,支持动态和交互式内容,可以在任何分辨率下保持清晰,非常适合用于创建工作流图、流程图和其他图表。SVG图形可以通过JavaScript进行操纵,例如...

    vml+flashVML

    压缩包中的"vml"文件可能包含一些基本的VML示例代码,而"vml+flashvml"文件可能包含了关于如何结合Flash和VML的教程或实例代码。 总的来说,学习和理解VML及Flash VML可以帮助开发者在早期的网页环境中创建出美观且...

    VML+HTML实现流程图查看

    实现了vml+html中显示的,并解决了ie浏览器兼容的问题,代码直接运行便好用

    vml+js实现的框图编辑器

    在这个特定的项目中,"vml+js实现的框图编辑器"利用了两种关键技术:VML(Vector Markup Language)和JavaScript,来构建一个能够执行多种操作的交互式编辑器。 VML,全称为矢量标记语言,是一种用于在网页上描绘...

    ajax+vml+js开发实时监控和矩形报表(原稿)

    解压导入到eclipse,直接运行,IE要求5.5以上. 博文链接:https://sailinglxg.iteye.com/blog/138849

    asp+vml 图表 矩形图示例

    ASP(Active Server Pages)是一种微软开发的服务器端脚本...如果需要跨平台和设备的兼容性,开发者现在可能会选择使用JavaScript库,如D3.js或Highcharts,它们能够生成包括柱状图在内的各种复杂图表,并且支持SVG。

    javascript+ajax+vml折线图

    用javascript+ajax+vml生成折线图javascript类打包

    VML.rar_VML_javascript_javascript 教程

    当JavaScript与VML结合时,可以实现动态生成和修改矢量图形的功能,这对于创建数据可视化、交互式图表和复杂用户界面非常有用。 1. **创建VML元素** 使用JavaScript,我们可以动态创建`&lt;v:shape&gt;`等VML元素,并...

    网页制作完全手册!dhtml+html+css+htc+time+vml+滤镜~等等

    dhtml+html+css+htc+time+vml+滤镜~等等"则涵盖了这一领域多个关键知识点,旨在帮助初学者和进阶者全面理解网页设计与开发。下面我们将详细探讨这些技术及其在网页制作中的应用。 首先,HTML(HyperText Markup ...

    HighchartsJS是一个基于SVG和VML渲染的JavaScript图表库

    - **丰富的图表类型**:提供多种图表类型,如折线图、柱状图、饼图、散点图、面积图、热力图等,满足不同数据展示需求。 - **交互性**:图表具有良好的交互性,允许用户通过点击、悬浮、缩放和滚动来探索数据。 -...

    asp+vml图表 饼状图示例

    在这个"asp+vml图表 饼状图示例"中,我们将探讨如何利用这两项技术来生成动态的数据图表。 首先,VML是一种基于XML的语言,它允许在网页上绘制复杂的图形,包括线条、曲线、形状以及我们关注的饼状图。VML的优点...

Global site tag (gtag.js) - Google Analytics