//>>built
define("dojox/charting/plot2d/commonStacked",["dojo/_base/lang","dojox/lang/functional","./common"],function(m,p,q){var n=m.getObject("dojox.charting.plot2d.commonStacked",!0);return m.mixin(n,{collectStats:function(l,k){for(var d=m.delegate(q.defaultStats),h=0;h<l.length;++h)for(var f=l[h],e=0;e<f.data.length;e++)if(null!==f.data[e]){if("number"!=typeof f.data[e]&&f.data[e].hasOwnProperty("x")){var b=f.data[e].x;if(null!==b){var a=n.getValue(l,h,b,k)[0];a=null!=a&&a.y?a.y:null}}else a=n.getIndexValue(l,
h,e,k)[0],b=e+1;d.hmin=Math.min(d.hmin,b);d.hmax=Math.max(d.hmax,b);d.vmin=Math.min(d.vmin,a);d.vmax=Math.max(d.vmax,a)}return d},rearrangeValues:function(l,k,d){var h=p.filter(l,"x"),f=h.length;if(!f)return l;for(var e={},b=0;b<f;++b){for(var a=h[b],c=a.min,g=a.max;c<g;++c)a[c]=(a[c]||0)+(e[c]||0);e=a}for(b=0;b<f;++b)for(a=h[b],c=a.min,g=a.max;c<g;++c)a[c]=this.isNullValue(a[c])?0:k(a[c])-d;if(this.opt.minWidth){k=this.opt.minWidth;for(b=f-1;b;--b)for(a=h[b],e=h[b-1],c=a.min,g=a.max;c<g;++c)a[c]-=
e[c];e=a.max;for(c=a.min;c<e;++c){for(b=d=a=0;b<f;++b)g=h[b][c],0<g&&(a+=g,++d);if(a<=d*k)for(b=0;b<f;++b)g=h[b][c],0<g&&(h[b][c]=k);else{for(b=d=0;b<f;++b)a=h[b],g=a[c],0<g&&(g<k?(d+=k-g,a[c]=k):0<d&&(g=a[c]-k,g>=d?(a[c]-=d,d=0):0<g&&(a[c]=k,d-=g)));if(0<d)for(b=f-1;0<=b;--b)if(a=h[b],g=a[c],0<g)if(g=a[c]-k,g>=d){a[c]-=d;break}else 0<g&&(a[c]=k,d-=g)}}for(b=1;b<f;++b)for(a=h[b],e=h[b-1],c=a.min,g=a.max;c<g;++c)a[c]+=e[c]}return l},getIndexValue:function(l,k,d,h){var f=0,e;for(e=0;e<=k;++e)if(!l[e].hidden){var b=
f;var a=l[e].data[d];h(a)||(isNaN(a)&&(a=a.y||0),f+=a)}return[f,b]},getValue:function(l,k,d,h){var f=null,e,b;for(e=0;e<=k;++e)if(!l[e].hidden)for(b=0;b<l[e].data.length;b++){var a=f;var c=l[e].data[b];if(!h(c))if(c.x==d){f||(f={x:d});null!=c.y&&(null==f.y&&(f.y=0),f.y+=c.y);break}else if(c.x>d)break}return[f,a]}})});