var str;
var cDiv1=document.createElement("div");

function Graph(width, height, vPixels, eachBarWidth, eachGroupWidth, xTickValueMaxCharLen, xTickValueMaxLength, stacked) {
this.stacked = stacked;
this.width = width || 400;
this.height = height || 200;
this.vPixels=vPixels;
this.eachBarWidth=eachBarWidth;
this.eachGroupWidth=eachGroupWidth;
this.rows = new Array();
this.addRow = _addRowGraph;
this.setXScale = _setXScaleGraph;
this.setXScaleValues = _setXScaleValuesGraph;
this.setTime = _setStartTimeGraph;
this.setDate = _setStartDateGraph;
this.build = _buildGraph;
this.setLegend = _setLegendGraph;
this.writeLegend = _writeLegendGraph;
this.offset = 0;
this.titleSpacerHeight=20;
this.yLabelWidth=150;
this.yTickValueWidth=50;
this.yTickValueHeight=13;
this.yTickMarkWidth=6;
this.yTickMarkHeight=1;
this.yAxisWidth=1;
this.xAxisHeight=1;
this.xTickMarkHeight=6;
this.xTickMarkWidth=1;
this.xTickValueMaxCharLen=xTickValueMaxCharLen;
if (word==0) this.xTickValueMaxLength=xTickValueMaxLength
else this.xTickValueMaxLength=xTickValueMaxLength*3
this.xLabelHeight=30;
this.legendSpacerWidth=10;
this.tickValueFontSize=10;
this.labelFontSize=14;
this.legendHeadFontSize=14;
this.legendFontSize=12;
if (word==0) this.xTickValueVertical=(this.eachGroupWidth<this.xTickValueMaxCharLen*this.tickValueFontSize*.8)
else this.xTickValueVertical=(this.eachGroupWidth<this.xTickValueMaxCharLen*this.tickValueFontSize)
if (this.xTickValueVertical==true) {
if (word==0 ) {
if (_app=='Microsoft Internet Explorer') this.xTickValueHeight=Math.ceil(this.xTickValueMaxLength/Math.max(1,Math.floor(this.eachGroupWidth*.5/this.tickValueFontSize))*this.tickValueFontSize*.7)
else this.xTickValueHeight=this.xTickValueMaxLength*this.tickValueFontSize*0.95
} else this.xTickValueHeight=Math.ceil((this.xTickValueMaxLength/2)*this.tickValueFontSize*.81)
} else {
if (word==0 ) this.xTickValueHeight=Math.ceil(this.xTickValueMaxLength/this.xTickValueMaxCharLen*1.2)*this.tickValueFontSize
else this.xTickValueHeight=Math.ceil(this.xTickValueMaxLength/3/this.xTickValueMaxCharLen*1.2)*this.tickValueFontSize
}
this.chartFootHeight=50;
this.container=document.createElement("div");
document.getElementById("resultC").appendChild(this.container);
document.getElementById("resultC").lastChild.id="chartProper";
this.container.style.position="relative";
this.container.style.width=this.width+this.yLabelWidth+this.yTickValueWidth+this.yTickMarkWidth+this.yAxisWidth+this.legendSpacerWidth+250;
this.container.style.height=this.titleSpacerHeight+this.vPixels+this.xAxisHeight+this.xTickMarkHeight+this.xLabelHeight+this.xTickValueHeight+50+"px";
this.container.style.border='solid black 1px';
document.getElementById("resultC").position="absolute";
document.getElementById("resultC").style.width=this.width+this.yLabelWidth+this.yTickValueWidth+this.yTickMarkWidth+this.yAxisWidth+this.legendSpacerWidth+250;
document.getElementById("resultC").style.height=this.titleSpacerHeight+this.vPixels+this.xAxisHeight+this.xTickMarkHeight+this.xLabelHeight+this.xTickValueHeight+this.chartFootHeight+140+"px";
return this;
}


