if(this.charttype == 'pie'){
this.buildPieLegend();
}
1){
numrows = numrows - 1;
}
var numcols = Math.ceil(this.itemnums / numrows);
var litemwidth = parent.expanded ? 80 : 30;
var litemheight = parent.expanded ? 14 : 8;
if(this.ltitle != null){
new lz.legendtitle(this, {name:'legendtitle', ltitle:this.ltitle, tposit:this.titleposition,
ttsize:(parent.expanded ? this.titletextsize : 10), tcolor:this.titlecolor});
}
this.setAttribute('width', litemwidth * numcols);
this.setAttribute('height', litemheight * numrows + (this.ltitle != null ? this.legendtitle.height : 0));
this.setAttribute('x', (parent.width - this.width) / 2);
if(this.posit == 'bottom'){
this.setAttribute('y', (this.centery + this.pieradius) +
(parent.height - this.centery - this.pieradius - this.height) / 2);
} else {
this.setAttribute('y', (this.centery - this.pieradius - this.height) / 2);
}
} else if(this.posit == 'left' || this.posit == 'right') {
var numcols = Math.floor(Math.sqrt(this.itemnums));
if(numcols > 1){
numcols = numcols - 1;
}
var numrows = Math.ceil(this.itemnums / numcols);
var litemwidth = parent.expanded ? 80 : 30;
var litemheight = parent.expanded ? 14 : 8;
if(this.ltitle != null){
new lz.legendtitle(this, {name:'legendtitle', ltitle:this.ltitle, tposit:this.titleposition,
ttsize:(parent.expanded ? this.titletextsize : 10), tcolor:this.titlecolor});
}
this.setAttribute('width', litemwidth * numcols);
this.setAttribute('height', litemheight * numrows + (this.ltitle != null ? this.legendtitle.height : 0));
if(this.posit == 'left'){
this.setAttribute('x', (this.centerx - this.pieradius - this.width) / 2);
this.setAttribute('y', (parent.height - this.height) / 2);
} else {
this.setAttribute('x', (this.centerx + this.pieradius) +
(parent.width - this.centerx - this.pieradius - this.width) / 2);
this.setAttribute('y', (parent.height - this.height) / 2);
}
} else {
this.setAttribute('width', this.legendwidth);
this.setAttribute('height', this.legendheight);
this.setAttribute('x', this.legendx);
this.setAttribute('y', this.legendy);
if(this.width / 4 > this.height){
var numrows = Math.floor(Math.sqrt(this.itemnums));
if(numrows > 1){
numrows = numrows - 1;
}
var numcols = Math.ceil(this.itemnums / numrows);
} else {
var numcols = Math.floor(Math.sqrt(this.itemnums));
if(numcols > 1){
numcols = numcols - 1;
}
var numrows = Math.ceil(this.itemnums / numcols);
}
if(this.ltitle != null){
new lz.legendtitle(this, {name:'legendtitle', ltitle:this.ltitle, tposit:this.titleposition,
ttsize:(parent.expanded ? this.titletextsize : 10), tcolor:this.titlecolor});
}
var litemwidth = (this.width / numcols);
var litemheight = (this.height / numrows);
}
for(var i = 0; i < this.piepieces.length; i++){
var pclink = this.piepieces[i];
new lz.legenditem(this, {itemvalue:parent[pclink]['piecevalue'],
lpiece:this.piepieces[i], width:litemwidth,
hlcolor:(this.hlcolor == null ? this.backcolor : this.hlcolor),
height:litemheight, iconcolor:this.piececolors[i],
itemlabel:this.legendvalues[i], iconshape:'triangle'});
}
this.fillStyle = this.backcolor;
this.strokeStyle = this.border;
this.lineWidth = this.borderwidth;
this.beginPath();
this.moveTo(-this.borderwidth,-this.borderwidth);
this.lineTo(this.width, -this.borderwidth);
this.lineTo(this.width, this.height);
this.lineTo(-this.borderwidth, this.height);
this.lineTo(-this.borderwidth,-this.borderwidth);
this.closePath();
if(this.backcolor != null){
this.fill();
}
if(this.border != null && this.borderwidth != 0){
this.stroke();
}
]]>
this.height){
var numrows = Math.floor(Math.sqrt(itemcount));
if(numrows > 1){
numrows = numrows - 1;
}
var numcols = Math.ceil(itemcount / numrows);
} else {
var numcols = Math.floor(Math.sqrt(itemcount));
if(numcols > 1){
numcols = numcols - 1;
}
var numrows = Math.ceil(itemcount / numcols);
}
if(this.ltitle != null){
numrows = numrows + 1;
}
var litemwidth = (this.width / numcols);
var litemheight = (this.height / numrows);
if(this.ltitle != null){
new lz.legendtitle(this, {name:'legendtitle', ltitle:this.ltitle, tposit:this.titleposition,
ttsize:this.titletextsize, tcolor:this.titlecolor});
}
// Create legend items.
for(var i = 0; i < dnum; i++){
var ll = parent.subnodes[dloc].subviews[i];
if(this.charttype == 'line'){
if(ll.lvdata != null &&
typeof ll.lvdata[0] != 'undefined'){
iconcolor = ll.lvdata[0];
} else {
iconcolor = ll.linesvisible;
}
} else if(ll.colordata != null &&
typeof ll.colordata[0] != 'undefined'){
iconcolor = ll.colordata[0];
} else {
iconcolor = ll.datacolor;
}
if(iconcolor.indexOf('x') != -1){
iconcolor = '#' + iconcolor.substring(iconcolor.indexOf('x')+1);
}
if(ll.legenddata != null &&
typeof ll.legenddata != 'undefined'){
itemlabel = ll.legenddata;
} else {
//itemlabel = ll.legenddatapath;
}
if(itemlabel != null){
new lz.legenditem(this, {itemvalue:itemlabel,
width:litemwidth, height:litemheight, dlink:ll,
hlcolor:(this.hlcolor == null ? this.backcolor : this.hlcolor),
height:this.height, iconcolor:iconcolor, textcolor:this.textcolor,
textsize:this.textsize, itemlabel:itemlabel, iconshape:'square'});
}
}
} else if(this.resizetodata == 'wide'){
var numrows = Math.floor(Math.sqrt(itemcount));
if(numrows > 1){
numrows = numrows - 1;
}
var numcols = Math.ceil(itemcount / numrows);
var litemwidth = 80;
var litemheight = 14;
if(this.ltitle != null){
new lz.legendtitle(this, {name:'legendtitle', ltitle:this.ltitle, tposit:this.titleposition,
ttsize:this.titletextsize, tcolor:this.titlecolor});
}
this.setAttribute('width', litemwidth * numcols);
this.setAttribute('height', litemheight * numrows + (this.ltitle != null ? this.legendtitle.height : 0));
// Create legend items.
for(var i = 0; i < dnum; i++){
var ll = parent.subnodes[dloc].subviews[i];
if(this.charttype == 'line'){
if(ll.lvdata != null &&
typeof ll.lvdata[0] != 'undefined'){
iconcolor = ll.lvdata[0];
} else {
iconcolor = ll.linesvisible;
}
} else if(ll.colordata != null &&
typeof ll.colordata[0] != 'undefined'){
iconcolor = ll.colordata[0];
} else {
iconcolor = ll.datacolor;
}
if(iconcolor.indexOf('x') != -1){
iconcolor = '#' + iconcolor.substring(iconcolor.indexOf('x')+1);
}
if(ll.legenddata != null &&
typeof ll.legenddata != 'undefined'){
itemlabel = ll.legenddata;
} else {
//itemlabel = ll.legenddatapath;
}
if(itemlabel != null){
new lz.legenditem(this, {itemvalue:itemlabel,
width:litemwidth, height:litemheight, dlink:ll,
hlcolor:(this.hlcolor == null ? this.backcolor : this.hlcolor),
height:this.height, iconcolor:iconcolor, textcolor:this.textcolor,
textsize:this.textsize, itemlabel:itemlabel, iconshape:'square'});
}
}
} else if(this.resizetodata == 'tall'){
var numcols = Math.floor(Math.sqrt(itemcount));
if(numcols > 1){
numcols = numcols - 1;
}
var numrows = Math.ceil(itemcount / numcols);
var litemwidth = 80;
var litemheight = 14;
if(this.ltitle != null){
new lz.legendtitle(this, {name:'legendtitle', ltitle:this.ltitle, tposit:this.titleposition,
ttsize:this.titletextsize, tcolor:this.titlecolor});
}
this.setAttribute('width', litemwidth * numcols);
this.setAttribute('height', litemheight * numrows + (this.ltitle != null ? this.legendtitle.height : 0));
// Create legend items.
for(var i = 0; i < dnum; i++){
var ll = parent.subnodes[dloc].subviews[i];
if(this.charttype == 'line'){
if(ll.lvdata != null &&
typeof ll.lvdata[0] != 'undefined'){
iconcolor = ll.lvdata[0];
} else {
iconcolor = ll.linesvisible;
}
} else if(ll.colordata != null &&
typeof ll.colordata[0] != 'undefined'){
iconcolor = ll.colordata[0];
} else {
iconcolor = ll.datacolor;
}
if(iconcolor.indexOf('x') != -1){
iconcolor = '#' + iconcolor.substring(iconcolor.indexOf('x')+1);
}
if(ll.legenddata != null &&
typeof ll.legenddata != 'undefined'){
itemlabel = ll.legenddata;
} else {
//itemlabel = ll.legenddatapath;
}
if(itemlabel != null){
new lz.legenditem(this, {itemvalue:itemlabel,
width:litemwidth, height:litemheight, dlink:ll,
hlcolor:(this.hlcolor == null ? this.backcolor : this.hlcolor),
height:this.height, iconcolor:iconcolor, textcolor:this.textcolor,
textsize:this.textsize, itemlabel:itemlabel, iconshape:'square'});
}
}
}
this.fillStyle = this.backcolor;
this.strokeStyle = this.border;
this.lineWidth = this.borderwidth;
this.beginPath();
this.moveTo(-this.borderwidth,-this.borderwidth);
this.lineTo(this.width, -this.borderwidth);
this.lineTo(this.width, this.height);
this.lineTo(-this.borderwidth, this.height);
this.lineTo(-this.borderwidth,-this.borderwidth);
this.closePath();
if(this.backcolor != null){
this.fill();
}
if(this.border != null && this.borderwidth != 0){
this.stroke();
}
this.setAttribute('legenddrawn', true);
]]>
var dloc = parent.findData();
var snum = parent.subnodes[dloc].subviews.length;
(See barchart, linechart, or piechart for an example.)
if(this.itemlabel != null){
this.ltext.setAttribute('text', itemlabel);
} else {
this.ltext.setAttribute('text', itemvalue);
}
this.setAttribute('bgcolor', this.hlcolor);
if(parent.charttype == 'pie'){
parent.parent[this.lpiece].setAttribute('exploded', true);
}
this.setAttribute('bgcolor', parent.backcolor);
if(parent.charttype == 'pie'){
parent.parent[this.lpiece].setAttribute('exploded', false);
}
if(parent.charttype != "pie"){
this.dlink.setAttribute('dataenabled', !this.dlink.dataenabled);
}
if(parent.charttype == "line"){
parent.parent.ondata.sendEvent();
}
this.fillStyle = parent.iconcolor;
this.beginPath();
if(parent.iconshape == 'triangle'){
this.moveTo(2, 2);
this.lineTo(parent.height - 2, parent.height - 2);
this.lineTo(2, parent.height - 2);
this.lineTo(2, 2);
}
if(parent.iconshape == 'square'){
this.moveTo(2, 2);
this.lineTo(parent.height - 2, 2);
this.lineTo(parent.height - 2, parent.height - 2);
this.lineTo(2, parent.height - 2);
this.lineTo(2, 2);
}
this.closePath();
this.fill();
this.stroke();
(See barchart, linechart, or piechart for an example.)
(See barchart, linechart, or piechart for an example.)