/*
 * Copyright (c) 2001-2007, TIBCO Software Inc.
 * Use, modification, and distribution subject to terms of license.
 */
jsx3.require("jsx3.chart.CartesianChart","jsx3.chart.BarSeries");jsx3.Class.defineClass("jsx3.chart.BCChart",jsx3.chart.CartesianChart,null,function(q,e){q.TYPE_CLUSTERED="clustered";q.TYPE_STACKED="stacked";q.TYPE_STACKED100="stacked100";q.jv={clustered:1,stacked:1,stacked100:1};e.init=function(c,g,j,m,k){this.jsxsuper(c,g,j,m,k);this.type=q.TYPE_CLUSTERED;this.seriesOverlap=0;this.categoryCoverage=0.65;};e.getType=function(){return this.type;};e.setType=function(r){if(q.jv[r])this.type=r;else throw new jsx3.IllegalArgumentException("type",r);};e.getSeriesOverlap=function(){return !isNaN(this.seriesOverlap)?this.seriesOverlap:0;};e.setSeriesOverlap=function(h){this.seriesOverlap=h;};e.getCategoryCoverage=function(){return !isNaN(this.categoryCoverage)?this.categoryCoverage:1;};e.setCategoryCoverage=function(m){this.categoryCoverage=m;};e.pC=jsx3.Method.newAbstract();e.Wh=jsx3.Method.newAbstract();e.Td=function(b,a,p,r,l,m){if(this.type==q.TYPE_STACKED||this.type==q.TYPE_STACKED100){p=0;r=1;}var Dc=a-b;var lb=Dc*m;var ic=(b+a)/2;var Wb=lb/(r-r*l+l);var nc=Wb*(p-(r-1)/2)*(1-l);var Mc=null;if(p>0&&l==0){var cb=Wb*(p-1-(r-1)/2)*(1-l);Mc=Math.round(ic+cb+Wb/2);}else{Mc=Math.round(ic+nc-Wb/2);}var U=Math.round(ic+nc+Wb/2)-1;return [Mc,U];};e.Ns=function(a){if(this.type==q.TYPE_CLUSTERED){var ec=this.getRangeForField(a,"getParallelValue");var J=this.getRangeForField(a,"getMinValue");return this.getCombinedRange([ec,J]);}else{if(this.type==q.TYPE_STACKED){return this.getStackedRangeForField(a,"getParallelValue");}else{if(this.type==q.TYPE_STACKED100){return this.getStacked100RangeForField(a,"getParallelValue");}else{jsx3.chart.LOG.error("unsupported Bar/Column Chart type: "+this.type);return null;}}}};e.We=function(p){return this.getRangeForField(p,"getNormalValue");};e.updateView=function(){this.jsxsuper();this.JJ();};e.JJ=function(){var J=this.M4();var pb=this.aO();var nc=pb.length;if(nc==0)return;var vc=this.gH();var yc=this.pC();var nb=this.Wh();if(vc==null||yc==null||nb==null)return;if(!jsx3.chart.isValueAxis(yc)){jsx3.chart.LOG.error("bad parallel axis type: "+yc.getClass());return;}var W=this.getSeriesOverlap();var _=this.getCategoryCoverage();var Bb=null;if(this.type==q.TYPE_STACKED100)Bb=this.Z6(pb,"getParallelValue");var xb=null,A=null;if(this.type==q.TYPE_STACKED||this.type==q.TYPE_STACKED100){xb=new Array(vc.length);A=new Array(vc.length);for(var Fc=0;Fc<vc.length;Fc++){xb[Fc]=A[Fc]=0;}}for(var Fc=0;Fc<nc;Fc++){var jc=pb[Fc];jc.MY();for(var Qb=0;Qb<vc.length;Qb++){var H=vc[Qb];var ab=null,hc=null;if(jsx3.chart.isValueAxis(yc)){var db=jc.getParallelValue(H);if(this.type==q.TYPE_CLUSTERED){ab=jc.getMinValue(H);if(ab==null)ab=0;hc=db;if(hc==null){continue;}}else{if(this.type==q.TYPE_STACKED||this.type==q.TYPE_STACKED100){var rb=this.type==q.TYPE_STACKED?db:100*(db/Bb[Qb]);if(rb>=0){ab=xb[Qb];hc=xb[Qb]+rb;xb[Qb]=hc;}else{ab=A[Qb]+rb;hc=A[Qb];A[Qb]=ab;}}}}var Jc=yc.getCoordinateForNoClip(ab);if(ab!=0)Jc=Jc+(yc.getHorizontal()?1:-1);var w=yc.getCoordinateForNoClip(hc);var cb=null,wc=null;if(jsx3.chart.isValueAxis(nb)){var _b=jc.getNormalValue(H);if(_b==null)continue;var xc=nb.getCoordinateForNoClip(_b);var L=jc.getNormalWidth();cb=xc-Math.ceil(L/2);wc=xc+Math.floor(L/2);}else{if(jsx3.chart.isCategoryAxis(nb)){var Q=nb.getRangeForCategory(Qb);var Ec=this.Td(Q[0],Q[1],Fc,nc,W,_);cb=Ec[0];wc=Ec[1];}}jc.ZW(H,Qb,Jc,cb,w,wc);}jc.updateView();J.appendChild(jc.l5());}};q.getVersion=function(){return jsx3.chart.q2;};});jsx3.Class.defineClass("jsx3.chart.BarChart",jsx3.chart.BCChart,null,function(f,m){m.init=function(e,i,l,k,g){this.jsxsuper(e,i,l,k,g);};m.wH=function(k){return k instanceof jsx3.chart.BarSeries;};m.getXRange=function(h){return this.Ns(h);};m.getYRange=function(o){return this.We(o);};m.pC=function(){return this.getPrimaryXAxis();};m.Wh=function(){return this.getPrimaryYAxis();};m.toString=function(){return "[BarChart '"+this.getName()+"']";};});jsx3.Class.defineClass("jsx3.chart.ColumnChart",jsx3.chart.BCChart,null,function(s,e){e.init=function(r,c,f,q,g){this.jsxsuper(r,c,f,q,g);};e.wH=function(i){return i instanceof jsx3.chart.ColumnSeries;};e.getXRange=function(o){return this.We(o);};e.getYRange=function(b){return this.Ns(b);};e.pC=function(){return this.getPrimaryYAxis();};e.Wh=function(){return this.getPrimaryXAxis();};e.toString=function(){return "[ColumnChart '"+this.getName()+"']";};});