function _setLegendGraph(yLabelSeries) {
this.legends=yLabelSeries;
}
function _addRowGraph(yValueSeries) {
this.rows[this.rows.length] = new Array();
var row = this.rows[this.rows.length-1];
for(var i = 0; i < yValueSeries.length; i++) row[row.length] = yValueSeries[i]
}
function _rescaleGraph(g) {
g.posMax = 0, g.negMax = 0, g.c = 0;
for(var i = 0; i < g.rows.length; i++) {
for(var j = 0; j < g.rows[i].length; j++) {
g.c++;
if(g.rows[i][j] > g.posMax) g.posMax = g.rows[i][j];
if(g.rows[i][j] < g.negMax) g.negMax = g.rows[i][j];
}
}
g.vscale = Math.ceil(g.vPixels/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))/g.scale;
g.hscale = Math.ceil(g.width/g.c-1/g.rows[0].length);
}
function _stackRescaleGraph(g) {
var m, n, c = 0;
g.posMax = 0, g.negMax = 0;
for(var i = 0; i < g.rows[0].length; i++) {
m = 0; n = 0;
c++;
for(var j = 0; j < g.rows.length; j++) {
if(g.rows[j][i] > 0) m += g.rows[j][i];
else n += g.rows[j][i];
}
if(m > g.posMax) g.posMax = m;
if(n < g.negMax) g.negMax = n;
}
g.vscale = Math.ceil(g.vPixels/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))/g.scale;
g.hscale = Math.floor(g.width/c)-1;
}
function _relRescaleGraph(g) {
var m, c = 0;
var adjPercent=new Array();
g.scale=20;
g.vscale = Math.ceil(g.height/5)/20;
for(var i = 0; i < g.rows[0].length; i++) {
m = 0;
c++;
for(var j = 0; j < g.rows.length; j++) {
if(g.rows[j][i] < 0) g.rows[j][i] = 0;
m += g.rows[j][i];
}
var s = 100/m; var k = 0; var kk=0;
for(var j = 0; j < g.rows.length; j++) {
g.rows[j][i] = Math.round(10*g.rows[j][i]*s)/10;
//if(j != 0) {
k += Math.round(g.rows[j][i]*g.vscale);
kk += g.rows[j][i];
//}
}
adjPercent[i]=100-kk;
}

for(var i = 0; i < g.rows[0].length; i++) {
for(var j = 0; j < g.rows.length; j++) {
if (eval(g.rows[j][i]+adjPercent[i])>0 && g.rows[j][i]!=0){
g.rows[j][i] += adjPercent[i];
adjPercent[i]=0;
}
}
}

g.hscale = Math.floor(g.width/c)-1;
g.posMax = 100; g.negMax = 0;
}
function _writeLegendGraph() {
var st = "";
var cTable=document.createElement("table");
var cTbody=document.createElement("tbody");
var cTr=document.createElement("tr");
var cTd0=document.createElement("td");
cTable.border=1;
cTable.cellSpacing=0;
cTable.cellPadding=0;
cTd0.colSpan=2;
cTd0.style.width=Math.floor(screen.width/6);

cTd0.style.fontFamily='Arial';
cTd0.style.fontSize=this.legendHeadFontSize;
cTd0.style.fontWeight="bold";
cTd0.appendChild(document.createTextNode(graphGpVarColLabel));
cTr.appendChild(cTd0);
cTr.lastChild.id="chart";
cTbody.appendChild(cTr);

for(var i = 0; i < this.legends.length; i++) {
if(!this.legends[i]) continue;
if(i >= this.rows.length) break;

var cTr1=document.createElement("tr");
var cTd1=document.createElement("td");
var cImg=document.createElement("img");
cTr1.style.maxHeight=12;
cImg.src="graph/"+parseInt(i-parseInt(i/25)*25)+".gif";
cImg.border=1;
cImg.hspace=1;
cTd1.appendChild(cImg);
cTr1.appendChild(cTd1);
cTr1.lastChild.id="chart";
cTbody.appendChild(cTr1);
var cTd2=document.createElement("td");
cTd2.style.fontFamily='Arial';
cTd2.style.fontSize=this.legendFontSize;

cTd2.appendChild(document.createTextNode(this.legends[i]));
cTr1.appendChild(cTd2);
cTr1.lastChild.id="chart";

}

cTable.appendChild(cTbody);

var cLegend=document.createElement("div");
cLegend.style.position="absolute";

cLegend.style.top=this.titleSpacerHeight+"px";

var cLegendLeftPos=this.yLabelWidth+this.yTickValueWidth+this.yTickMarkWidth+this.yAxisWidth+this.legendSpacerWidth+this.width
cLegend.style.left=cLegendLeftPos+"px";
cLegend.style.zIndex=2;
cLegend.style.height=this.vPixels;
cLegend.style.maxWidth=Math.floor(screen.width/10);
cLegend.style.maxHeight=this.vPixels;
cLegend.style.overflow="auto";
cLegend.appendChild(cTable);
this.container.appendChild(cLegend);

return st;
// should return cLegend
}
function _buildRegGraph(g, doc) {

str="";

/////////////////////////////// legend /////////////////////////////////////////////////
if(g.legends && document.getElementById("cboColVar").options[document.getElementById("cboColVar").selectedIndex].value!=999) {
g.writeLegend();
}

/////////////////////////////////////////////////////////////////////////////////////////////////

//////// y axis ///////////////////////////////////////////////////////////////////////////////

////////// y axis label ////////////////////////////////////////////
if(g.yLabel) {

var yLabelDiv=document.createElement("div");
var yLabelTab=document.createElement("table");
var yLabelTbody=document.createElement("tbody");
var yLabelTr=document.createElement("tr");
var yLabelTd=document.createElement("td");
yLabelDiv.style.position="absolute";
yLabelDiv.style.top=(g.titleSpacerHeight-g.yTickValueHeight)+"px";
yLabelDiv.style.left=0+"px";
yLabelDiv.style.width=(g.yLabelWidth-15)+"px";
yLabelDiv.style.height=g.height+"px";
yLabelDiv.style.align="left";
yLabelDiv.style.overflow="auto";
yLabelDiv.style.padding="10px";
yLabelTd.width=(g.yLabelWidth-15)+"px";
yLabelTd.height=(g.height-30)+"px";
yLabelTd.style.fontWeight="bold";
yLabelTd.style.fontSize=g.labelFontSize;
yLabelTd.style.fontFamily="Arial";
yLabelTd.align="left";
yLabelTd.vAlign="middle";
yLabelTd.appendChild(document.createTextNode(g.yLabel));
yLabelTr.appendChild(yLabelTd);
yLabelTr.lastChild.id="chart";
yLabelTbody.appendChild(yLabelTr);
yLabelTab.appendChild(yLabelTbody);
yLabelDiv.appendChild(yLabelTab);
g.container.appendChild(yLabelDiv);

g.yLabel = g.yLabel.split(" ");
g.yLabel = g.yLabel.join("<BR>\n");

var r = 2; if(g.negMax && g.posMax) r++;
}
//////////////////////////////////////////////////////////////////////////

////////// positive graph -- y axis tick values, tick marks and y axis////////////////
if(g.posMax > 0) {
if(g.scale) str += _writeScaleGraph(g, 0, g.posMax);
//////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////positive graph -- body of chart /////////////////////////////////////

var barBody=document.createElement("div");
barBody.style.position="absolute";
barBody.style.top=g.titleSpacerHeight+"px";
barBody.style.left=(g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth+g.yAxisWidth)+"px";
barBody.style.width=g.width;
barBody.style.height=parseInt(g.vPixels*Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+"px";
barBody.style.backgroundColor=g.bgColor;
var barDivs=new Array();
var barAlts=new Array();
var barImgs=new Array();

for(var j = 0; j < g.rows[0].length; j++) {
barDivs[j]=[];
barAlts[j]=[];
barImgs[j]=[];

for(var i = 0; i < g.rows.length; i++) {
if(parseInt(g.vscale*g.rows[i][j]) > 0) {

barDivs[j][i]=document.createElement("div");
barDivs[j][i].style.position="absolute";
barDivs[j][i].style.top=parseInt(g.vPixels*Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale))-Math.floor(g.vscale*g.rows[i][j]))+"px";
barDivs[j][i].style.left=((j*g.rows.length+i)*g.eachBarWidth+j)+"px";
barDivs[j][i].style.width=g.eachBarWidth+"px";
barDivs[j][i].style.height=Math.floor(g.vscale*g.rows[i][j])+"px";
barImgs[j][i]=document.createElement("img");
barImgs[j][i].src="graph/"+parseInt(i-parseInt(i/25)*25)+".gif";
barImgs[j][i].style.width=g.eachBarWidth+"px";
barImgs[j][i].style.height=Math.floor(g.vscale*g.rows[i][j])+"px";
barImgs[j][i].alt="";
if(g.legends && g.legends[i]) barImgs[j][i].alt += g.legends[i]+": ";
barImgs[j][i].alt += graphCellvarDisplay[j][i];
if(g.dates) barImgs[j][i].alt += ", "+g.dates[j];
barImgs[j][i].style.position="absolute";
barDivs[j][i].appendChild(barImgs[j][i]);
barBody.appendChild(barDivs[j][i]);

}
}
}
if (barBody) g.container.appendChild(barBody)
}

