/* YUI 3.9.1 (build 5852) Copyright 2013 Yahoo! Inc. http://yuilibrary.com/license/ */
YUI.add("series-fill-util",function(e,t){function r(){}var n=e.Lang;r.ATTRS={area:{getter:function(){return this._defaults||this._getAreaDefaults()},setter:function(t){var n=this._defaults||this._getAreaDefaults();this._defaults=e.merge(n,t)}}},r.prototype={_getPath:function(){var e=this._path;return e||(e=this.get("graphic").addShape({type:"path"}),this._path=e),e},_toggleVisible:function(e){this._path&&this._path.set("visible",e)},drawFill:function(e,t){if(e.length<1)return;var r=n.isNumber,i=e.length,s=e[0],o=t[0],u=s,a=o,f,l,c,h=!0,p=0,d=this.get("styles").area,v=this._getPath(),m=d.color||this._getDefaultColor(this.get("graphOrder"),"slice");v.clear(),v.set("fill",{color:m,opacity:d.alpha}),v.set("stroke",{weight:0});for(;p<i;p=++p){f=e[p],l=t[p],c=r(f)&&r(l);if(!c)continue;h?(this._firstValidX=f,this._firstValidY=l,h=!1,v.moveTo(f,l)):v.lineTo(f,l),u=f,a=l}this._lastValidX=u,this._lastValidY=a,v.end()},drawAreaSpline:function(){if(this.get("xcoords").length<1)return;var e=this.get("xcoords"),t=this.get("ycoords"),n=this.getCurveControlPoints(e,t),r=n.length,i,s,o,u,a,f,l=0,c=e[0],h=t[0],p=this.get("styles").area,d=this._getPath(),v=p.color||this._getDefaultColor(this.get("graphOrder"),"slice");d.set("fill",{color:v,opacity:p.alpha}),d.set("stroke",{weight:0}),d.moveTo(c,h);for(;l<r;l=++l)a=n[l].endx,f=n[l].endy,i=n[l].ctrlx1,s=n[l].ctrlx2,o=n[l].ctrly1,u=n[l].ctrly2,d.curveTo(i,o,s,u,a,f);this.get("direction")==="vertical"?(d.lineTo(this._leftOrigin,f),d.lineTo(this._leftOrigin,h)):(d.lineTo(a,this._bottomOrigin),d.lineTo(c,this._bottomOrigin)),d.lineTo(c,h),d.end()},drawStackedAreaSpline:function(){if(this.get("xcoords").length<1)return;var e=this.get("xcoords"),t=this.get("ycoords"),n,r=this.get("order"),i=this.get("seriesTypeCollection"),s,o,u,a,f,l,c,h,p,d=0,v,m,g=this.get("styles").area,y=this._getPath(),b=g.color||this._getDefaultColor(this.get("graphOrder"),"slice");v=e[0],m=t[0],n=this.getCurveControlPoints(e,t),u=n.length,y.set("fill",{color:b,opacity:g.alpha}),y.set("stroke",{weight:0}),y.moveTo(v,m);for(;d<u;d=++d)h=n[d].endx,p=n[d].endy,a=n[d].ctrlx1,f=n[d].ctrlx2,l=n[d].ctrly1,c=n[d].ctrly2,y.curveTo(a,l,f,c,h,p);if(r>0){s=i[r-1].get("xcoords").concat().reverse(),o=i[r-1].get("ycoords").concat().reverse(),n=this.getCurveControlPoints(s,o),d=0,u=n.length,y.lineTo(s[0],o[0]);for(;d<u;d=++d)h=n[d].endx,p=n[d].endy,a=n[d].ctrlx1,f=n[d].ctrlx2,l=n[d].ctrly1,c=n[d].ctrly2,y.curveTo(a,l,f,c,h,p)}else this.get("direction")==="vertical"?(y.lineTo(this._leftOrigin,t[t.length-1]),y.lineTo(this._leftOrigin,m)):(y.lineTo(e[e.length-1],this._bottomOrigin),y.lineTo(v,this._bottomOrigin));y.lineTo(v,m),y.end()},_defaults:null,_getClosingPoints:function(){var e=this.get("xcoords").concat(),t=this.get("ycoords").concat(),n,r;return this.get("direction")==="vertical"?(r=this._getLastValidIndex(e),n=this._getFirstValidIndex(e),t.push(t[r]),t.push(t[n]),e.push(this._leftOrigin),e.push(this._leftOrigin)):(r=this._getLastValidIndex(t),n=this._getFirstValidIndex(t),e.push(e[r]),e.push(e[n]),t.push(this._bottomOrigin),t.push(this._bottomOrigin)),e.push(e[0]),t.push(t[0]),[e,t]},_getHighestValidOrder:function(e,t,n,r){var i=r==="vertical"?"stackedXCoords":"stackedYCoords",s;while(isNaN(s)&&n>-1)n-=1,n>-1&&(s=e[n].get(i)[t]);return n},_getCoordsByOrderAndIndex:function(e,t,n,r){var i,s;return r==="vertical"?(i=n<0?this._leftOrigin:e[n].get("stackedXCoords")[t],s=this.get("stackedYCoords")[t]):(i=this.get("stackedXCoords")[t],s=n<0?this._bottomOrigin:e[n].get("stackedYCoords")[t]),[i,s]},_getStackedClosingPoints:function(){var e=this.get("order"),t=this.get("direction"),n=this.get("seriesTypeCollection"),r,i,s=this.get("stackedXCoords"),o=this.get("stackedYCoords"),u,a,f,l,c,h,p,d,v,m,g,y;if(e<1)return this._getClosingPoints();a=n[e-1],c=a.get("stackedXCoords").concat(),h=a.get("stackedYCoords").concat(),t==="vertical"?(r=this._getFirstValidIndex(s),i=this._getLastValidIndex(s),f=a._getFirstValidIndex(c),l=a._getLastValidIndex(c)):(r=this._getFirstValidIndex(o),i=this._getLastValidIndex(o),f=a._getFirstValidIndex(h),l=a._getLastValidIndex(h)),l>=r&&f<=i?(f=Math.max(r,f),l=Math.min(i,l),c=c.slice(f,l+1),h=h.slice(f,l+1),u=f):u=i,d=[s[r]],v=[o[r]],m=r;while((isNaN(g)||g<e-1)&&m<=u)y=g,g=this._getHighestValidOrder(n,m,e,t),!isNaN(y)&&g>y&&(p=this._getCoordsByOrderAndIndex(n,m,y,t),d.push(p[0]),v.push(p[1])),p=this._getCoordsByOrderAndIndex(n,m,g,t),d.push(p[0]),v.push(p[1]),m+=1;c&&c.length>0&&l>r&&f<i&&(d=d.concat(c),v=v.concat(h),g=e-1),m=Math.max(r,l),e-=1,g=NaN;while(m<=i)y=g,g=this._getHighestValidOrder(n,m,e,t),isNaN(y)||(g>y?(p=this._getCoordsByOrderAndIndex(n,m,y,t),d.push(p[0]),v.push(p[1])):g<y&&(p=this._getCoordsByOrderAndIndex(n,m-1,g,t),d.push(p[0]),v.push(p[1]))),p=this._getCoordsByOrderAndIndex(n,m,g,t),d.push(p[0]),v.push(p[1]),m+=1;return d.reverse(),v.reverse(),[s.concat(d),o.concat(v)]},_getAreaDefaults:function(){return{}}},e.augment(r,e.Attribute),e.Fills=r},"3.9.1");
