VML画柱状图、并图、折线图的封装

None.gif /*    3D统计图绘图类
None.gif功能:根据表格数据绘制统计图
None.gif作者:LiuZXIT
None.gif完成:2003/9/10
None.gif备注:在IE6下测试成功
None.gif局限性:1.只能针对于单一二维行列式规则TABLE进行绘制
None.gif    2.TABLE内容必须有左标题和上标题,并且右下部分都必须是数据区
None.gif不足:没有支持动态定制数据源,例如用一个XML数据包,有些文字太长会出现显示不好
None.gif
None.gif注意点:
None.gif    1.htm页面必需包含以下内容
None.gif        
< HTML  xmlns:v ="urn:schemas-microsoft-com:vml"  xmlns:o ="urn:schemas-microsoft-com:office:office" >
ExpandedBlockStart.gifContractedBlock.gif        
< STYLE > dot.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        v\:*         
{dot.gif}{behavior:url(#default#VML);}
ExpandedSubBlockStart.gifContractedSubBlock.gif        o\:*         
{dot.gif}{ behavior: url(#default#VML) }
ExpandedSubBlockStart.gifContractedSubBlock.gif        .shape       
{dot.gif}{ behavior: url(#default#VML) }
ExpandedBlockEnd.gif        
</ STYLE >
None.gif    2.饼形图和柱状图只能针对一行或一列数据,所以在勾选多行或多列时,只会绘制出勾选的最上面行或最左边列
None.gif*/
ExpandedBlockStart.gifContractedBlock.gif
< script > dot.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function draw3D(arTable,aDiv,asTool,intCol,intRow)dot.gif{    //是否画工具栏asTool如不填为N都认为是Y,跳过左边intCol列和表头intRow列省略为1
InBlock.gif
    if(arTable==null || aDiv==null)return;
InBlock.gif    asTool
=(asTool==null?'Y':asTool);
InBlock.gif    asTool
=(asTool.toUpperCase()=='N'?'N':'Y');
InBlock.gif    intCol
=(intCol==null?1:intCol);
InBlock.gif    intRow
=(intRow==null?1:intRow);
InBlock.gif    intCol
=(parseInt(intCol)==NaN?1:parseInt(intCol));
InBlock.gif    intRow
=(parseInt(intRow)==NaN?1:parseInt(intRow));
InBlock.gif    
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for(var i=intCol;i<arTable.rows[intRow - 1].cells.length;i++)dot.gif{
InBlock.gif        arTable.rows[intRow 
- 1].cells[i].innerHTML +='<input type="checkbox" checked name="SelectCol" checked>'
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
for(var i=intRow;i<arTable.rows.length;i++)dot.gif{
InBlock.gif        arTable.rows[i].cells[intCol 
- 1].innerHTML +='<input type="checkbox" name="SelectRow" checked>'
ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
if(asTool=='Y')dot.gif{
InBlock.gif        
var strTool='';
InBlock.gif        strTool 
+= '<span style="font:9pt;"><select id="DrawImg_room" onchange="draw.changeRate(this.value)">';
InBlock.gif            strTool 
+= '<option value=0.7>0.7';
InBlock.gif            strTool 
+= '<option value=0.8 selected>0.8<option value=1 >1<option value=2>2<option value=4>4';
InBlock.gif            strTool 
+= '<option value=6>6<option value=8 >8<option value=10>10</option></select>';
InBlock.gif        strTool 
+= '<input type="radio" id="DrawImg_type2" name="DrawImg_type" checked><label for="d2">柱状图</label>  ';
InBlock.gif        strTool 
+= '<input type="radio" id="DrawImg_type1" name="DrawImg_type"><label for="d4">饼形图</label>  ';
InBlock.gif        strTool 
+= '<input type="radio" id="DrawImg_type3" name="DrawImg_type"><label for="d3">折线图</label>  ';
InBlock.gif        strTool 
+= '<input type="radio" id="Draw_Compare1" name="Draw_Compare" checked><label for="Draw_Compare1">横比</label>  ';
InBlock.gif        strTool 
+= '<input type="radio" id="Draw_Compare2" name="Draw_Compare"><label for="Draw_Compare2">纵比</label>  ';
InBlock.gif        strTool 
+= '<input type="button" id="Draw_Button" value="画图" onclick="this.DrawImg.draw()"></span>';
InBlock.gif        aDiv.insertAdjacentHTML(
"beforeBegin",strTool);
InBlock.gif        document.all('Draw_Button').DrawImg
=this;
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
this.Rate=0.8;                    //尺寸比例
InBlock.gif
    this.DataSource=new Array();    //数据源
InBlock.gif
    this.DataHead=new Array();        //表头
InBlock.gif
    this.DataKind=new Array();        //种类
InBlock.gif
    this.Color=new Array("#ff0000","#ffA6A6","#ff00ff","#ffaeff","#0000ff","#84aeff","#00ffff","#a6aeff","#00ff00","#b5ffb5","#ffff00","#ffffb5")
InBlock.gif    
this.DrGroup=new Array();        //画了的图的记录集
InBlock.gif
    this.DrawObject=arTable;        //放置数据的TABLE
InBlock.gif
    this.DrawDiv=aDiv;                //用于画图的DIV,建议用DIV而避免用其他标签
InBlock.gif
    this.IntCol=intCol;                //标题列数
InBlock.gif
    this.IntRow=intRow;                //标题行数
InBlock.gif

InBlock.gif    
this.drawPie=DR_drawPie;        //画饼型图
InBlock.gif
    this.drawPole=DR_drawPole;        //画柱状图
InBlock.gif
    this.drawLine=DR_drawLine;        //画折线图
InBlock.gif
    this.changeRate=DR_changeRate;    //改变比例尺
InBlock.gif
    this.collectData=DR_collectData;    //收集数据
InBlock.gif
    this.draw=DR_draw;            //画图
InBlock.gif
    
ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function DR_draw()dot.gif{
InBlock.gif    
if(DrawImg_type1.checked)this.DrawDiv.innerHTML=draw.drawPie();
InBlock.gif    
if(DrawImg_type2.checked)this.DrawDiv.innerHTML=draw.drawPole();
InBlock.gif    
if(DrawImg_type3.checked)this.DrawDiv.innerHTML=draw.drawLine();
InBlock.gif    
if(document.all('DrawImg_room')!=null)document.all('DrawImg_room').value=1;
ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function DR_collectData()dot.gif{
InBlock.gif    
var intRow=this.IntRow,intCol=this.IntCol,tblData=this.DrawObject;
InBlock.gif    
this.DataSource=new Array();
InBlock.gif    
this.DataHead=new Array();
InBlock.gif    
this.DataKind=new Array();
ExpandedSubBlockStart.gifContractedSubBlock.gif    
if(Draw_Compare1.checked)dot.gif{    //如果是横比
ExpandedSubBlockStart.gifContractedSubBlock.gif
        if(intRow > 0)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
for(var i=intCol;i<tblData.rows[intRow - 1].cells.length;i++)dot.gif{
InBlock.gif                
if(tblData.rows[intRow - 1].cells[i].all('SelectCol').checked)this.DataHead[this.DataHead.length++]=tblData.rows[intRow - 1].cells[i].innerText;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
if(intCol > 0)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
for(var i=intRow;i<tblData.rows.length;i++)dot.gif{
InBlock.gif                
if(tblData.rows[i].cells[intCol - 1].all('SelectRow').checked)this.DataKind[this.DataKind.length++]=tblData.rows[i].cells[intCol - 1].innerText;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
var intValue;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
for(var i=intRow;i<tblData.rows.length;i++)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
if(tblData.rows[i].cells[intCol - 1].all('SelectRow').checked)dot.gif{
InBlock.gif                
this.DataSource[this.DataSource.length++]=new Array();
ExpandedSubBlockStart.gifContractedSubBlock.gif                
for(var j=intCol;j<tblData.rows[i].cells.length;j++)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
if(tblData.rows[intRow - 1].cells[j].all('SelectCol').checked)dot.gif{
InBlock.gif                        
this.DataSource[this.DataSource.length - 1].length ++
InBlock.gif                        intValue
=parseInt(tblData.rows[i].cells[j].innerText+"");
InBlock.gif                        intValue
=(isNaN(intValue)?0:intValue)
InBlock.gif                        
this.DataSource[this.DataSource.length - 1][this.DataSource[this.DataSource.length - 1].length - 1]=intValue;
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif    }
elsedot.gif{    //否则纵比
ExpandedSubBlockStart.gifContractedSubBlock.gif
        if(intRow > 0)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
for(var i=intCol;i<tblData.rows[intRow - 1].cells.length;i++)dot.gif{
InBlock.gif                
if(tblData.rows[intRow - 1].cells[i].all('SelectCol').checked)this.DataKind[this.DataKind.length++]=tblData.rows[intRow - 1].cells[i].innerText;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
if(intCol > 0)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
for(var i=intRow;i<tblData.rows.length;i++)dot.gif{
InBlock.gif                
if(tblData.rows[i].cells[intCol - 1].all('SelectRow').checked)this.DataHead[this.DataHead.length++]=tblData.rows[i].cells[intCol - 1].innerText;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
var intValue;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
for(var i=intCol;i<tblData.rows[intCol].cells.length;i++)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
if(tblData.rows[intRow - 1].cells[i].all('SelectCol').checked)dot.gif{
InBlock.gif                
this.DataSource[this.DataSource.length++]=new Array();
ExpandedSubBlockStart.gifContractedSubBlock.gif                
for(var j=intRow;j<tblData.rows.length;j++)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
if(tblData.rows[j].cells[intRow - 1].all('SelectRow').checked)dot.gif{
InBlock.gif                        
this.DataSource[this.DataSource.length - 1].length ++
InBlock.gif                        intValue
=parseInt(tblData.rows[j].cells[i].innerText+"");
InBlock.gif                        intValue
=(isNaN(intValue)?0:intValue)
InBlock.gif                        
this.DataSource[this.DataSource.length - 1][this.DataSource[this.DataSource.length - 1].length - 1]=intValue;
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif}

ExpandedSubBlockStart.gifContractedSubBlock.gif
function DR_drawPie()dot.gif{        //arInt:那一组数据
InBlock.gif
    this.collectData();
InBlock.gif    
if(this.DataSource.length<1)return;
InBlock.gif    
var maxScale = 1<<16,intTotal=0
InBlock.gif    
for (var i=0;i<this.DataSource[0].length;i++)intTotal+= parseInt(this.DataSource[0][i]);
InBlock.gif    
this.Rate=1;
InBlock.gif    
var w=1,strObj='DR_Group'
ExpandedSubBlockStart.gifContractedSubBlock.gif    
while(w > 0)dot.gif{
InBlock.gif        
if(document.all(strObj + w)==null)break;
InBlock.gif        w
++
ExpandedSubBlockEnd.gif    }

InBlock.gif    
this.DrGroup[this.DrGroup.length++]=(strObj + w);
InBlock.gif
InBlock.gif    
var str="<v:group id='" +(strObj + w) +"' style='width:500;height:500;position:absolute;' CoordSize='3600,3600'>\n"
InBlock.gif        
//画底下的圆饼
InBlock.gif
        str += "<v:shape style='width:10;height:10;' CoordSize='"+this.Rate+","+this.Rate+"'>\n"
InBlock.gif            str 
+= "<v:path v='ae 300,200,200,200,3932100,23592960 xe' />\n"
InBlock.gif            str 
+= "<o:extrusion v:ext='view' on='t'  rotationangle='80,-10' backdepth='10' color='#0086c6' />\n"
InBlock.gif        str 
+= "</v:shape>\n"
InBlock.gif        
//画各部分的饼块
InBlock.gif
        var numStart=0,numScale=0;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
for (var i=0;i<this.DataSource[0].length;i++)dot.gif{
InBlock.gif            numScale
=(this.DataSource[0][i] / intTotal) * maxScale * 360;
InBlock.gif            str 
+= "<v:shape style='width:10;height:10;' CoordSize='"+this.Rate+","+this.Rate+"'>\n"
InBlock.gif                str 
+= "<v:path v='m 300,200 ae 300,200,200,200,"+parseInt(numStart)+","+parseInt(numScale)+" xe' />\n"
InBlock.gif                str 
+= "<v:fill color='"+this.Color[i * 2 % 12]+"' color2='"+this.Color[(i * 2 % 12+ 1]+"' rotate='t' focus='100%' type='gradient' />\n"
InBlock.gif                str 
+= "<o:extrusion v:ext='view' on='t'  rotationangle='80,-10' backdepth='0' />\n"
InBlock.gif            str 
+= "</v:shape>\n"
InBlock.gif            numStart
+=numScale
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//画右边的图例
InBlock.gif
        var intTmp=0
ExpandedSubBlockStart.gifContractedSubBlock.gif        
for (var i=0;i<this.DataSource[0].length;i++)dot.gif{
InBlock.gif            str 
+= "<v:rect style='top:"+(i*200)+";left:4500;width:100;height:100;' strokecolor='#0099ff' fillcolor='"+this.Color[(i * 2 % 12)]+"'></v:rect>"
InBlock.gif            str
+="<v:line from='4600,"+(i*200)+"' to='5500,"+(i*200)+"' strokecolor='#ffffff' strokeWeight='2'>"
InBlock.gif                str 
+= "<v:textbox inset='0pt,0pt,0pt,0pt' style='color:#0099ff;font-size:9pt;'>"+this.DataHead[i]+":"+(i==this.DataSource[0].length - 1?(10000 - intTmp)/100:parseInt(this.DataSource[0][i] / intTotal * 10000/100)+"%</v:textbox></v:line>"
InBlock.gif            intTmp 
+= parseInt(this.DataSource[0][i] / intTotal * 10000)
ExpandedSubBlockEnd.gif        }

InBlock.gif    str 
+= "</v:group>\n"
InBlock.gif    
return str
ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function DR_drawPole()dot.gif{
InBlock.gif    
this.collectData();
InBlock.gif    
if(this.DataSource.length<1)return;
InBlock.gif    
//    数据最大值,数组元素个数                            每个柱子的宽度                            柱与柱间的间隔
InBlock.gif
    var intMax=0,intTotal=this.DataSource[0].length + 1,intPWidth=parseInt(1800 / intTotal,10),intPad=intPWidth * 2;
InBlock.gif    intPWidth
=(intPWidth>300?300:intPWidth);
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for(var i=0;i<this.DataSource[0].length;i++)dot.gif{intMax=(intMax < this.DataSource[0][i]?this.DataSource[0][i]:intMax)}
InBlock.gif    intMax
=(parseInt(intMax / Math.pow(10,(intMax+"").length - 1)) + 1* Math.pow(10,(intMax+"").length - 1)
InBlock.gif    
this.Rate=1;
InBlock.gif    
var w=1,strObj='DR_Group'
ExpandedSubBlockStart.gifContractedSubBlock.gif    
while(w > 0)dot.gif{
InBlock.gif        
if(document.all(strObj + w)==null)break;
InBlock.gif        w
++
ExpandedSubBlockEnd.gif    }

InBlock.gif    
this.DrGroup[this.DrGroup.length++]=(strObj + w);
InBlock.gif
InBlock.gif    
var str="<v:group id='" +(strObj + w) +"' style='width:500;height:500;position:absolute;' CoordSize='3600,3600'>\n"
InBlock.gif        
//画底板
InBlock.gif
        str += "<v:PolyLine Points='400,2400 200,2600 3800,2600 4000,2400' strokecolor='#0099ff'>\n"        //
InBlock.gif
               str += "<v:fill color='#00cfef' angle='45' rotate='t' focus='100%' type='gradient' />\n"
InBlock.gif        str 
+= "</v:PolyLine>\n"
InBlock.gif        str 
+= "<v:PolyLine Points='400,2400 200,2600 200,200 400,0 ' strokecolor='#0099ff'>\n"        //
InBlock.gif
               str += "<v:fill color='#00cfef' angle='210' rotate='t' focus='100%' type='gradient' />\n"
InBlock.gif        str 
+= "</v:PolyLine>\n"
InBlock.gif        str 
+= "<v:PolyLine Points='400,0 4000,0 4000,2400 400,2400 ' strokecolor='#0099ff'>\n"
InBlock.gif               str 
+= "<v:fill color='#00cfef' angle='135' rotate='t' focus='100%' type='gradient' />\n"    //
InBlock.gif
        str += "</v:PolyLine>\n"
InBlock.gif        
//画虚线
ExpandedSubBlockStart.gifContractedSubBlock.gif
        for(var i=1;i<10;i++)dot.gif{
InBlock.gif            str 
+= "<v:PolyLine filled='false' Points='200,"+(2600 - 240 * i)+" 400,"+(2400 - 240 * i)+" 4000,"+(2400 - 240 * i)+"' strokecolor='#0099ff'>\n"
InBlock.gif                str 
+= "<v:stroke dashstyle='Dash' />\n"
InBlock.gif            str 
+= "</v:PolyLine>\n"
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//画左边的坐标
ExpandedSubBlockStart.gifContractedSubBlock.gif
        for(var i=1;i<11;i++)dot.gif{
InBlock.gif            str
+="<v:RoundRect style='left:0;top:"+(2600 - 240 * i)+";' strokeColor='transparent'>"
InBlock.gif                str
+="<v:textbox inset='0pt,0pt,0pt,0pt' style='font-size:9pt;color:#0000ff;'>"+(i*(intMax / 10))+"</v:textbox></v:RoundRect>"
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//画底下的标签
ExpandedSubBlockStart.gifContractedSubBlock.gif
        for (var i=0;i<this.DataSource[0].length;i++)dot.gif{
InBlock.gif            str
+="<v:RoundRect style='left:"+(400 + parseInt(intPad * (i + 0.5),10- parseInt((intPWidth / 2)))+";top:2600;' strokeColor='transparent'>"
InBlock.gif                str
+="<v:textbox inset='0pt,0pt,0pt,0pt' style='font-size:9pt;color:#0099ff;'>"+this.DataHead[i]+"</v:textbox></v:RoundRect>"
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//画柱状图
ExpandedSubBlockStart.gifContractedSubBlock.gif
        for(var i=0;i<this.DataSource[0].length;i++)dot.gif{
InBlock.gif            str 
+= "<v:PolyLine Points='"+(400 + parseInt(intPad * (i + 0.5),10))+",2400 "+(400 + parseInt(intPad * (i + 0.5),10))+","+(2400 - parseInt(this.DataSource[0][i]/intMax * 2400,10))+" "+(400 + parseInt(intPad * (i + 0.5),10+ intPWidth)+"," +(2400 - parseInt(this.DataSource[0][i]/intMax * 2400,10))+" "+(400 + parseInt(intPad * (i + 0.5),10+ intPWidth)+",2400 ' strokecolor='#ffffff'>\n"
InBlock.gif                   str 
+= "<v:fill color='"+this.Color[(i % 12)]+"' angle='150' rotate='t' focus='100%' type='gradient' />\n"
InBlock.gif                   str 
+= "<o:extrusion v:ext='view' on='t' backdepth='0' foredepth='"+(parseInt(intPWidth / 10))+"' />\n"
InBlock.gif            str 
+= "</v:PolyLine>\n"
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//画每根柱的数据量
ExpandedSubBlockStart.gifContractedSubBlock.gif
        for (var i=0;i<this.DataSource[0].length;i++)dot.gif{
InBlock.gif            str
+="<v:RoundRect style='left:"+(400 + parseInt(intPad * (i + 0.5),10))+";top:"+(2400 - parseInt(this.DataSource[0][i]/intMax * 2400 + 100))+";' strokeColor='transparent'>"
InBlock.gif                str
+="<v:textbox inset='0pt,0pt,0pt,0pt' style='font-size:9pt;color:#ff00ff;'>"+this.DataSource[0][i]+"</v:textbox></v:RoundRect>"
ExpandedSubBlockEnd.gif        }

InBlock.gif    str 
+= "</v:group>"
InBlock.gif    
return str
ExpandedSubBlockEnd.gif}

ExpandedSubBlockStart.gifContractedSubBlock.gif
function DR_drawLine()dot.gif{        //arInt:那一组数据
InBlock.gif
    this.collectData();
InBlock.gif    
if(this.DataSource.length<1)return;
InBlock.gif    
var intMax=0,intPWidth=parseInt(3600 / (this.DataSource[0].length>1?this.DataSource[0].length - 1:1),10);
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for(var i=0;i<this.DataSource.length;i++)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
for(var j=0;j<this.DataSource[i].length;j++)dot.gif{intMax=(intMax < this.DataSource[i][j]?this.DataSource[i][j]:intMax)}
ExpandedSubBlockEnd.gif    }

InBlock.gif    intMax
=(parseInt(intMax / Math.pow(10,(intMax+"").length - 1)) + 1* Math.pow(10,(intMax+"").length - 1)
InBlock.gif    
this.Rate=1;
InBlock.gif    
var w=1,strObj='DR_Group'
ExpandedSubBlockStart.gifContractedSubBlock.gif    
while(w > 0)dot.gif{
InBlock.gif        
if(document.all(strObj + w)==null)break;
InBlock.gif        w
++
ExpandedSubBlockEnd.gif    }

InBlock.gif    
this.DrGroup[this.DrGroup.length++]=(strObj + w);
InBlock.gif
InBlock.gif    
var str="<v:group id='" +(strObj + w) +"' style='width:500;height:500;position:absolute;' CoordSize='3600,3600'>\n"
InBlock.gif        
//画底板
InBlock.gif
        str += "<v:PolyLine Points='200,2400 3800,2400 3800,0 200,0 ' strokecolor='#0099ff'>\n"
InBlock.gif               str 
+= "<v:fill color='#00cfef' angle='135' rotate='t' focus='100%' type='gradient' />\n"
InBlock.gif        str 
+= "</v:PolyLine>\n"
InBlock.gif        
//画坐标线
ExpandedSubBlockStart.gifContractedSubBlock.gif
        for(var i=1;i<10;i++)dot.gif{
InBlock.gif            str 
+= "<v:PolyLine filled='false' Points='200,"+(240 * i)+" 3800,"+(240 * i)+"' strokecolor='#0099ff'/>\n"
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
for(var i=1;i<this.DataSource[0].length;i++)dot.gif{
InBlock.gif            str 
+= "<v:PolyLine filled='false' Points='"+(200 + intPWidth * i)+",0 "+(200 + intPWidth * i)+",2400' strokecolor='#0099ff'>\n"
InBlock.gif                str 
+= "<v:stroke dashstyle='Dash' />\n"
InBlock.gif            str 
+= "</v:PolyLine>\n"
ExpandedSubBlockEnd.gif        }

InBlock.gif        
InBlock.gif        str 
+= "<v:PolyLine filled='false' Points='200,-100 200,2400 3900,2400' StartArrow='Classic' EndArrow='Classic'>"
InBlock.gif            str 
+= "<v:stroke StartArrow='Classic' EndArrow='Classic'/>"
InBlock.gif        str 
+= "</v:PolyLine>"
InBlock.gif
InBlock.gif        
//画左边的坐标
ExpandedSubBlockStart.gifContractedSubBlock.gif
        for(var i=1;i<11;i++)dot.gif{
InBlock.gif            str
+="<v:RoundRect style='left:0;top:"+(2400 - 240 * i)+";' strokeColor='transparent'>"
InBlock.gif                str
+="<v:textbox style='font-size:9pt;color:#0099ff;' inset='0pt,0pt,0pt,0pt'>"+(i*(intMax / 10))+"</v:textbox></v:RoundRect>"
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//画底下的标签
ExpandedSubBlockStart.gifContractedSubBlock.gif
        for (var i=0;i<this.DataSource[0].length;i++)dot.gif{
InBlock.gif            str
+="<v:line from='"+(200 + intPWidth * i)+",2410' to='"+(450 + intPWidth * i)+",2410' strokecolor='#ffffff'>"
InBlock.gif                str
+="<v:TextBox style='font-size:9pt;color:#0099ff;' inset='0pt,0pt,0pt,0pt'>"+this.DataHead[i]+"</v:TextBox></v:line>"
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//画折线
ExpandedSubBlockStart.gifContractedSubBlock.gif
        for(var j=0;j<this.DataSource.length;j++)dot.gif{
InBlock.gif            
var st = "";
ExpandedSubBlockStart.gifContractedSubBlock.gif            
for(var i=0;i<this.DataSource[j].length;i++)dot.gif{
InBlock.gif                st 
+=" " + (200 + intPWidth*i) +","+ (2400 - parseInt(this.DataSource[j][i]/intMax * 2400,10))
ExpandedSubBlockEnd.gif            }

InBlock.gif            str 
+= "<v:PolyLine filled='false' Points='"+st+"' strokecolor='"+this.Color[(j % 12)*2]+"'/>\n"
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//画右边的图例
ExpandedSubBlockStart.gifContractedSubBlock.gif
        for (var i=0;i<this.DataKind.length;i++)dot.gif{
InBlock.gif            str
+="<v:line from='3850,"+(i*150 + 40)+"' to='3950,"+(i*150 + 40)+"' strokecolor='"+this.Color[(i % 12)*2]+"' strokeWeight='2' />"
InBlock.gif            str
+="<v:line from='3970,"+(i*150)+"' to='4370,"+(i*150)+"' strokecolor='#ffffff' strokeWeight='2'>"
InBlock.gif                str 
+= "<v:textbox inset='0pt,0pt,0pt,0pt' style='color:#0099ff;font-size:9pt;'>"+this.DataKind[i]+"</v:textbox></v:line>"
ExpandedSubBlockEnd.gif        }

InBlock.gif    str 
+= "</v:group>"
InBlock.gif    
return str
ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function DR_changeRate(ai_Rate)dot.gif{
InBlock.gif     
if(ai_Rate==this.Rate)return;
ExpandedSubBlockStart.gifContractedSubBlock.gif     
for(var i=0;i<this.DrGroup.length;i++)dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif         
if(document.all(this.DrGroup[i])==null)dot.gif{
InBlock.gif             
this.DrGroup=this.DrGroup.slice(0,i).concat(this.DrGroup.slice(i+1))
InBlock.gif             i
--
ExpandedSubBlockStart.gifContractedSubBlock.gif         }
elsedot.gif{document.all(this.DrGroup[i]).coordsize=parseInt(3600 / ai_Rate)+","+parseInt(3600 / ai_Rate);}
ExpandedSubBlockEnd.gif     }

InBlock.gif     
this.Rate=ai_Rate;
ExpandedBlockEnd.gif}

None.gif
</ script >
None.gif=============JsVML.htm================
None.gif
< HTML  xmlns:v ="urn:schemas-microsoft-com:vml"  xmlns:o ="urn:schemas-microsoft-com:office:office" >
None.gif
< HEAD >
ExpandedBlockStart.gifContractedBlock.gif
< STYLE > dot.gif
ExpandedSubBlockStart.gifContractedSubBlock.gifv\:*         
{dot.gif}{behavior:url(#default#VML);}
ExpandedSubBlockStart.gifContractedSubBlock.gifo\:*         
{dot.gif}{ behavior: url(#default#VML) }
ExpandedSubBlockStart.gifContractedSubBlock.gif.shape       
{dot.gif}{ behavior: url(#default#VML) }
None.gif
</ STYLE >
None.gif
< script  language ="javascript"  src ="JsVml.js" ></ script >
None.gif
</ head >
None.gif
< body >
None.gif
< table  id ="tblData"  width ="60%"  border ="1"  cellpadding ="0" >
None.gif  
< tr >  
None.gif    
< th > 年份 </ th >< th > 第一2季 </ th >< th > 第二4季 </ th >< th > 第三季 </ th >< th > 第四季 </ th >< th > 平均 </ th >
None.gif  
</ tr >
None.gif  
< tr >  
None.gif    
< td  align ="center" > 1998 </ td >
None.gif    
< td  align ="right" > 2400 </ td >< td  align ="right" > 1277 </ td >
None.gif    
< td  align ="right" > 3670 </ td >< td  align ="right" > 3176 </ td >
None.gif    
< td  align ="right" > 3176 </ td >
None.gif  
</ tr >
None.gif  
< tr >  
None.gif    
< td  align ="center" > 1999 </ td >
None.gif    
< td  align ="right" > 2215 </ td >< td  align ="right" > 1021 </ td >
None.gif    
< td  align ="right" > 1841 </ td >< td  align ="right" > 1952 </ td >
None.gif    
< td  align ="right" > 2215 </ td >
None.gif  
</ tr >
None.gif  
< tr >  
None.gif    
< td  align ="center" > 2000 </ td >
None.gif    
< td  align ="right" > 1964 </ td >< td  align ="right" > 2746 </ td >
None.gif    
< td  align ="right" > 1248 </ td >< td  align ="right" > 1878 </ td >
None.gif   
< td  align ="right" > 3670 </ td >
None.gif  
</ tr >
None.gif  
< tr >  
None.gif    
< td  align ="center" > 2001 </ td >
None.gif    
< td  align ="right" > 2254 </ td >< td  align ="right" > 1876 </ td >
None.gif    
< td  align ="right" > 2486 </ td >< td  align ="right" > 2000 </ td >
None.gif    
< td  align ="right" > 3670 </ td >
None.gif  
</ tr >
None.gif  
< tr >  
None.gif    
< td  align ="center" > 2002 </ td >
None.gif    
< td  align ="right" > 2487 </ td >< td  align ="right" > 2348 </ td >
None.gif    
< td  align ="right" > 2345 </ td >< td  align ="right" > 2456 </ td >
None.gif    
< td  align ="right" > 3670 </ td >
None.gif  
</ tr >
None.gif
</ table >
None.gif
None.gif
< div  id ="tDraw"  style ="width:600;height:400;overflow:auto;" ></ div >
None.gif
ExpandedBlockStart.gifContractedBlock.gif
< script > dot.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
for(var i=1;i<tblData.rows.length;i++)dot.gif{
InBlock.gif    
var intQty=0
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for(var j=1;j<tblData.rows[i].cells.length - 1;j++)dot.gif{
InBlock.gif        intQty 
+= parseInt(tblData.rows[i].cells[j].innerText,10)
ExpandedSubBlockEnd.gif    }

InBlock.gif    tblData.rows[i].cells[j].innerText
=parseInt(intQty / (j - 1))
ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedBlockEnd.gif    
var draw=new draw3D(tblData,tDraw);
None.gif
</ script >
None.gif
None.gif


转自csdn 效果可以在这看...
http://vbb.iecn.net/showthread.php?threadid=14724

转载于:https://www.cnblogs.com/gwazy/archive/2006/05/08/393520.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值