//////////////positive graph ends here //////////////////////////////////////////

//////////////horizontal axis //////////////////////////////////////////////////////////
if(g.scale || g.xScale) {

var xAxisDiv=document.createElement("div");
xAxisDiv.style.position="absolute";
xAxisDiv.style.top=parseInt(g.titleSpacerHeight+g.vPixels*Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+"px";
xAxisDiv.style.left=(g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth)+"px";
xAxisDiv.style.width=g.width;
xAxisDiv.style.height=g.xAxisHeight+"px";
var xAxisImg=document.createElement("img");
xAxisImg.src="graph/black.gif";
xAxisImg.style.width=(parseInt(g.width)+1)+"px";
xAxisImg.style.height=g.xAxisHeight+"px";
xAxisImg.style.position="absolute";
xAxisDiv.appendChild(xAxisImg);
g.container.appendChild(xAxisDiv);
}
//////////////////////////////////////////////////////////////////////////////////////////////

///////////////// x axis values and ticks ///////////////////////////////////////////
_writeXScaleGraph(g);
if(g.negMax < 0) {

//////////////// negative graph -- y axis tick values, tick marks and axis ////////////////////////////////////////

if(g.scale) _writeNegScaleGraph(g, g.negMax, 0);

///////////////// negative graph - body of chart ///////////////////////////////////////////////////////////

var negBarBody=document.createElement("div");
negBarBody.style.position="absolute";
negBarBody.style.top=g.titleSpacerHeight+parseInt(g.vPixels*Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+g.xAxisHeight+"px";
negBarBody.style.left=(g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth+g.yAxisWidth)+"px";
negBarBody.style.width=g.width;
negBarBody.style.height=parseInt(g.vPixels*Math.ceil(-1*g.negMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+"px";
negBarBody.style.backgroundColor=g.bgColor;

var barDivs=new Array();
var barAlts=new Array();
var barImgs=new Array();

for(var j = 0; j < g.rows[0].length; j++) {
barDivs[j]=[];
barAlts[j]=[];
barImgs[j]=[];

for(var i = 0; i < g.rows.length; i++) {
if(parseInt(g.vscale*g.rows[i][j]) < 0) {

barDivs[j][i]=document.createElement("div");
barDivs[j][i].style.position="absolute";
barDivs[j][i].style.top="0px";
barDivs[j][i].style.left=((j*g.rows.length+i)*g.eachBarWidth+j)+"px";
barDivs[j][i].style.width=g.eachBarWidth+"px";
barDivs[j][i].style.height=Math.floor(-1*g.vscale*g.rows[i][j])+"px";
barImgs[j][i]=document.createElement("img");
barImgs[j][i].src="graph/"+parseInt(i-parseInt(i/25)*25)+".gif";
barImgs[j][i].style.width=g.eachBarWidth+"px";
barImgs[j][i].style.height=Math.floor(-1*g.vscale*g.rows[i][j])+"px";
barImgs[j][i].alt="";
if(g.legends && g.legends[i]) barImgs[j][i].alt += g.legends[i]+": ";
barImgs[j][i].alt += graphCellvarDisplay[j][i];
if(g.dates) barImgs[j][i].alt += ", "+g.dates[j];
barImgs[j][i].style.position="absolute";
barDivs[j][i].appendChild(barImgs[j][i]);
negBarBody.appendChild(barDivs[j][i]);
}
}
}
if (negBarBody) g.container.appendChild(negBarBody)
}

////////////// negative graph ends here ////////////////////////////////////////////////////////////

///////////////////////////whole chart done!  /////////////////////////////////

//var graphFoot = "<TABLE><TR HEIGHT=50 VALIGN=BOTTOM><TD ID='chart'></TD></TR></TABLE>";
}

function _setXScaleGraph(s, skip, inc) {
this.xScale = true;
this.s = s || 0;
this.skip = skip || 1;
this.inc = inc || 1;
}
function _setXScaleValuesGraph(xLabelSeriesX) {
this.xScale = true;
this.s = 0;
this.skip = 1;
this.inc = 1;
this.dates = new Array();
this.dates = xLabelSeriesX;
//for(var i = 0; i < arguments.length; i++)
//this.dates[this.dates.length] = arguments[i];
}
function _setStartTimeGraph(hour, min, skip, inc) {
this.xScale = true;
this.sTime = new Date(0, 0, 0, hour, min);
this.skip = skip || 1;
this.inc = inc || 1;
}
function _setStartDateGraph(month, day, year, skip, inc) {
this.xScale = true;
this.sDate = new Date(year, month-1, day);
this.skip = skip || 1;
this.inc = inc || skip || 1;
this.showDate = true;
}
function _setDatesArrayGraph(g) {
if(g.dates) return;
g.dates = new Array();
for(var i = 0; i < g.rows[0].length; i++) {
var dateStr = "";
if(g.sDate) {
if(g.showDay) {
eval('switch(g.sDate.getDay()) {'+
'case 0: dateStr += "Sun"; break;'+
'case 1: dateStr += "Mon"; break;'+
'case 2: dateStr += "Tue"; break;'+
'case 3: dateStr += "Wed"; break;'+
'case 4: dateStr += "Thu"; break;'+
'case 5: dateStr += "Fri"; break;'+
'case 6: dateStr += "Sat"; break;'+
'}');
dateStr += " ";
}
if(g.longDate && g.showDate) {
dateStr += g.sDate.getDate()+"-";
eval('switch(g.sDate.getMonth()) {'+
'case 0: dateStr += "Jan"; break;'+
'case 1: dateStr += "Feb"; break;'+
'case 2: dateStr += "Mar"; break;'+
'case 3: dateStr += "Apr"; break;'+
'case 4: dateStr += "May"; break;'+
'case 5: dateStr += "Jun"; break;'+
'case 6: dateStr += "Jul"; break;'+
'case 7: dateStr += "Aug"; break;'+
'case 8: dateStr += "Sep"; break;'+
'case 9: dateStr += "Oct"; break;'+
'case 10: dateStr += "Nov"; break;'+
'case 11: dateStr += "Dec"; break;'+
'}');
} else if(g.showDate) dateStr += (g.sDate.getMonth()+1)+"/"+g.sDate.getDate();
if(g.showYear && g.showDate) {
if(g.longDate) dateStr += "-";
else dateStr += "/";
}
if(g.showYear) {
if(g.longYear) dateStr += g.sDate.getFullYear();
else dateStr += (g.sDate.getFullYear()%100);
}
g.sDate.setDate(g.sDate.getDate()+ g.inc);
} else if(g.sTime) {
var hrs = g.sTime.getHours();
if(!g.armyTime) {
var pm = false;
if(hrs == 0) { hrs = 12; }
else if(hrs >= 12) { if(hrs > 12) hrs -= 12; pm = true; }
} else 
if(hrs < 10) hrs = "0" + hrs;
dateStr = hrs + ":";
var min = g.sTime.getMinutes();
if(min < 10) min = "0" + min;
dateStr += min;
if(!g.armyTime) { !pm ? dateStr += "am" : dateStr += "pm" ; }
g.sTime.setMinutes(g.sTime.getMinutes()+ g.inc); 
} else dateStr = g.s+i*g.inc;
g.dates[i] = dateStr;
}
}
function _writeXScaleGraph(g) {
var st = "";
var mozXVertTickValue=new Array();
var sp;
if(!g.c) g.c = g.rows[0].length*2-1;

var n = g.rows[0].length;
var mult = 1;
if(g.stacked || g.relative) mult = g.rows.length

var tickValueDivs=new Array();
var tickValues=new Array();
var tickMarkDivs=new Array();
var tickMarkImgs=new Array();
var xTicksDiv=document.createElement("div");
xTicksDiv.style.position="absolute";
xTicksDiv.style.top=parseInt(g.titleSpacerHeight+g.vPixels+g.xAxisHeight+g.xTickMarkHeight)+"px";
xTicksDiv.style.left=g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth+"px";

for(var i = 0; i <= n; i++) {

tickMarkDivs[i]=document.createElement("div");
tickMarkDivs[i].style.position="absolute";
tickMarkDivs[i].style.top=parseInt(g.titleSpacerHeight+g.vPixels*Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale))+g.xAxisHeight)+"px";
tickMarkDivs[i].style.left=(g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth+i*(parseInt(g.eachBarWidth*g.rows.length/mult)+1))+"px";
tickMarkDivs[i].style.width=g.xTickMarkWidth+"px";
tickMarkDivs[i].style.height=g.xTickMarkHeight+"px";
tickMarkImgs[i]=document.createElement("img");
tickMarkImgs[i].src="graph/black.gif";
tickMarkImgs[i].style.width=g.xTickMarkWidth+"px";
tickMarkImgs[i].style.height=g.xTickMarkHeight+"px";
tickMarkImgs[i].style.position="absolute";
tickMarkDivs[i].appendChild(tickMarkImgs[i]);
g.container.appendChild(tickMarkDivs[i]);

}

var cspan = g.rows.length;
if(g.stacked || g.relative) cspan = 2;
cspan *= g.skip;
if(g.sDate || g.sTime) _setDatesArrayGraph(g);
var t = 0;

for(var i = 0; i < Math.floor(g.rows[0].length/g.skip); i++) {

tickValueDivs[i]=document.createElement("div");
tickValueDivs[i].style.position="absolute";
tickValueDivs[i].style.top="0px";
tickValueDivs[i].style.left=(i*(parseInt(g.eachBarWidth*g.rows.length/mult)+1))+"px";
if (_app=='Microsoft Internet Explorer' && g.xTickValueVertical==true) {
tickValueDivs[i].style.writingMode="tb-rl";
tickValueDivs[i].style.textAlign="left";
} else tickValueDivs[i].style.textAlign="center"
if (_app!='Microsoft Internet Explorer' && g.xTickValueVertical==true) tickValueDivs[i].style.align="right"
//tickValueDivs[i].style.overflow="auto";
tickValueDivs[i].style.fontSize=g.tickValueFontSize;
tickValueDivs[i].style.fontStyle="normal";
if (_app!='Microsoft Internet Explorer' && g.xTickValueVertical==true) {
mozXVertTickValue[i]=(g.dates[i*g.skip] || "").split("");
if (word==0) tickValueDivs[i].style.lineHeight="90%"
for (sp=0;sp<mozXVertTickValue[i].length;sp++) {
if (mozXVertTickValue[i][sp]=="-") mozXVertTickValue[i][sp]="|"
if (mozXVertTickValue[i][sp]=="(" || mozXVertTickValue[i][sp]=="[") mozXVertTickValue[i][sp]="/\\"
if (mozXVertTickValue[i][sp]==")" || mozXVertTickValue[i][sp]=="]") mozXVertTickValue[i][sp]="\\/"
tickValueDivs[i].appendChild(document.createTextNode(mozXVertTickValue[i][sp]));
tickValueDivs[i].appendChild(document.createElement("br"));
}
tickValueDivs[i].style.width=(g.eachGroupWidth-2)+"px";
} else {
tickValues[i]=(g.dates[i*g.skip] || "");
tickValueDivs[i].style.width=(g.eachBarWidth*g.rows.length/mult)+"px";
tickValueDivs[i].appendChild(document.createTextNode(tickValues[i]));
}
xTicksDiv.appendChild(tickValueDivs[i]);

}
var len = g.rows[0].length;
if(!g.stacked) len *= g.rows.length;
if(i < Math.ceil(g.rows[0].length/g.skip)) {

}

xTicksDiv.height=g.xTickValueHeight+"px";
g.container.appendChild(xTicksDiv);

if(g.xLabel) {
var xLabelDiv=document.createElement("div");
xLabelDiv.style.position="absolute";
xLabelDiv.style.top=parseInt(g.titleSpacerHeight+g.vPixels+g.xAxisHeight+g.xTickMarkHeight+g.xTickValueHeight)+"px";
xLabelDiv.style.left=g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth+"px";
xLabelDiv.style.width=g.width+"px";
xLabelDiv.style.textAlign="center";
xLabelDiv.style.fontSize=g.labelFontSize;
xLabelDiv.style.fontWeight="bold";
xLabelDiv.style.fontFamily="Arial";
xLabelDiv.style.writingMode="lr-tb";
if(g.legends && document.getElementById("cboRowVar").options[document.getElementById("cboRowVar").selectedIndex].value!=999) xLabelDiv.appendChild(document.createTextNode(g.xLabel))
g.container.appendChild(xLabelDiv);
}

return st;
}

function _writeNegScaleGraph(g, min, max) {
var h = Math.ceil(g.vPixels/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)));
var p = (Math.ceil(-1*g.negMax/g.scale)*g.scale)/((Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale))*g.scale);
var n = Math.ceil(-1*g.negMax/g.scale);

