//>>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++){var b,a;null!==f.data[e]&&("number"!=typeof f.data[e]&&f.data[e].hasOwnProperty("x")?(b=f.data[e].x,null!==b&&(a=n.getValue(l,h,b,k)[0],a=null!=a&&a.y?a.y:null)):(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,b,a;for(b=0;b<=k;++b)l[b].hidden||
(a=f,e=l[b].data[d],h(e)||(isNaN(e)&&(e=e.y||0),f+=e));return[f,a]},getValue:function(l,k,d,h){var f=null,e,b,a,c;for(e=0;e<=k;++e)if(!l[e].hidden)for(b=0;b<l[e].data.length;b++)if(c=f,a=l[e].data[b],!h(a))if(a.x==d){f||(f={x:d});null!=a.y&&(null==f.y&&(f.y=0),f.y+=a.y);break}else if(a.x>d)break;return[f,c]}})});