(function(b){var a={series:{stack:null}};function c(f){function d(k,j){var h=null;for(var g=0;g<j.length;++g){if(k==j[g]){break}if(j[g].stack==k.stack&&j[g].enabled&&j[g].datapoints.points.length!=0){h=j[g]}}return h}function e(O,F,g){if(F.stack==null||F.stack===false||F.enabled==false||g.points.length==0){return}var q=d(F,O.getData());if(!q){return}if(q.datapoints.points.length>g.points.length){var J=[];var D=0,B=0,A=0,v=-1,X=q.datapoints.points.length,k=q.datapoints.pointsize,H=g.points.length,W=g.pointsize;for(B=0;B<X;B+=k){v=-1;for(A=0;A<H;A+=W){if(q.datapoints.points[B]==g.points[A]){v=A;break}}if(v>-1){for(D=0;D<W;++D){J.push(g.points[v+D])}}else{J.push(q.datapoints.points[B]);for(D=1;D<k;++D){J.push(0)}}}F.datapoints.points=J;g.points=J}var L=g.pointsize,R=g.points,h=q.datapoints.pointsize,I=q.datapoints.points,u=[],G,E,n,V,U,t,C=F.lines.show,S=F.bars.horizontal,p=L>2&&(S?g.format[2].x:g.format[2].y),o=C&&F.lines.steps,Q=true,r=S?1:0,T=S?0:1,P=0,N=0,M,K;while(true){if(P>=R.length){break}M=u.length;if(R[P]==null){for(K=0;K<L;++K){u.push(R[P+K])}P+=L}else{if(N>=I.length){if(!C){for(K=0;K<L;++K){u.push(R[P+K])}}P+=L}else{if(I[N]==null){for(K=0;K<L;++K){u.push(null)}Q=true;N+=h}else{G=R[P+r];E=R[P+T];V=I[N+r];U=I[N+T];t=0;if(G==V){for(K=0;K<L;++K){u.push(R[P+K])}u[M+T]+=U;t=U;P+=L;N+=h}else{if(G>V){if(C&&P>0&&R[P-L]!=null){n=E+(R[P-L+T]-E)*(V-G)/(R[P-L+r]-G);u.push(V);u.push(n+U);for(K=2;K<L;++K){u.push(R[P+K])}t=U}N+=h}else{if(Q&&C){P+=L;continue}for(K=0;K<L;++K){u.push(R[P+K])}if(C&&N>0&&I[N-h]!=null){t=U+(I[N-h+T]-U)*(G-V)/(I[N-h+r]-V)}u[M+T]+=t;P+=L}}Q=false;if(M!=u.length&&p){u[M+2]+=t}}}}if(o&&M!=u.length&&M>0&&u[M]!=null&&u[M]!=u[M-L]&&u[M+1]!=u[M-L+1]){for(K=0;K<L;++K){u[M+L+K]=u[M+K]}u[M+1]=u[M-L+1]}}g.points=u}f.hooks.processDatapoints.push(e)}b.plot.plugins.push({init:c,options:a,name:"stack",version:"1.2"})})(jQuery);