闲来无事,做着完,效率不高,功能也不好
code
//绘制扇形统计图
importfj.graphics.*;
importfj.seach.JToolTip;
importfj.math.JDegree;
test=JGDI.getInstance();
test.target=_root;
vara=[30,30,15,10,15];
varb=["第一季度","第二季度","第三季度","第四季度","第五季度"];
drawing(a);
deletea;
functiontrans(a:Array){
//把数据进行转换
varl=a.length;
vart=0;
for(vari=0;i
t+=a[i];
}
for(vari=0;i
a[i]=a[i]*360/t;
}
}
functiondrawing(a){
//绘图函数
trans(a);
varc=[];
varl=a.length;
vart1=0;
vart2=0;
for(vari=0;i
t2+=a[i];
t1=t2-a[i];
c[i]=(t1+t2)/2;
vartemp=this.createEmptyMovieClip("draw"+i,i);
test.target=temp;
test.fillSector(newJSolidBrush(random(0xff9900),20),200,150,150,150,t1,t2);
test.drawSector(newJPen(2,0xff0000,60),200,150,150,150,t1,t2);
newJToolTip().setToolTip(temp,b[i]+":"+Math.round(a[i]*100/360)+"%");
temp.i=i;
temp.x=this._x;
temp.y=this._y;
temp.onEnterFrame=function(){
if(this.hitTest(_xmouse,_ymouse,true)){
varx=JDegree.cosD(c[this.i])*20;
vary=JDegree.sinD(c[this.i])*20;
this._x=this.x+x;
this._y=this.y+y;
}else{
this._x=this.x;
this._y=this.y;
}
};
}
}