function CanvasChartPainterFactory(){
return new CanvasChartPainter();
}
function CanvasChartPainter(){
this.base=AbstractChartPainter;
}
CanvasChartPainter.prototype=new AbstractChartPainter;
CanvasChartPainter.prototype.create=function(el){
while(el.firstChild){
el.removeChild(el.lastChild);
}
this.el=el;
this.w=el.clientWidth;
this.h=el.clientHeight;
this.canvas=document.createElement("canvas");
this.canvas.width=this.w;
this.canvas.height=this.h;
this.canvas.style.width=this.w+"px";
this.canvas.style.height=this.h+"px";
el.appendChild(this.canvas);
if((!this.canvas.getContext)&&(typeof G_vmlCanvasManager!="undefined")){
this.canvas=G_vmlCanvasManager.initElement(this.canvas);
}
};
CanvasChartPainter.prototype.init=function(_2,_3,_4,_5,_6,_7){
this.ctx=this.canvas.getContext("2d");
this.chartx=0;
this.chartw=this.w;
this.charth=this.h;
this.charty=0;
this.xlen=_2;
this.ymin=_3;
this.ymax=_4;
this.xgd=_5;
this.ygd=_6;
this.calc(this.chartw,this.charth,_2,_3,_4,_5,_6);
};
CanvasChartPainter.prototype.drawLegend=function(_8){
var _9,_a,_b,_c,_d;
_d=document.createElement("div");
_d.className="secondAxisLabel";
_d.style.position="absolute";
_9=document.createElement("div");
_9.className="legend";
_9.style.position="absolute";
_a=document.createElement("ul");
for(i=0;i<_8.length-2;i++){
_b=document.createElement("li");
_b.style.color=_8[i].color;
_c=document.createElement("span");
_c.appendChild(document.createTextNode(_8[i].label));
_c.style.color="black";
_b.appendChild(_c);
_a.appendChild(_b);
}
_9.appendChild(_a);
this.el.appendChild(_9);
_9.style.right="0px";
_9.style.top=this.charty+(this.charth/2)-(_9.offsetHeight/2)+"px";
this.legend=_9;
this.el.appendChild(_d);
_d.style.top=this.charty+(this.charth/2)-_9.offsetHeight-100+"px";
_d.style.right="0px";
this.chartw=this.w-(this.legend.offsetWidth+5);
this.calc(this.chartw,this.charth,this.xlen,this.ymin,this.ymax,this.xgd,this.ygd);
};
CanvasChartPainter.prototype.drawVerticalAxis=function(_e,_f,_10){
var _11,_12,_13,y,ty,n,_17,_18,_19,w,_1b,pos;
_19=Math.pow(10,_f);
_13=_10.range/(_e-1);
_11=document.createElement("div");
_11.style.position="absolute";
_11.style.left="0px";
_11.style.top="0px";
_11.style.textAlign="right";
this.el.appendChild(_11);
this.ctx.fillStyle="black";
w=0;
_1b=new Array();
for(n=0,i=_10.ymax;(i>_10.ymin)&&(n<_e-1);i-=_13,n++){
_12=document.createElement("span");
_12.setAttribute("style","color:blue");
_18=parseInt(i*_19)/_19;
_12.appendChild(document.createTextNode(_18.toFixed(_f)));
_11.appendChild(_12);
_1b.push([i,_12]);
if(_12.offsetWidth>w){
w=_12.offsetWidth;
}
}
_12=document.createElement("span");
_12.setAttribute("style","color:blue");
_12.appendChild(document.createTextNode(_10.ymin.toFixed(_f)));
_11.appendChild(_12);
_1b.push([_10.ymin,_12]);
if(_12.offsetWidth>w){
w=_12.offsetWidth;
}
_11.style.width=w+"px";
this.chartx=w+5;
this.charty=_12.offsetHeight/2;
this.charth=this.h-((_12.offsetHeight*1.5)+5);
this.chartw=this.w-(((this.legend)?this.legend.offsetWidth:0)+w+10);
this.calc(this.chartw,this.charth,this.xlen,this.ymin,this.ymax,this.xgd,this.ygd);
n=_10.range/this.charth;
_17=(_10.ymin/n);
for(i=0;i<_1b.length;i++){
_12=_1b[i][1];
pos=_1b[i][0];
if(pos==_10.ymin){
y=this.charty+this.charth-1;
}else{
y=this.charty+(this.charth-(pos/n)+_17);
}
this.ctx.fillRect(this.chartx-5,y,5,1);
ty=y-(_12.offsetHeight/2);
_12.style.position="absolute";
_12.style.right="0px";
_12.style.top=ty+"px";
}
};
CanvasChartPainter.prototype.drawOtherVerticalAxis=function(ygd,_1e,_1f){
var _20,_21,_22,y,ty,n,_26,_27,_28,w,_2a,pos;
_28=Math.pow(10,_1e);
_22=_1f.range/(ygd-1);
w=0;
_20=document.createElement("div");
_20.style.position="absolute";
_20.style.top="0px";
_20.style.textAlign="left";
this.el.appendChild(_20);
this.ctx.fillStyle="black";
_2a=new Array();
for(n=0,i=_1f.ymax;(i>_1f.ymin)&&(n<ygd-1);i-=_22,n++){
_21=document.createElement("span");
_21.setAttribute("style","color:red");
_27=parseInt(i*_28)/_28;
_21.appendChild(document.createTextNode(_27.toFixed(_1e)));
_20.appendChild(_21);
_2a.push([i,_21]);
if(_21.offsetWidth>w){
w=_21.offsetWidth;
}
}
_20.style.left=(this.chartw-10)+"px";
_21=document.createElement("span");
_21.setAttribute("style","color:red");
_21.appendChild(document.createTextNode(_1f.ymin.toFixed(_1e)));
_20.appendChild(_21);
_2a.push([_1f.ymin,_21]);
if(_21.offsetWidth>w){
w=_21.offsetWidth;
}
_20.style.width=w+"px";
this.chartw=this.w-w-15;
this.chartw=this.chartw-this.legend.offsetWidth;
this.chartw=this.chartw-w;
this.calc(this.chartw,this.charth,this.xlen,this.ymin,this.ymax,this.xgd,this.ygd);
n=_1f.range/this.charth;
_26=(_1f.ymin/n);
this.ctx.fillStyle="black";
for(i=0;i<_2a.length;i++){
_21=_2a[i][1];
pos=_2a[i][0];
if(pos==_1f.ymin){
y=this.charty+this.charth-1;
}else{
y=this.charty+(this.charth-(pos/n)+_26);
}
this.ctx.fillRect(this.chartw+this.chartx,y,5,1);
ty=y-(_21.offsetHeight/2);
_21.style.position="absolute";
_21.style.right="0px";
_21.style.top=ty+"px";
}
};
CanvasChartPainter.prototype.drawHorizontalAxis=function(_2c,_2d,xgd,_2f){
var _30,_31,_32,x,tx,n,_36;
_36=Math.pow(10,_2f);
var _37=_2d[NUMBER_OF_POINTS-1];
if(parseInt(_37)!=_37){
if(parseInt(_37-0.0001)==parseInt(_37)){
_37=parseInt(_37)+1;
}else{
_37=parseInt(_37);
}
}
document.getElementById("speedUnitFlag").getElementsByTagName("input")[2].checked?xgd=parseInt((_37/100)+1):xgd=(_37/5)+1;
newLabels=new Array(xgd+1);
for(i=0;i<xgd+1;i++){
newLabels[i]=(_37*(i/(xgd-1)));
}
n=this.chartw/(xgd-1);
_30=document.createElement("div");
_30.style.position="absolute";
_30.style.left="0px";
_30.style.top=(this.charty+this.charth+5)+"px";
_30.style.width=this.w+"px";
this.el.appendChild(_30);
this.ctx.fillStyle="black";
for(i=0;i<xgd;i++){
_31=document.createElement("span");
_31.appendChild(document.createTextNode(newLabels[i].toFixed(_2f)));
_30.appendChild(_31);
x=this.chartx+(n*i);
tx=x-(_31.offsetWidth/2);
_31.style.position="absolute";
_31.style.left=tx+"px";
_31.style.top="0px";
this.ctx.fillRect(x,this.charty+this.charth,1,5);
}
this.calc(this.chartw,this.charth,_2c,this.ymin,this.ymax,xgd,this.ygd);
};
CanvasChartPainter.prototype.drawAxes=function(_38){
this.ctx.fillStyle="black";
this.ctx.fillRect(this.chartx,this.charty,1,this.charth);
this.ctx.fillRect(this.chartx,this.charty+this.charth-1,this.chartw+1,1);
if(_38){
this.ctx.fillRect(this.chartw+this.chartx,this.charty,1,this.charth);
}
};
CanvasChartPainter.prototype.drawBackground=function(){
this.ctx.fillStyle="white";
this.ctx.fillRect(0,0,this.w,this.h);
};
CanvasChartPainter.prototype.drawChart=function(_39,ygd){
step=_39.range/(ygd-1);
this.ctx.fillStyle="silver";
if(this.xgrid){
for(i=this.xgrid;i<this.chartw;i+=this.xgrid){
this.ctx.fillRect(this.chartx+i,this.charty,1,this.charth-1);
}
}
if(this.ygrid){
for(i=this.charth-this.ygrid,curVal=(_39.ymin+step);i>0;i-=this.ygrid,curVal+=step){
if(curVal==0){
this.ctx.fillStyle="black";
this.ctx.fillRect(this.chartx+1,this.charty+i,this.chartw,1);
this.ctx.fillStyle="silver";
}
this.ctx.fillRect(this.chartx+1,this.charty+i,this.chartw,1);
}
}
};
CanvasChartPainter.prototype.drawArea=function(_3b,_3c){
var i,len,x,y,n,_42;
n=this.range/this.charth;
_42=(this.ymin/n);
len=_3c.length;
if(len){
this.ctx.fillStyle=_3b;
x=this.chartx+1;
this.ctx.beginPath();
this.ctx.moveTo(x,this.charty+this.charth-1);
y=this.charty+this.charth-(_3c[0]/n)+_42;
this.ctx.lineTo(x,y);
for(i=1;i<len;i++){
y=this.charty+this.charth-(_3c[i]/n)+_42;
x+=this.xstep;
this.ctx.lineTo(x,y);
}
this.ctx.lineTo(x,this.charty+this.charth-1);
this.ctx.closePath();
this.ctx.fill();
}
};
CanvasChartPainter.prototype.drawLine=function(_43){
var i,len,x,y,n,_49;
var _4a=_43.color;
var _4b=_43.values;
n=_43.range/this.charth;
_49=(_43.ymin/n);
len=_4b.length;
if(len){
this.ctx.lineWidth=1;
this.ctx.strokeStyle=_4a;
x=this.chartx+1;
y=this.charty+this.charth-(_4b[0]/n)+_49;
this.ctx.beginPath();
this.ctx.moveTo(x,y);
for(i=1;i<len;i++){
y=this.charty+this.charth-(_4b[i]/n)+_49;
x+=this.xstep;
this.ctx.lineTo(x,y);
}
this.ctx.stroke();
}
};
CanvasChartPainter.prototype.drawBars=function(_4c,_4d,_4e,_4f,_50){
var i,len,x,y,n,_56;
n=this.range/this.charth;
_56=(this.ymin/n);
len=_4d.length;
if(len>_4e){
len=_4e;
}
if(len){
this.ctx.fillStyle=_4c;
x=this.chartx+_4f+1;
for(i=0;i<len;i++){
y=this.charty+this.charth-(_4d[i]/n)+_56;
this.ctx.beginPath();
this.ctx.moveTo(x,this.charty+this.charth-1);
this.ctx.lineTo(x,y);
this.ctx.lineTo(x+_50,y);
this.ctx.lineTo(x+_50,this.charty+this.charth-1);
this.ctx.closePath();
this.ctx.fill();
x+=this.xstep;
}
}
};

