dataseries.lzx
<library>
<class name="datacolumn">
<attribute name="columndatapath" type="string" value="
"/>
<attribute name="labeldatapath" type="string" value="
"/>
<attribute name="values" value="$once{null}"/>
<attribute name="datatype" value="string
" type="string"/>
<attribute name="datadone" value="false
" type="boolean"/>
<view name="dataview" visible="false">
<handler name="ondata">
parent.getRootDataSeries().ondata.sendEvent();
</handler>
</view>
<method name="getMin">
var min;
if(values != null){
if(values.length > 0)
{
min = values[0];
}
for(var i = 1; i < values.length; i++)
{
if(values[i] < min)
{
min = values[i];
}
}
return min;
} else {
return 0;
}
</method>
<method name="getMax">
var max;
if(values != null){
if(values.length > 0)
{
max = values[0];
}
for(var i = 1; i < values.length; i++)
{
if(max < values[i])
{
max = values[i];
}
}
return max;
} else {
return 0;
}
</method>
<method name="processData" args="value">
return value;
</method>
<method name="getNestedAttribute" args="attName">
//Debug.write("attribeName " + attName);
//Debug.write("attribeValue " + this[attName]);
if((this[attName] != "") && (this[attName] != null))
{
//Debug.write("attribeValue " + this[attName]);
return this[attName];
}
else
{
return parent.getNestedAttribute(attName);
}
</method>
<method name="getDataPath">
var obj = this;
while(obj != canvas)
{
if(obj["datapath"] != null)
{
return obj.datapath;
}
obj = obj.parent;
}
return null;
</method>
<method name="loadData">
var dp = this.getDataPath();
if(dp == null){
return;
}
if(dp.xpathQuery(this.columndatapath) != undefined){
this.values = dp.xpathQuery(this.columndatapath);
if(this.datatype == "number")
{
//FIXME(peter, 4/12/2005): is there a faster way of converting string to a number
for(var i = 0; i < this.values.length; i++)
{
this.values[i] = this.processData(new Number(this.values[i]));
}
}
else
{
for(var i = 0; i < this.values.length; i++)
{
this.values[i] = this.processData(this.values[i]);
}
}
this.dataview.setAttribute('datapath', this.columndatapath);
}
</method>
<method name="clearCache">
//Debug.write("data column clear Cache");
this.values = null;
</method>
<method name="datachange">
//Debug.write("********column datachange ")
//this.values = null;
</method>
<method name="getRootDataSeries">
var objectplace = this;
while(objectplace.parent instanceof lz.dataseries){
if(parent instanceof lz.dataseries){
objectplace = objectplace.parent;
} else {
break;
}
}
return objectplace;
</method>
<handler name="ondata">
//this.getRootDataseries().ondata.sendEvent();
</handler>
<doc>
<tag name="shortdesc"><text>
a series of data
</text></tag>
<text>
<warning>This component is of Beta quality and is subject to change.</warning>
</text>
</doc>
</class>
<class name="dataseries">
<doc>
<text>
<warning>This component is of Beta quality and is subject to change.</warning>
</text>
</doc>
<attribute name="enabled" value="true
"/>
<attribute name="label" type="html" value="
"/>
<attribute name="dataseriesleafs" value="$once{[]}"/>
<attribute name="datacolumnsmap" value="$once{new Object()}"/>
<method name="getNestedAttribute" args="attName">
//Debug.write("getNestedAttribute: " + attName);
//Debug.write("getNestedAttributeValue: " + this[attName]);
if((this[attName] != "") && (this[attName] != null))
{
return this[attName];
}
else if(parent instanceof lz.dataseries)
{
return parent.getNestedAttribute(attName);
}
else
{
return "";
}
</method>
<method name="getDataColumn" args="name">
//Debug.write("datacolumnsmap[name]: " + datacolumnsmap[name]);
if(name != undefined){
if(datacolumnsmap[name] && datacolumnsmap[name].values)
{
return datacolumnsmap[name];
}
for(var i = 0; i < this.subnodes.length; i++)
{
//Debug.write("subnodename: " + this.subnodes[i].name);
if((this.subnodes[i] instanceof lz.datacolumn) && (this.subnodes[i].name == name))
{
datacolumnsmap[name] = this.subnodes[i];
datacolumnsmap[name].loadData();
return datacolumnsmap[name];
}
}
if(parent instanceof lz.dataseries)
{
return parent.getDataColumn(name);
}
}
return null;
</method>
<method name="getNumDataSeries"> //get the Number of leaf dataseries
return this.dataseriesleafs != null?this.getDataSeriesLeafs().length:0;
</method>
<method name="getDataSeries" args="index"> //get the leaf dataseries of that index
return this.getDataSeriesLeafs()[index];
</method>
<method name="getDataSeriesLeafs">
if(this.dataseriesleafs != null){
if(this.dataseriesleafs.length > 0){
return this.dataseriesleafs;
}
for(var i = 0; i < this.subnodes.length; i++){
var childDataSeries = this.subnodes[i];
if(childDataSeries instanceof lz.dataseries){
this.dataseriesleafs = this.dataseriesleafs.concat(childDataSeries.getDataSeriesLeafs());
}
}
if(this.dataseriesleafs.length == 0){
this.dataseriesleafs.push(this);
}
}
return this.dataseriesleafs;
</method>
<method name="getLegend">
var dscounter = 1;
// The counter serves to keep track of the number of legends on the
// canvas. This fixes the issue with multiple charts all ending up
// with the same legend text.
var ds = canvas["legendds"];
if(!canvas["legendds"])
{
ds = new lz.dataset(canvas, { name: "legendds"});
canvas["legendds"] = ds;
} else {
dscounter++;
ds = new lz.dataset(canvas, { name: "legendds"+dscounter});
canvas["legendds"+dscounter] = ds;
}
ds.childNodes = [];
var series = this.getDataSeriesLeafs();
var dp = ds.getPointer();
if( parent.constructor.tagname == 'piechart') {
if(parent.getDataSeries().getDataSeries(0).getDataColumn("x") != null){
var xseries = parent.getDataSeries().getDataSeries(0).getDataColumn("x").values;
} else {
var xseries = null;
}
if(xseries != null){
for (var i=0 ; i<xseries.length ; i++ ) {
dp.addNode("item", "", {name: xseries[i]});
}
}
} else {
var yseriesname = (parent.constructor.tagname == 'barchart'? 'x' : 'y');
for(var i = 0; i < series.length; i++)
{
var aseries = series[i];
if(aseries.getDataColumn(yseriesname) != null)
{
dp.addNode("item", "", {name: aseries.label});
}
}
}
return dp;
</method>
<method name="getRootDataSeries">
var objectplace = this;
while(objectplace.parent instanceof lz.dataseries){
if(parent instanceof lz.dataseries){
objectplace = objectplace.parent;
} else {
break;
}
}
return objectplace;
</method>
<method name="clearCache">
for(var i = 0; i < this.subnodes.length; i++)
{
if(this.subnodes[i]["clearCache"])
{
this.subnodes[i].clearCache();
}
}
this.dataseriesleafs = [];
</method>
<method name="addDataSeries" args="args">
this.clearCache();
var childNode = new lz.dataseries(this, args);
this.clearCache();
return childNode;
</method>
<method name="removeDataSeries" args="child">
this.clearCache();
child.destroy();
</method>
<method name="addDataColumn" args="args">
this.clearCache();
var childNode = new lz.datacolumn(this, args);
return childNode;
</method>
<method name="removeDataColumn" args="child">
this.clearCache();
child.destroy();
</method>
<handler name="ondata">
// Have to keep this from happening on linechart, or else it doesn't
// draw it properly the first time. This may need to be fixed. -JC
if(this.getRootDataSeries().parent.constructor.tagname != "linechart"){
this.clearCache();
this.setAttribute("datadone", true);
}
</handler>
</class>
</library>