WEB开发网
开发学院网页设计JavaScript 利用vml制作统计图全攻略----饼图的制作 (三... 阅读

利用vml制作统计图全攻略----饼图的制作 (三)

 2010-09-14 13:32:28 来源:WEB开发网   
核心提示:4. VMLPie.prototype.CreatePie<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> CreatePie提供了一个参数,也就是饼图制作的容器,利用vml制作统计图

4. VMLPie.prototype.CreatePie<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

CreatePie提供了一个参数,也就是饼图制作的容器,我们通过Draw的上述代码已经建立了一个V:Group元素,这个也就是饼图绘制的容器了。

var mX=Math.pow(2,16) * 360;
//这个参数是划图形的关键
//AE x y width height startangle endangle
//x y表示圆心位置
//width height形状的大小
//startangle endangle的计算方法如下
// 2^16 * 度数    
var vTotal=0;
var startAngle=0;
var endAngle=0;
var pieAngle=0;
var prePieAngle=0;      
//计算数据的总和
for(i=0;i<this.all.length;i++){
   vTotal+=this.all[i].Value;
}
//建立图例容器
//这里子元素的left,top或者width都是针对于容器设置的坐标系统而言的
//例如
//图表容器我设置了coordsize为 21600,21600,那么objLengendGroup的位置都是相对于这个坐标系统而言的
//和实际图形显示的大小没有直接关系
var objLegendGroup=document.createElement("v:group");
with(objLegendGroup){
   style.left="17000px";
   style.top="4000px";
   style.width="4000px";
   style.height=1400 * this.all.length +"px";
   coordsize="21600,21600";          
}
//做图例的背景填充并且设置阴影
var objLegendRect=document.createElement("v:rect");
objLegendRect.fillcolor=" #EBF<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />
1F
9";
objLegendRect.strokeweight=1;
with(objLegendRect){     
   //设置为21600,21600,就是保证完全覆盖group客户区
   style.width="21600px";
   style.height="21600px";          
}      
//对于图例加入阴影
var vShadow=document.createElement("v:shadow");
vShadow.on="t";        
vShadow.type="single";
vShadow.color="graytext";
vShadow.offset="4px,4px";       
objLegendRect.appendChild(vShadow);
//将其放到图例的容器中
objLegendGroup.appendChild(objLegendRect);
this.LegendObject=objLegendGroup;vGroup.appendChild(objLegendGroup);

1 2  下一页

Tags:利用 vml 制作

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接