databar.lzx
<library>
<class name="databar" visible="${this.datalink.dataenabled}">
<attribute name="datalink" value="$once{null}"/>
<attribute name="tooltip" type="boolean" value="false
"/>
<attribute name="animationinit" type="string" value="
"/>
<attribute name="realheight" type="number" value="$once{this.height}"/>
<attribute name="realwidth" type="number" value="$once{this.width}"/>
<attribute name="realy" type="number" value="0
"/>
<attribute name="realx" type="number" value="0
"/>
<attribute name="dataresource" type="string" value="
"/>
<attribute name="drawaxis" type="string" value="x
"/>
<attribute name="siblingbars" type="number" value="0
"/>
<attribute name="barspace" type="number" value="0
"/>
<attribute name="barnumber" type="number" value="0
"/>
<attribute name="barset" type="number" value="0
"/>
<attribute name="totalsets" type="number" value="0
"/>
<attribute name="bvalue" type="number" value="0
"/>
<handler name="onmouseover">
if(this.tooltip){
}
</handler>
<handler name="oninit" method="initBar"/>
<method name="initBar" args="ignore">
// Constrains width and positioning to the size and scale of
// the bar view.
if(this.drawaxis == 'x'){
var d = [parent, "width"];
this.applyConstraintMethod("__constraintAxisX_width", d);
var dd = [this, "width"];
this.applyConstraintMethod("__constraintAxisX_x", dd);
var ddd = [parent.classroot, "scaler"];
this.applyConstraintMethod("__constraintAxisX_height", ddd);
var h = [parent, "height"];
this.applyConstraintMethod("__constraintAxisX_y", h);
} else {
var d = [parent, "height"];
this.applyConstraintMethod("__constraintAxisY_height", d);
var dd = [this, "height"];
this.applyConstraintMethod("__constraintAxisY_y", dd);
var ddd = [parent.classroot, "altscaler"];
this.applyConstraintMethod("__constraintAxisY_width", ddd);
var h = [parent, "width"];
this.applyConstraintMethod("__constraintAxisY_x", h);
}
// Sends bars behind labels.
this.sendBehind(parent.subnodes[2]);
if(this.dataresource){
this.setSource(this.dataresource);
}
this.setAttribute('realx', this.x);
this.setAttribute('realy', this.y);
// Performs animation if set.
if(this.animationinit && !parent.anicomplete){
if(animationinit == "fadein"){
this.fadein.doStart();
}
if(animationinit == "growdown"){
this.growdown.doStart();
}
if(animationinit == "unblink"){
this.unblink.doStart();
}
if(animationinit == "rain"){
this.rain.doStart();
}
if(animationinit == "slideover"){
this.slideover.doStart();
}
}
</method>
<method name="__constraintAxisX_x" args="ignore">
this.setAttribute("x", ((this.barnumber * this.totalsets) *
(this.width + this.barspace)) + ((this.width + this.barspace) *
this.barset));
</method>
<method name="__constraintAxisX_y" args="ignore">
if(this.bvalue < 0){
this.setAttribute("y", parent.height - (Math.abs(parent.classroot.minimum) * parent.classroot.scaler));
} else {
this.setAttribute("y", parent.height - (Math.abs(parent.classroot.minimum) * parent.classroot.scaler) -
this.height - (parent.classroot.zerowidth / 2));
}
</method>
<method name="__constraintAxisX_width" args="ignore">
this.setAttribute("width",
(parent.width / this.siblingbars) - this.barspace);
</method>
<method name="__constraintAxisX_height" args="ignore">
this.setAttribute("height", Math.abs(this.bvalue) * parent.classroot.scaler);
</method>
<method name="__constraintAxisY_x" args="ignore">
this.setAttribute("x", (Math.abs(parent.classroot.minimum) * parent.classroot.altscaler) -
(parent.classroot.zerowidth / 2) - (this.bvalue < 0 ? this.width : 0));
</method>
<method name="__constraintAxisY_y" args="ignore">
this.setAttribute("y", ((this.barnumber * this.totalsets) *
(this.height + this.barspace)) + ((this.height + this.barspace) *
this.barset));
</method>
<method name="__constraintAxisY_width" args="ignore">
this.setAttribute("width", Math.abs(this.bvalue) * parent.classroot.altscaler);
</method>
<method name="__constraintAxisY_height" args="ignore">
this.setAttribute("height",
(parent.height / this.siblingbars) - this.barspace);
</method>
<animator name="fadein" attribute="opacity" from="0" to="1" duration="5000" start="false"/>
<animator name="growdown" attribute="${parent.drawaxis == 'x' ? 'height' : 'width'}" from="0" to="${parent.drawaxis == 'x' ? parent.realheight : parent.realwidth}" duration="5000" start="false"/>
<animator name="unblink" attribute="${parent.drawaxis == 'x' ? 'width' : 'height'}" from="0" to="${parent.drawaxis == 'x' ? parent.realwidth : parent.realheight}" duration="5000" start="false"/>
<animator name="rain" attribute="${parent.drawaxis == 'x' ? 'y' : 'x'}" from="${Math.random(1, 10) * 100}" to="${parent.drawaxis == 'x' ? parent.realy : parent.realx}" duration="${Math.random(1, 10) * 10000}" start="false"/>
<animator name="slideover" attribute="${parent.drawaxis == 'x' ? 'x' : 'y'}" from="-100" to="${parent.drawaxis == 'x' ? parent.realx : parent.realy}" duration="5000" start="false"/>
<doc>
<tag name="shortdesc">
<text>
(See barchart for an example.)
</text>
</tag>
</doc>
</class>
</library>