piepiece.lzx
<library>
<class name="piepiece" extends="drawview" clickable="false" width="${parent.width}" height="${parent.height}">
<attribute name="piececolor" type="color" value="$once{null}"/>
<attribute name="bordercolor" type="color" value="$once{null}"/>
<attribute name="borderwidth" type="number" value="1
"/>
<attribute name="piecevalue" type="number" value="0
"/>
<attribute name="pieceradius" type="number" value="0
"/>
<attribute name="pieceopacity" type="number" value="1
"/>
<attribute name="centerx" type="number" value="0
"/>
<attribute name="centery" type="number" value="0
"/>
<attribute name="piecepercent" type="number" value="0
"/>
<attribute name="startpercent" type="number" value="0
"/>
<attribute name="exploded" type="boolean" value="${parent.wedgeover == this}"/>
<attribute name="explode" type="boolean" value="false
"/>
<attribute name="collapsex" type="number" value="$once{this.x}"/>
<attribute name="collapsey" type="number" value="$once{this.y}"/>
<handler name="oncontext" method="renderThis"/>
<event name="onexploded"/>
<handler name="onexploded">
if(this.explode && this.exploded == true){
this.explodeThis();
} else {
if(this.explode){
this.collapseThis();
}
}
</handler>
<handler name="onmouseover">
</handler>
<handler name="onmouseout">
</handler>
<handler name="onclick">
</handler>
<method name="renderThis" args="ignore">
if(this.pieceopacity != null && typeof this.pieceopacity != 'undefined'){
this.globalAlpha = this.pieceopacity;
}
if(this.piececolor != null && typeof this.piececolor != 'undefined'){
this.fillStyle = this.piececolor;
}
if(this.bordercolor != null && typeof this.bordercolor != 'undefined'){
this.strokeStyle = this.bordercolor;
}
if(this.borderwidth != null && typeof this.borderwidth != 'undefined'){
this.lineWidth = this.borderwidth;
}
var startpos = (2 * Math.PI) * startpercent;
var endpos = startpos + ((2 * Math.PI) * piecepercent);
this.beginPath();
var sx = this.centerx - this.pieceradius * Math.cos(((2 * Math.PI) / 2) - startpos);
var sy = this.centery - this.pieceradius * Math.sin(startpos);
this.moveTo(centerx, centery);
this.lineTo(sx, sy);
this.arc(centerx, centery, this.pieceradius, startpos, endpos, false);
this.lineTo(centerx, centery);
this.closePath();
this.fill();
if(this.borderwidth != 0 && this.borderwidth != null){
this.stroke();
}
</method>
<method name="explodeThis">
var startpos = (2 * Math.PI) * startpercent;
var endpos = startpos + ((2 * Math.PI) * piecepercent);
var midpos = (endpos + startpos) / 2;
var sx = this.centerx - this.pieceradius * Math.cos(((2 * Math.PI) / 2) - midpos);
var sy = this.centery - this.pieceradius * Math.sin(midpos);
var ratx = this.centerx - sx;
var raty = this.centery - sy;
this.setAttribute('x', this.x - (.08 * (ratx)));
this.setAttribute('y', this.y - (.08 * (raty)));
</method>
<method name="collapseThis">
this.setAttribute('x', this.collapsex);
this.setAttribute('y', this.collapsey);
</method>
<doc>
<tag name="shortdesc">
<text>
(See piechart for an example.)
</text>
</tag>
</doc>
</class>
<class name="backcircle" extends="drawview" width="${parent.width}" height="${parent.height}">
<attribute name="drawbg" type="color" value="0xCCCCCC
"/>
<attribute name="drawbgborder" type="color" value="0x000000
"/>
<attribute name="bgborderwidth" type="number" value="1
"/>
<attribute name="pieradius" type="number" value="0
"/>
<attribute name="ctrx" type="number" value="0
"/>
<attribute name="ctry" type="number" value="0
"/>
<handler name="oncontext">
if(this.drawbg != null){
this.fillStyle = this.drawbg;
}
if(this.drawbgborder != null){
this.strokeStyle = this.drawbgborder;
}
if(this.bgborderwidth != null){
this.lineWidth = this.bgborderwidth;
}
this.beginPath();
this.arc(this.ctrx, this.ctry, this.pieradius, 0, 2 * Math.PI, false);
this.fill();
this.stroke();
</handler>
<doc>
<tag name="shortdesc">
<text>
(See piechart for an example.)
</text>
</tag>
</doc>
</class>
</library>