var tickValueDivs=new Array();
var tickValues=new Array();
var tickMarkDivs=new Array();
var tickMarkImgs=new Array();

//alert("pixel per segment="+h+"  proportion in this range="+p+"  number of segment in this range="+n);
var st = "";
if(h < 15) {
if(!g.posMax)
alert(graphWarn[word]);

return st;
}

var H = h - 3;

if (g.posMax>0) {
for(var i = 1; i <= n; i++) {
tickValueDivs[i]=document.createElement("div");
tickValueDivs[i].style.position="absolute";
tickValueDivs[i].style.top=(g.titleSpacerHeight+g.vPixels*(Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+(i*h)-Math.floor(g.yTickValueHeight*0.6))+"px";
tickValueDivs[i].style.left=g.yLabelWidth+"px";
tickValueDivs[i].style.width=(g.yTickValueWidth-1)+"px";
tickValueDivs[i].style.height=g.yTickValueHeight+"px";
tickValueDivs[i].style.textAlign="right";
tickValueDivs[i].style.overflow="auto";
tickValueDivs[i].style.fontSize=g.tickValueFontSize;
tickValueDivs[i].style.fontStyle="italic";
tickValues[i]=(g.scale*-1*i+g.offset).toFixed(statvarDecimal[document.getElementById("cboStat").selectedIndex]);
tickValueDivs[i].appendChild(document.createTextNode(tickValues[i]));
g.container.appendChild(tickValueDivs[i]);
}

for(var i = 1; i <= n; i++) {
tickMarkDivs[i]=document.createElement("div");
tickMarkDivs[i].style.position="absolute";
tickMarkDivs[i].style.top=(g.titleSpacerHeight+g.vPixels*(Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+(i*h))+"px";
tickMarkDivs[i].style.left=(g.yLabelWidth+g.yTickValueWidth)+"px";
tickMarkDivs[i].style.width=g.yTickMarkWidth+"px";
tickMarkDivs[i].style.height=g.yTickMarkHeight+"px";
tickMarkImgs[i]=document.createElement("img");
tickMarkImgs[i].src="graph/black.gif";
tickMarkImgs[i].style.width=g.yTickMarkWidth+"px";
tickMarkImgs[i].style.height=g.yTickMarkHeight+"px";
tickMarkImgs[i].style.position="absolute";
tickMarkDivs[i].appendChild(tickMarkImgs[i]);
g.container.appendChild(tickMarkDivs[i]);
}

var yAxisDiv=document.createElement("div");
yAxisDiv.style.position="absolute";
yAxisDiv.style.top=g.titleSpacerHeight+g.vPixels*(Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+"px";
yAxisDiv.style.left=(g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth)+"px";
yAxisDiv.style.width="1px";
yAxisDiv.style.height=(parseInt(h*n)+1)+"px";
var yAxisImg=document.createElement("img");
yAxisImg.src="graph/black.gif";
yAxisImg.style.width="1px";
yAxisImg.style.height=(parseInt(h*n)+1)+"px";
yAxisImg.style.position="absolute";
yAxisDiv.appendChild(yAxisImg);
g.container.appendChild(yAxisDiv);

} else {
for(var i = 0; i <= n; i++) {
tickValueDivs[i]=document.createElement("div");
tickValueDivs[i].style.position="absolute";
tickValueDivs[i].style.top=(g.titleSpacerHeight+g.vPixels*(Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+(i*h)-Math.floor(g.yTickValueHeight*0.6))+"px";
tickValueDivs[i].style.left=g.yLabelWidth+"px";
tickValueDivs[i].style.width=(g.yTickValueWidth-1)+"px";
tickValueDivs[i].style.height=g.yTickValueHeight+"px";
tickValueDivs[i].style.textAlign="right";
tickValueDivs[i].style.overflow="auto";
tickValueDivs[i].style.fontSize=g.tickValueFontSize;
tickValueDivs[i].style.fontStyle="italic";
tickValues[i]=(g.scale*-1*i+g.offset).toFixed(statvarDecimal[document.getElementById("cboStat").selectedIndex]);
tickValueDivs[i].appendChild(document.createTextNode(tickValues[i]));
g.container.appendChild(tickValueDivs[i]);
}

for(var i = 0; i <= n; i++) {
tickMarkDivs[i]=document.createElement("div");
tickMarkDivs[i].style.position="absolute";
tickMarkDivs[i].style.top=(g.titleSpacerHeight+g.vPixels*(Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+(i*h))+"px";
tickMarkDivs[i].style.left=(g.yLabelWidth+g.yTickValueWidth)+"px";
tickMarkDivs[i].style.width=g.yTickMarkWidth+"px";
tickMarkDivs[i].style.height=g.yTickMarkHeight+"px";
tickMarkImgs[i]=document.createElement("img");
tickMarkImgs[i].src="graph/black.gif";
tickMarkImgs[i].style.width=g.yTickMarkWidth+"px";
tickMarkImgs[i].style.height=g.yTickMarkHeight+"px";
tickMarkImgs[i].style.position="absolute";
tickMarkDivs[i].appendChild(tickMarkImgs[i]);
g.container.appendChild(tickMarkDivs[i]);
}

var yAxisDiv=document.createElement("div");
yAxisDiv.style.position="absolute";
yAxisDiv.style.top=g.titleSpacerHeight+g.vPixels*(Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+"px";
yAxisDiv.style.left=(g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth)+"px";
yAxisDiv.style.width="1px";
yAxisDiv.style.height=g.vPixels+"px";
var yAxisImg=document.createElement("img");
yAxisImg.src="graph/black.gif";
yAxisImg.style.width="1px";
yAxisImg.style.height=g.vPixels+"px";
yAxisImg.style.position="absolute";
yAxisDiv.appendChild(yAxisImg);
g.container.appendChild(yAxisDiv);
}


return st;
}

function _writeScaleGraph(g, min, max) {
var p = g.posMax/(g.posMax-g.negMax);
var h = Math.ceil(g.height/(g.posMax-g.negMax)*g.scale);
var n = Math.ceil(p*(g.posMax-g.negMax)/g.scale);

var tickValueDivs=new Array();
var tickValues=new Array();
var tickMarkDivs=new Array();
var tickMarkImgs=new Array();

//alert("pixel per segment="+h+"  proportion in this range="+p+"  number of segment in this range="+n);
var st = "";
if(h < 15) {
alert(graphWarn[word]);
return st;
}
var H = h - 3;
for(var i = 0; i <= n; i++) {
if(g.relative) st += "%";

tickValueDivs[i]=document.createElement("div");
tickValueDivs[i].style.position="absolute";
tickValueDivs[i].style.top=(g.titleSpacerHeight+(g.vPixels*(Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))/n*i)-Math.floor(g.yTickValueHeight*0.6))+"px";
tickValueDivs[i].style.left=g.yLabelWidth+"px";
tickValueDivs[i].style.width=(g.yTickValueWidth-1)+"px";
tickValueDivs[i].style.height=g.yTickValueHeight+"px";
tickValueDivs[i].style.textAlign="right";
tickValueDivs[i].style.overflow="auto";
tickValueDivs[i].style.fontSize=g.tickValueFontSize;
tickValueDivs[i].style.fontStyle="italic";
tickValues[i]=(g.scale*(n-i)+g.offset).toFixed(statvarDecimal[document.getElementById("cboStat").selectedIndex]);
if(g.relative) tickValues[i] += "%";
tickValueDivs[i].appendChild(document.createTextNode(tickValues[i]));
g.container.appendChild(tickValueDivs[i]);

}

for(var i = 0; i <= n; i++) {

tickMarkDivs[i]=document.createElement("div");
tickMarkDivs[i].style.position="absolute";
tickMarkDivs[i].style.top=(g.titleSpacerHeight+(g.vPixels*(Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))/n*i))+"px";
tickMarkDivs[i].style.left=(g.yLabelWidth+g.yTickValueWidth)+"px";
tickMarkDivs[i].style.width=g.yTickMarkWidth+"px";
tickMarkDivs[i].style.height=g.yTickMarkHeight+"px";
tickMarkImgs[i]=document.createElement("img");
tickMarkImgs[i].src="graph/black.gif";
tickMarkImgs[i].style.width=g.yTickMarkWidth+"px";
tickMarkImgs[i].style.height=g.yTickMarkHeight+"px";
tickMarkImgs[i].style.position="absolute";
tickMarkDivs[i].appendChild(tickMarkImgs[i]);
g.container.appendChild(tickMarkDivs[i]);
}

var yAxisDiv=document.createElement("div");
yAxisDiv.style.position="absolute";
yAxisDiv.style.top=g.titleSpacerHeight+"px";
yAxisDiv.style.left=(g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth)+"px";
yAxisDiv.style.width="1px";
yAxisDiv.style.height=g.vPixels+"px";
var yAxisImg=document.createElement("img");
yAxisImg.src="graph/black.gif";
yAxisImg.style.width="1px";
yAxisImg.style.height=g.vPixels+"px";
yAxisImg.style.position="absolute";
yAxisDiv.appendChild(yAxisImg);
g.container.appendChild(yAxisDiv);

return st;
}
function _buildStackGraph(g) {
var mult = 1;
if(g.stacked || g.relative) mult = g.rows.length
if(!g.c) g.c = g.rows[0].length*2-1;
str="";

if(g.legends && document.getElementById("cboColVar").options[document.getElementById("cboColVar").selectedIndex].value!=999) {
g.writeLegend();
}

if(g.yLabel) {

var yLabelDiv=document.createElement("div");
var yLabelTab=document.createElement("table");
var yLabelTbody=document.createElement("tbody");
var yLabelTr=document.createElement("tr");
var yLabelTd=document.createElement("td");
yLabelDiv.style.position="absolute";
yLabelDiv.style.top=(g.titleSpacerHeight-g.yTickValueHeight)+"px";
yLabelDiv.style.left=0+"px";
yLabelDiv.style.width=(g.yLabelWidth-15)+"px";
yLabelDiv.style.height=g.height+"px";
yLabelDiv.style.align="left";
yLabelDiv.style.overflow="auto";
yLabelDiv.style.padding="10px";
yLabelTd.width=(g.yLabelWidth-15)+"px";
yLabelTd.height=(g.height-30)+"px";
yLabelTd.style.fontWeight="bold";
yLabelTd.style.fontSize=g.labelFontSize;
yLabelTd.style.fontFamily="Arial";
yLabelTd.align="left";
yLabelTd.vAlign="middle";
yLabelTd.appendChild(document.createTextNode(g.yLabel));
yLabelTr.appendChild(yLabelTd);
yLabelTr.lastChild.id="chart";
yLabelTbody.appendChild(yLabelTr);
yLabelTab.appendChild(yLabelTbody);
yLabelDiv.appendChild(yLabelTab);
g.container.appendChild(yLabelDiv);
}
if(g.posMax > 0) {
if(!g.yLabel) str += "<TR>\n";
if(g.scale) str += _writeScaleGraph(g, 0, g.posMax);
var adjPixel=new Array();

var barBody=document.createElement("div");
barBody.style.position="absolute";
barBody.style.top=g.titleSpacerHeight+"px";
barBody.style.left=(g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth+g.yAxisWidth)+"px";
barBody.style.width=g.width;
barBody.style.height=g.vPixels*(Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)));
barBody.style.backgroundColor=g.bgColor;
var barDivs=new Array();
var barAlts=new Array();
var barImgs=new Array();
var barImgHeight=new Array();
var barImgCumin=new Array();

for(var j = 0; j < g.rows[0].length; j++) {

barDivs[j]=document.createElement("div");
barDivs[j].style.position="absolute";
barDivs[j].style.top="0px";
barDivs[j].style.left=(j*g.eachBarWidth+j)+"px";
barDivs[j].style.width=g.eachBarWidth+"px";
barDivs[j].style.height=g.vPixels*(Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+"px";
barAlts[j]=[];
barImgs[j]=[];
barImgHeight[j]=[];
barImgCumin[j]=0;

adjPixel[j]=0;
str += "<TD ID='chartbg' VALIGN=BOTTOM";
if(g.bgColor) str += " BGCOLOR=\""+g.bgColor+"\"";
str += ">";

var k = 0, y = 0, drawn = false;
for(var i = 0; i < g.rows.length; i++) if(parseInt(g.vscale*g.rows[i][j]) > 0) k += Math.round(g.vscale*g.rows[i][j])
if(g.rows.length > 0 && g.relative && (g.vPixels != k)) {
adjPixel[j]=g.vPixels-k;

if (k<=0) {
barImgs[j][0]=document.createElement("img");
barImgs[j][0].src="graph/clear.gif";
barImgs[j][0].style.width=g.eachBarWidth+"px";
barImgs[j][0].style.height=g.vPixels+"px";
barImgs[j][0].alt="";

if (!(g.relative && k>0) && g.legends && g.legends[0]) barImgs[j][0].alt += g.legends[0]+": ";
//if (!(g.relative && k>0)) barImgs[j][0].alt += Math.ceil((g.height-k)/g.vscale*10)/10;
if (g.relative && k<=0) barImgs[j][0].alt += divErrorMsg[word];
if (g.dates && !(g.relative && k>0)) barImgs[j][0].alt += ", "+prepIn[word]+" "+g.dates[j]
barImgs[j][0].style.position="absolute";
barDivs[j].appendChild(barImgs[j][0]);
barBody.appendChild(barDivs[j]);
}

y++;
drawn = true;
}
for(var i = 0; i < g.rows.length; i++) {
if(parseInt(g.vscale*g.rows[i][j]) > 0) {

barImgs[j][i]=document.createElement("img");
barImgs[j][i].src="graph/"+parseInt(i-parseInt(i/25)*25)+".gif";
barImgs[j][i].style.width=g.eachBarWidth+"px";
barImgs[j][i].style.position="absolute";
barImgs[j][i].alt="";

if (adjPixel[j]!=0)  {
if ((parseInt(g.vscale*g.rows[i][j])+parseInt(adjPixel[j]))>0){
barImgHeight[j][i] = eval(Math.round(g.vscale*g.rows[i][j])+adjPixel[j]);
adjPixel[j]=0;
} else barImgHeight[j][i] = Math.round(g.vscale*g.rows[i][j])
} else barImgHeight[j][i] = Math.round(g.vscale*g.rows[i][j])

barImgs[j][i].style.height=barImgHeight[j][i]+"px";
barImgs[j][i].style.top=g.vPixels*(Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))-barImgCumin[j]-barImgHeight[j][i]+"px";
barImgCumin[j]+=barImgHeight[j][i];
barImgs[j][i].style.left="0px";

if(g.legends && g.legends[i]) barImgs[j][i].alt += g.legends[i]+": "
if(!g.relative) barImgs[j][i].alt += graphCellvarDisplay[j][i]
if(g.relative) barImgs[j][i].alt += g.rows[i][j].toFixed(1)+"%"
if(g.dates && !g.relative) barImgs[j][i].alt += ", "+g.dates[j]
if(g.dates && g.relative) barImgs[j][i].alt += ", "+prepIn[word]+" "+g.dates[j]
barDivs[j].appendChild(barImgs[j][i]);
drawn = true;
}
}
barBody.appendChild(barDivs[j]);
}
}
if(g.scale || g.xScale) {
var xAxisDiv=document.createElement("div");
xAxisDiv.style.position="absolute";
xAxisDiv.style.top=parseInt(g.titleSpacerHeight+g.vPixels*Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+"px";
xAxisDiv.style.left=(g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth)+"px";
xAxisDiv.style.width=g.width;
xAxisDiv.style.height=g.xAxisHeight+"px";
var xAxisImg=document.createElement("img");
xAxisImg.src="graph/black.gif";
xAxisImg.style.width=(parseInt(g.width)+1)+"px";
xAxisImg.style.height=g.xAxisHeight+"px";
xAxisImg.style.position="absolute";
xAxisDiv.appendChild(xAxisImg);
g.container.appendChild(xAxisDiv);
}

//if(g.xScale && !g.negMax) {
if(g.xScale) {
_writeXScaleGraph(g);
}
/////////////////////// negative graph ///////////////////////////
if(g.negMax < 0) {

if(g.scale) _writeNegScaleGraph(g, g.negMax, 0)

var negBarBody=document.createElement("div");
negBarBody.style.position="absolute";
negBarBody.style.top=g.titleSpacerHeight+parseInt(g.vPixels*Math.ceil(g.posMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+g.xAxisHeight+"px";
negBarBody.style.left=(g.yLabelWidth+g.yTickValueWidth+g.yTickMarkWidth+g.yAxisWidth)+"px";
negBarBody.style.width=g.width;
negBarBody.style.height=parseInt(Math.ceil(g.vPixels/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))*Math.ceil(-1*g.negMax/g.scale))+"px";
negBarBody.style.backgroundColor=g.bgColor;

var barDivs=new Array();
var barAlts=new Array();
var barImgs=new Array();
var barImgHeight=new Array();
var barImgCumin=new Array();
for(var j = 0; j < g.rows[0].length; j++) {
barDivs[j]=document.createElement("div");
barDivs[j].style.position="absolute";
barDivs[j].style.top="0px";
barDivs[j].style.left=(j*g.eachBarWidth+j)+"px";
barDivs[j].style.width=g.eachBarWidth+"px";
barDivs[j].style.height=g.vPixels*(Math.ceil(-1*g.negMax/g.scale)/(Math.ceil(g.posMax/g.scale)+Math.ceil(-1*g.negMax/g.scale)))+"px";
barAlts[j]=[];
barImgs[j]=[];
barImgHeight[j]=[];
barImgCumin[j]=0;
var drawn = false;
for(var i = 0; i < g.rows.length; i++) {
if(parseInt(g.vscale*g.rows[i][j]) < 0) {
barImgs[j][i]=document.createElement("img");
barImgs[j][i].src="graph/"+parseInt(i-parseInt(i/25)*25)+".gif";
barImgs[j][i].style.position="absolute";
barImgs[j][i].style.width=g.eachBarWidth+"px";
barImgHeight[j][i] = Math.round(-1*g.vscale*g.rows[i][j]);
barImgs[j][i].style.height=barImgHeight[j][i]+"px";
barImgs[j][i].style.top=barImgCumin[j]+"px";
barImgCumin[j]+=barImgHeight[j][i];
barImgs[j][i].style.left="0px";
barImgs[j][i].alt="";

if(g.legends && g.legends[i]) barImgs[j][i].alt += g.legends[i]+": ";
if(g.relative) barImgs[j][i].alt += g.rows[i][j]
else barImgs[j][i].alt +=graphCellvarDisplay[j][i]
if(g.relative) barImgs[j][i].alt += "%";
if(g.dates) barImgs[j][i].alt += ", "+g.dates[j];
barDivs[j].appendChild(barImgs[j][i]);
drawn = true;
}
}
negBarBody.appendChild(barDivs[j]);
}
}
if(g.xLabel) {
g.xLabel;
}

//var graphFoot = "<TABLE><TR HEIGHT=50 VALIGN=BOTTOM><TD ID='chart'></TD></TR></TABLE>";
if (barBody) g.container.appendChild(barBody)
if (negBarBody) g.container.appendChild(negBarBody)
}

function _adjustOffsetGraph(g) {
if(g.relative) return;
for(var i = 0; i < g.rows.length; i++)
for(var j = 0; j < g.rows[i].length; j++)
g.rows[i][j] -= g.offset;
}
function _buildGraph(scale,posMax,negMax) {
var screenspec="height="+eval((Math.ceil(eval(screen.availHeight-350)/(posMax-negMax)*scale)*eval(Math.ceil(posMax/scale)+Math.ceil(negMax/scale)))+300)+",width="+eval(screen.availWidth-10)+",resizable,scrollbars";
//var graphWin=open('graph.html','graphical',screenspec);
//if (navigator.userAgent.indexOf("Opera")==-1) {
//graphWin.close();
//var graphWin=open('graph.html','graphical',screenspec);
//}
//graphWin.moveTo(1,1);
//var d=graphWin.document;
var doc;
//doc = d || graphWin.document;
if(!this.rows) return;
if(this.rows.length == 0) {
document.getElementById("cDiv0").innerHTML="<TABLE><TR><TD ID='chart'><TT>[empty graph]</TT></TD></TR></TABLE>\n";
//doc.write("<TABLE><TR><TD ID='chart'><TT>[empty graph]</TT></TD></TR></TABLE>\n");
return;
}
_adjustOffsetGraph(this);
if(this.xScale) _setDatesArrayGraph(this);
if(this.relative) {
_relRescaleGraph(this);
_buildStackGraph(this, doc);
return;
}
if(this.stacked) {
_stackRescaleGraph(this);
_buildStackGraph(this, doc);
return;
}
_rescaleGraph(this);
_buildRegGraph(this, doc);
}

