label.lzx
<library>
<include href="extensions/drawview.lzx"/>
<class name="label" extends="drawview" width="${this.realtext.width + 4}" height="${this.realtext.height + 4}" visible="${this.datalink != null ? this.datalink.dataenabled : true}">
<attribute name="ltext" type="color" value="$once{null}"/>
<attribute name="ltextsize" type="number" value="10
"/>
<attribute name="lborder" type="color" value="#000000
"/>
<attribute name="lbwidth" type="number" value="1
"/>
<attribute name="ltcolor" type="color" value="#000000
"/>
<attribute name="rvalx" type="number" value="0
"/>
<attribute name="rvaly" type="number" value="0
"/>
<attribute name="fadein" type="boolean" value="false
"/>
<attribute name="datalink" value="$once{null}"/>
<attribute name="drawaxis" type="string" value="x
"/>
<attribute name="labelnumber" type="number" value="0
"/>
<attribute name="labelset" type="number" value="0
"/>
<attribute name="charttype" type="string" value="line
"/>
<attribute name="barlink" value="${parent['bar'+this.labelset+this.labelnumber]}"/>
<handler name="oncontext" method="initLabel"/>
<handler name="onmouseover" method="bringToFront"/>
<method name="initLabel" args="ignore">
if(this.charttype == "bar"){
if(this.drawaxis == 'x'){
var d = [this.barlink, "x"];
this.applyConstraintMethod("__constraintBarX_x", d);
var dd = [this.barlink, "y"];
this.applyConstraintMethod("__constraintBarX_y", dd);
if(this.fadein == true){
this.fader.doStart();
}
} else {
var d = [this.barlink, "x"];
this.applyConstraintMethod("__constraintBarY_x", d);
var dd = [this.barlink, "y"];
this.applyConstraintMethod("__constraintBarY_y", dd);
if(this.fadein == true && parent.anicomplete == false){
this.fader.doStart();
}
}
} else if(this.charttype == "line"){
var d = [parent.classroot, "altscaler"];
this.applyConstraintMethod("__constraintLine_x", d);
var dd = [parent.classroot, "scaler"];
this.applyConstraintMethod("__constraintLine_y", dd);
} else if(this.charttype == "pie"){
this.setAttribute('x', this.x - this.width / 2);
this.setAttribute('y', this.y - this.height / 2);
}
</method>
<method name="__constraintBarX_x" args="ignore">
this.setAttribute("x", this.barlink.x + (this.barlink.width / 2) -
(this.width / 2));
</method>
<method name="__constraintBarX_y" args="ignore">
this.setAttribute("y", this.barlink.y - this.height - 4);
</method>
<method name="__constraintBarY_x" args="ignore">
this.setAttribute("x", (Math.abs(parent.classroot.minimum) * parent.classroot.altscaler) +
this.barlink.width + 4);
</method>
<method name="__constraintBarY_y" args="ignore">
this.setAttribute("y", this.barlink.y + ((this.barlink.height - this.height) / 2));
</method>
<method name="__constraintLine_x" args="ignore">
this.setAttribute("x", parent.classroot.altscaler * this.rvalx +
parent.classroot.altzero);
</method>
<method name="__constraintLine_y" args="ignore">
this.setAttribute("y", parent.classroot.dataclip.datapane.height -
(parent.classroot.scaler * this.rvaly) -
(parent.classroot.minimum * parent.classroot.scaler * -1) - this.height - 3);
</method>
<method name="renderBorder">
this.strokeStyle = this.lborder;
this.lineWidth = this.lbwidth;
this.beginPath();
this.moveTo(0,0);
this.lineTo((this.width - 1), 0);
this.lineTo((this.width - 1), (this.height - 1));
this.lineTo(0, (this.height - 1));
this.lineTo(0,0);
this.stroke();
</method>
<text name="realtext" resize="true" text="${parent.ltext}" fontsize="${parent.ltextsize}" x="${(parent.width - this.width) / 2}" fgcolor="${parent.ltcolor}" y="${(parent.height - this.height) / 2 - 1}">
<handler name="ontext">
if(this.sprite.width != 0 && this.sprite.width != 4){
parent.setAttribute('width', this.sprite.width + 4);
if(parent.context){
parent.renderBorder();
}
}
</handler>
</text>
<animator name="fader" attribute="opacity" from="0" to="1" duration="5000" start="false"/>
<doc>
<tag name="shortdesc">
<text>
(See barchart, linechart, or piechart for an example.)
</text>
</tag>
</doc>
</class>
<class name="ticklabel" extends="view" width="${this.realtext.width}" visible="${this.datalink != null ? this.datalink.dataenabled : true}" height="${this.realtext.height}">
<attribute name="ltext" type="string" value="0
"/>
<attribute name="ltcolor" type="color" value="#000000
"/>
<attribute name="ltextsize" type="number" value="10
"/>
<attribute name="datalink" value="$once{null}"/>
<attribute name="ticklength" type="number" value="0
"/>
<attribute name="tickaxis" type="string" value="y
"/>
<attribute name="labelnumber" type="number" value="$once{null}"/>
<attribute name="labelset" type="number" value="$once{null}"/>
<attribute name="numlabels" type="number" value="0
"/>
<attribute name="loffset" type="number" value="0
"/>
<attribute name="charttype" type="string" value="line
"/>
<attribute name="labelangle" type="number" value="$once{null}"/>
<handler name="oninit" method="initLabel"/>
<method name="initLabel" args="ignore">
if(this.tickaxis == 'x'){
var barlink = parent.classroot.parent.dataclip.datapane['bar'+this.labelset+
this.labelnumber];
if(this.labelset != null){
var d = [barlink, "x"];
this.applyConstraintMethod("__constraintTickXLabel_x", d);
this.setAttribute('y', this.y + this.ticklength + this.loffset);
} else {
// Really only needed to compensate for this little issue with the
// barchart directional switch.
if(this.charttype == 'bar'){
var cm = "__constraintTickXNoLabelBar_x";
} else {
var cm = "__constraintTickXNoLabel_x";
}
var d = [parent, "width"];
this.applyConstraintMethod(cm, d);
}
} else {
var barlink = parent.classroot.parent.dataclip.datapane['bar'+this.labelset+
this.labelnumber];
if(this.labelset != null){
var d = [barlink, "y"];
this.applyConstraintMethod("__constraintTickYLabel_y", d);
this.setAttribute('x', this.x - this.width - this.ticklength - this.loffset);
} else {
this.setAttribute('x', parent.width - this.width - this.ticklength - 4);
var d = [parent, "height"];
this.applyConstraintMethod("__constraintTickYNoLabel_y", d);
}
}
if(this.labelangle != null){
this.realtext.setAttribute('rotation', this.labelangle);
}
</method>
<method name="__constraintTickXLabel_x" args="ignore">
this.setAttribute("x", barlink.x + (barlink.width / 2) -
(this.width / 2));
</method>
<method name="__constraintTickXNoLabelBar_x" args="ignore">
this.setAttribute("x", ((parent.width / this.numlabels) *
(this.labelnumber)) - (this.width / 2) -
((parent.classroot.parent.minimum % parent.classroot.parent.hgridspacing) *
parent.classroot.parent.altscaler));
</method>
<method name="__constraintTickXNoLabel_x" args="ignore">
this.setAttribute("x", ((parent.width / this.numlabels) *
(this.labelnumber)) - (this.width / 2) -
((parent.classroot.parent.altminimum % parent.classroot.parent.vgridspacing) *
parent.classroot.parent.altscaler));
</method>
<method name="__constraintTickYLabel_y" args="ignore">
this.setAttribute("y", barlink.y + ((barlink.height - this.height) / 2));
</method>
<method name="__constraintTickYNoLabel_y" args="ignore">
this.setAttribute("y", parent.height - ((parent.height / this.numlabels) *
this.labelnumber) - ((parent.classroot.parent.minimum %
parent.classroot.parent.hgridspacing) * parent.classroot.parent.scaler * -1) -
(this.height / 2));
</method>
<text name="realtext" resize="true" text="${parent.ltext}" fontsize="${parent.ltextsize}" x="${(parent.width - this.width) / 2}" fgcolor="${parent.ltcolor}" y="${(parent.height - this.height) / 2}">
<handler name="ontext">
if(this.sprite.width != 0 && this.sprite.width != 4){
parent.setAttribute('width', this.sprite.width);
}
</handler>
</text>
<doc>
<tag name="shortdesc">
<text>
(See barchart, linechart, or piechart for an example.)
</text>
</tag>
</doc>
</class>
</library>
Cross References
Includes
Classes
- <class name="label" extends="drawview">
- <class name="ticklabel" extends="view">