var CHART_LINE=1;
var CHART_AREA=2;
var CHART_BAR=3;
var CHART_STACKED=4;
function Chart(el){
this._cont=el;
this._yMin=null;
this._yMax=null;
this._xGridDensity=0;
this._yGridDensity=0;
this._flags=0;
this._series=new Array();
this._labelPrecision=0;
this._horizontalLabels=new Array();
this._barWidth=10;
this._barDistance=2;
this._bars=0;
this._showLegend=true;
this._doubleAxis=false;
if((typeof CanvasChartPainterFactory!="undefined")&&(window.CanvasRenderingContext2D)){
this._painterFactory=CanvasChartPainterFactory;
}else{
if(typeof JsGraphicsChartPainterFactory!="undefined"){
this._painterFactory=JsGraphicsChartPainterFactory;
}else{
this._painterFactory=null;
}
}
}
Chart.prototype.setPainterFactory=function(f){
this._painterFactory=f;
};
Chart.prototype.setDoubleAxis=function(d){
this._doubleAxis=d;
};
Chart.prototype.setVerticalRange=function(_4,_5){
this._yMin=_4;
this._yMax=_5;
};
Chart.prototype.setLabelPrecision=function(_6){
this._labelPrecision=_6;
};
Chart.prototype.setShowLegend=function(b){
this._showLegend=b;
};
Chart.prototype.setGridDensity=function(_8,_9){
this._xGridDensity=_8;
this._yGridDensity=_9;
};
Chart.prototype.setHorizontalLabels=function(_a){
this._horizontalLabels=_a;
};
Chart.prototype.setDefaultType=function(_b){
this._flags=_b;
};
Chart.prototype.setBarWidth=function(_c){
this._barWidth=_c;
};
Chart.prototype.setBarDistance=function(_d){
this._barDistance=_d;
};
Chart.prototype.add=function(_e,_f,_10,_11){
var o,_13,j,_15,_16,_17;
if(!_11){
_11=this._flags;
}
if((_11&CHART_BAR)==CHART_BAR){
_13=this._barDistance+this._bars*(this._barWidth+this._barDistance);
this._bars++;
}else{
_13=0;
}
if(!this._series[0]){
for(j=0;j<_10.length;j++){
if((_10[j]>_16)||(_16==null)){
_16=_10[j];
_16=(Math.floor(_10[j]/10)+1)*10;
}
}
_15=-10;
if(_16<50){
_16=50;
}
_17=_16-_15;
this._yGridDensity=(_17/5)+1;
}else{
if(!this._series[1]){
_15=20*this._series[0].ymin;
for(j=0;j<_10.length;j++){
if((_10[j]>_16)||(_16==null)){
_16=(Math.floor(_10[j]/100)+1)*100;
}
}
if(_16>this._series[0].ymax*20){
this._series[0].ymax=_16/20;
this._series[0].range=this._series[0].ymax-this._series[0].ymin;
_17=_16-_15;
this._yGridDensity=(_17/100)+1;
}else{
_16=this._series[0].ymax*20;
}
}else{
_16=this._series[1].ymax/1000;
axesRatio=_16/this._series[0].ymax;
_15=this._series[0].ymin*axesRatio;
}
}
o=new ChartSeries(_e,_f,_10,_11,_13,_15,_16);
this._series.push(o);
};
Chart.prototype.draw=function(){
var _18,i,o,o2,len,_1d,_1e,_1f,_20,_21,_22,_23;
if(!this._painterFactory){
return;
}
_20=new Array();
stackedSeries=new Array();
_1d=0;
_1e=this._yMin;
_1f=this._yMax;
for(i=0;i<this._series.length;i++){
o=this._series[i];
if((o.flags&CHART_STACKED)==CHART_STACKED){
_20.push(o);
}
}
for(i=_20.length-2;i>=0;i--){
o=_20[i].values;
o2=_20[i+1].values;
len=(o2.length>o.length)?o2.length:o.length;
for(j=0;j<len;j++){
if((o[j])&&(!o2[j])){
continue;
}
if((!o[j])&&(o2[j])){
o[j]=o2[j];
}else{
o[j]=parseInt(o[j])+parseFloat(o2[j]);
}
}
}
for(i=0;i<this._series.length;i++){
o=this._series[i];
if((o.flags&CHART_STACKED)!=CHART_STACKED){
_20.push(o);
}
}
for(i=0;i<_20.length;i++){
o=_20[i];
if(o.values.length>_1d){
_1d=o.values.length;
}
for(j=0;j<o.values.length;j++){
if((o.values[j]<_1e)||(_1e==null)){
_1e=o.values[j];
}
if((o.values[j]>_1f)||(_1f==null)){
_1f=o.values[j];
}
}
}
if(this._series.length==this._bars){
_1d++;
this._xGridDensity++;
}
_23=((this._xGridDensity)&&(this._yGridDensity)&&(this._horizontalLabels.length>=this._xGridDensity));
_18=this._painterFactory();
_18.create(this._cont);
_18.init(_1d,_1e,_1f,this._xGridDensity,this._yGridDensity,_23);
_18.drawBackground();
if(this._showLegend){
_18.drawLegend(_20);
}
if(_23){
_18.drawVerticalAxis(this._yGridDensity,this._labelPrecision,this._series[0]);
if(this._doubleAxis&&this._series[1]){
_18.drawOtherVerticalAxis(this._yGridDensity,this._labelPrecision,this._series[1]);
}
_18.drawHorizontalAxis(_1d,this._horizontalLabels,this._xGridDensity,this._labelPrecision);
}
_18.drawChart(this._series[0],this._yGridDensity);
for(i=0;i<_20.length;i++){
_21=_20[i].flags&~CHART_STACKED;
switch(_21){
case CHART_LINE:
_18.drawLine(_20[i]);
break;
case CHART_AREA:
_18.drawArea(_20[i].color,_20[i].values);
break;
case CHART_BAR:
_18.drawBars(_20[i].color,_20[i].values,_1d-1,_20[i].offset,this._barWidth);
break;
default:
}
}
_18.drawAxes(this._doubleAxis);
};
function ChartSeries(_24,_25,_26,_27,_28,_29,_2a){
this.label=_24;
this.color=_25;
this.values=_26;
this.flags=_27;
this.offset=_28;
this.ymin=_29;
this.ymax=_2a;
this.range=_2a-_29;
}
function AbstractChartPainter(){
}
AbstractChartPainter.prototype.calc=function(w,h,_2d,_2e,_2f,xgd,ygd){
this.range=_2f-_2e;
this.xstep=w/(_2d-1);
this.xgrid=(xgd)?w/(xgd-1):0;
this.ygrid=(ygd)?h/(ygd-1):0;
this.ymin=_2e;
this.ymax=_2f;
};
AbstractChartPainter.prototype.create=function(el){
};
AbstractChartPainter.prototype.init=function(_33,_34,_35,xgd,ygd,_38){
};
AbstractChartPainter.prototype.drawLegend=function(_39){
};
AbstractChartPainter.prototype.drawVerticalAxis=function(ygd,_3b,_3c){
};
AbstractChartPainter.prototype.drawOtherVerticalAxis=function(ygd,_3e,_3f){
};
AbstractChartPainter.prototype.drawHorizontalAxis=function(_40,_41,xgd,_43){
};
AbstractChartPainter.prototype.drawAxes=function(_44){
};
AbstractChartPainter.prototype.drawBackground=function(){
};
AbstractChartPainter.prototype.drawChart=function(_45,ygd){
};
AbstractChartPainter.prototype.drawArea=function(_47,_48){
};
AbstractChartPainter.prototype.drawLine=function(_49){
};
AbstractChartPainter.prototype.drawBars=function(_4a,_4b,_4c,_4d,_4e){
};

