first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,517 @@
YUI.add('series-fill-util', function (Y, NAME) {
/**
* Provides functionality for drawing fills in a series.
*
* @module charts
* @submodule series-fill-util
*/
var Y_Lang = Y.Lang;
/**
* Utility class used for drawing area fills.
*
* @class Fills
* @constructor
* @submodule series-fill-util
*/
function Fills() {}
Fills.ATTRS = {
area: {
getter: function()
{
return this._defaults || this._getAreaDefaults();
},
setter: function(val)
{
var defaults = this._defaults || this._getAreaDefaults();
this._defaults = Y.merge(defaults, val);
}
}
};
Fills.prototype = {
/**
* Returns a path shape used for drawing fills.
*
* @method _getPath
* @return Path
* @private
*/
_getPath: function()
{
var path = this._path;
if(!path)
{
path = this.get("graphic").addShape({type:"path"});
this._path = path;
}
return path;
},
/**
* Toggles visibility
*
* @method _toggleVisible
* @param {Boolean} visible indicates visibilitye
* @private
*/
_toggleVisible: function(visible)
{
if(this._path)
{
this._path.set("visible", visible);
}
},
/**
* Draws fill
*
* @method drawFill
* @param {Array} xcoords The x-coordinates for the series.
* @param {Array} ycoords The y-coordinates for the series.
* @protected
*/
drawFill: function(xcoords, ycoords)
{
if(xcoords.length < 1)
{
return;
}
var isNumber = Y_Lang.isNumber,
len = xcoords.length,
firstX = xcoords[0],
firstY = ycoords[0],
lastValidX = firstX,
lastValidY = firstY,
nextX,
nextY,
pointValid,
noPointsRendered = true,
i = 0,
styles = this.get("styles").area,
path = this._getPath(),
color = styles.color || this._getDefaultColor(this.get("graphOrder"), "slice");
path.clear();
path.set("fill", {
color: color,
opacity: styles.alpha
});
path.set("stroke", {weight: 0});
for(; i < len; i = ++i)
{
nextX = xcoords[i];
nextY = ycoords[i];
pointValid = isNumber(nextX) && isNumber(nextY);
if(!pointValid)
{
continue;
}
if(noPointsRendered)
{
this._firstValidX = nextX;
this._firstValidY = nextY;
noPointsRendered = false;
path.moveTo(nextX, nextY);
}
else
{
path.lineTo(nextX, nextY);
}
lastValidX = nextX;
lastValidY = nextY;
}
this._lastValidX = lastValidX;
this._lastValidY = lastValidY;
path.end();
},
/**
* Draws a fill for a spline
*
* @method drawAreaSpline
* @protected
*/
drawAreaSpline: function()
{
if(this.get("xcoords").length < 1)
{
return;
}
var xcoords = this.get("xcoords"),
ycoords = this.get("ycoords"),
curvecoords = this.getCurveControlPoints(xcoords, ycoords),
len = curvecoords.length,
cx1,
cx2,
cy1,
cy2,
x,
y,
i = 0,
firstX = xcoords[0],
firstY = ycoords[0],
styles = this.get("styles").area,
path = this._getPath(),
color = styles.color || this._getDefaultColor(this.get("graphOrder"), "slice");
path.set("fill", {
color: color,
opacity: styles.alpha
});
path.set("stroke", {weight: 0});
path.moveTo(firstX, firstY);
for(; i < len; i = ++i)
{
x = curvecoords[i].endx;
y = curvecoords[i].endy;
cx1 = curvecoords[i].ctrlx1;
cx2 = curvecoords[i].ctrlx2;
cy1 = curvecoords[i].ctrly1;
cy2 = curvecoords[i].ctrly2;
path.curveTo(cx1, cy1, cx2, cy2, x, y);
}
if(this.get("direction") === "vertical")
{
path.lineTo(this._leftOrigin, y);
path.lineTo(this._leftOrigin, firstY);
}
else
{
path.lineTo(x, this._bottomOrigin);
path.lineTo(firstX, this._bottomOrigin);
}
path.lineTo(firstX, firstY);
path.end();
},
/**
* Draws a a stacked area spline
*
* @method drawStackedAreaSpline
* @protected
*/
drawStackedAreaSpline: function()
{
if(this.get("xcoords").length < 1)
{
return;
}
var xcoords = this.get("xcoords"),
ycoords = this.get("ycoords"),
curvecoords,
order = this.get("order"),
seriesCollection = this.get("seriesTypeCollection"),
prevXCoords,
prevYCoords,
len,
cx1,
cx2,
cy1,
cy2,
x,
y,
i = 0,
firstX,
firstY,
styles = this.get("styles").area,
path = this._getPath(),
color = styles.color || this._getDefaultColor(this.get("graphOrder"), "slice");
firstX = xcoords[0];
firstY = ycoords[0];
curvecoords = this.getCurveControlPoints(xcoords, ycoords);
len = curvecoords.length;
path.set("fill", {
color: color,
opacity: styles.alpha
});
path.set("stroke", {weight: 0});
path.moveTo(firstX, firstY);
for(; i < len; i = ++i)
{
x = curvecoords[i].endx;
y = curvecoords[i].endy;
cx1 = curvecoords[i].ctrlx1;
cx2 = curvecoords[i].ctrlx2;
cy1 = curvecoords[i].ctrly1;
cy2 = curvecoords[i].ctrly2;
path.curveTo(cx1, cy1, cx2, cy2, x, y);
}
if(order > 0)
{
prevXCoords = seriesCollection[order - 1].get("xcoords").concat().reverse();
prevYCoords = seriesCollection[order - 1].get("ycoords").concat().reverse();
curvecoords = this.getCurveControlPoints(prevXCoords, prevYCoords);
i = 0;
len = curvecoords.length;
path.lineTo(prevXCoords[0], prevYCoords[0]);
for(; i < len; i = ++i)
{
x = curvecoords[i].endx;
y = curvecoords[i].endy;
cx1 = curvecoords[i].ctrlx1;
cx2 = curvecoords[i].ctrlx2;
cy1 = curvecoords[i].ctrly1;
cy2 = curvecoords[i].ctrly2;
path.curveTo(cx1, cy1, cx2, cy2, x, y);
}
}
else
{
if(this.get("direction") === "vertical")
{
path.lineTo(this._leftOrigin, ycoords[ycoords.length-1]);
path.lineTo(this._leftOrigin, firstY);
}
else
{
path.lineTo(xcoords[xcoords.length-1], this._bottomOrigin);
path.lineTo(firstX, this._bottomOrigin);
}
}
path.lineTo(firstX, firstY);
path.end();
},
/**
* Storage for default area styles.
*
* @property _defaults
* @type Object
* @private
*/
_defaults: null,
/**
* Concatenates coordinate array with correct coordinates for closing an area fill.
*
* @method _getClosingPoints
* @return Array
* @protected
*/
_getClosingPoints: function()
{
var xcoords = this.get("xcoords").concat(),
ycoords = this.get("ycoords").concat(),
firstValidIndex,
lastValidIndex;
if(this.get("direction") === "vertical")
{
lastValidIndex = this._getLastValidIndex(xcoords);
firstValidIndex = this._getFirstValidIndex(xcoords);
ycoords.push(ycoords[lastValidIndex]);
ycoords.push(ycoords[firstValidIndex]);
xcoords.push(this._leftOrigin);
xcoords.push(this._leftOrigin);
}
else
{
lastValidIndex = this._getLastValidIndex(ycoords);
firstValidIndex = this._getFirstValidIndex(ycoords);
xcoords.push(xcoords[lastValidIndex]);
xcoords.push(xcoords[firstValidIndex]);
ycoords.push(this._bottomOrigin);
ycoords.push(this._bottomOrigin);
}
xcoords.push(xcoords[0]);
ycoords.push(ycoords[0]);
return [xcoords, ycoords];
},
/**
* Returns the order of the series closest to the current series that has a valid value for the current index.
*
* @method _getHighestValidOrder
* @param {Array} seriesCollection Array of series of a given type.
* @param {Number} index Index of the series item.
* @param {Number} order Index of the the series in the seriesCollection
* @param {String} direction Indicates the direction of the series
* @return Number
* @private
*/
_getHighestValidOrder: function(seriesCollection, index, order, direction)
{
var coords = direction === "vertical" ? "stackedXCoords" : "stackedYCoords",
coord;
while(isNaN(coord) && order > -1)
{
order = order - 1;
if(order > -1)
{
coord = seriesCollection[order].get(coords)[index];
}
}
return order;
},
/**
* Returns an array containing the x and y coordinates for a given series and index.
*
* @method _getCoordsByOrderAndIndex
* @param {Array} seriesCollection Array of series of a given type.
* @param {Number} index Index of the series item.
* @param {Number} order Index of the the series in the seriesCollection
* @param {String} direction Indicates the direction of the series
* @return Array
* @private
*/
_getCoordsByOrderAndIndex: function(seriesCollection, index, order, direction)
{
var xcoord,
ycoord;
if(direction === "vertical")
{
xcoord = order < 0 ? this._leftOrigin : seriesCollection[order].get("stackedXCoords")[index];
ycoord = this.get("stackedYCoords")[index];
}
else
{
xcoord = this.get("stackedXCoords")[index];
ycoord = order < 0 ? this._bottomOrigin : seriesCollection[order].get("stackedYCoords")[index];
}
return [xcoord, ycoord];
},
/**
* Concatenates coordinate array with the correct coordinates for closing an area stack.
*
* @method _getStackedClosingPoints
* @return Array
* @protected
*/
_getStackedClosingPoints: function()
{
var order = this.get("order"),
direction = this.get("direction"),
seriesCollection = this.get("seriesTypeCollection"),
firstValidIndex,
lastValidIndex,
xcoords = this.get("stackedXCoords"),
ycoords = this.get("stackedYCoords"),
limit,
previousSeries,
previousSeriesFirstValidIndex,
previousSeriesLastValidIndex,
previousXCoords,
previousYCoords,
coords,
closingXCoords,
closingYCoords,
currentIndex,
highestValidOrder,
oldOrder;
if(order < 1)
{
return this._getClosingPoints();
}
previousSeries = seriesCollection[order - 1];
previousXCoords = previousSeries.get("stackedXCoords").concat();
previousYCoords = previousSeries.get("stackedYCoords").concat();
if(direction === "vertical")
{
firstValidIndex = this._getFirstValidIndex(xcoords);
lastValidIndex = this._getLastValidIndex(xcoords);
previousSeriesFirstValidIndex = previousSeries._getFirstValidIndex(previousXCoords);
previousSeriesLastValidIndex = previousSeries._getLastValidIndex(previousXCoords);
}
else
{
firstValidIndex = this._getFirstValidIndex(ycoords);
lastValidIndex = this._getLastValidIndex(ycoords);
previousSeriesFirstValidIndex = previousSeries._getFirstValidIndex(previousYCoords);
previousSeriesLastValidIndex = previousSeries._getLastValidIndex(previousYCoords);
}
if(previousSeriesLastValidIndex >= firstValidIndex && previousSeriesFirstValidIndex <= lastValidIndex)
{
previousSeriesFirstValidIndex = Math.max(firstValidIndex, previousSeriesFirstValidIndex);
previousSeriesLastValidIndex = Math.min(lastValidIndex, previousSeriesLastValidIndex);
previousXCoords = previousXCoords.slice(previousSeriesFirstValidIndex, previousSeriesLastValidIndex + 1);
previousYCoords = previousYCoords.slice(previousSeriesFirstValidIndex, previousSeriesLastValidIndex + 1);
limit = previousSeriesFirstValidIndex;
}
else
{
limit = lastValidIndex;
}
closingXCoords = [xcoords[firstValidIndex]];
closingYCoords = [ycoords[firstValidIndex]];
currentIndex = firstValidIndex;
while((isNaN(highestValidOrder) || highestValidOrder < order - 1) && currentIndex <= limit)
{
oldOrder = highestValidOrder;
highestValidOrder = this._getHighestValidOrder(seriesCollection, currentIndex, order, direction);
if(!isNaN(oldOrder) && highestValidOrder > oldOrder)
{
coords = this._getCoordsByOrderAndIndex(seriesCollection, currentIndex, oldOrder, direction);
closingXCoords.push(coords[0]);
closingYCoords.push(coords[1]);
}
coords = this._getCoordsByOrderAndIndex(seriesCollection, currentIndex, highestValidOrder, direction);
closingXCoords.push(coords[0]);
closingYCoords.push(coords[1]);
currentIndex = currentIndex + 1;
}
if(previousXCoords &&
previousXCoords.length > 0 &&
previousSeriesLastValidIndex > firstValidIndex &&
previousSeriesFirstValidIndex < lastValidIndex)
{
closingXCoords = closingXCoords.concat(previousXCoords);
closingYCoords = closingYCoords.concat(previousYCoords);
highestValidOrder = order -1;
}
currentIndex = Math.max(firstValidIndex, previousSeriesLastValidIndex);
order = order - 1;
highestValidOrder = NaN;
while(currentIndex <= lastValidIndex)
{
oldOrder = highestValidOrder;
highestValidOrder = this._getHighestValidOrder(seriesCollection, currentIndex, order, direction);
if(!isNaN(oldOrder))
{
if(highestValidOrder > oldOrder)
{
coords = this._getCoordsByOrderAndIndex(seriesCollection, currentIndex, oldOrder, direction);
closingXCoords.push(coords[0]);
closingYCoords.push(coords[1]);
}
else if(highestValidOrder < oldOrder)
{
coords = this._getCoordsByOrderAndIndex(seriesCollection, currentIndex - 1, highestValidOrder, direction);
closingXCoords.push(coords[0]);
closingYCoords.push(coords[1]);
}
}
coords = this._getCoordsByOrderAndIndex(seriesCollection, currentIndex, highestValidOrder, direction);
closingXCoords.push(coords[0]);
closingYCoords.push(coords[1]);
currentIndex = currentIndex + 1;
}
closingXCoords.reverse();
closingYCoords.reverse();
return [xcoords.concat(closingXCoords), ycoords.concat(closingYCoords)];
},
/**
* Returns default values for area styles.
*
* @method _getAreaDefaults
* @return Object
* @private
*/
_getAreaDefaults: function()
{
return {
};
}
};
Y.augment(Fills, Y.Attribute);
Y.Fills = Fills;
}, '3.18.1');
@@ -0,0 +1 @@
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.18.1");
@@ -0,0 +1,517 @@
YUI.add('series-fill-util', function (Y, NAME) {
/**
* Provides functionality for drawing fills in a series.
*
* @module charts
* @submodule series-fill-util
*/
var Y_Lang = Y.Lang;
/**
* Utility class used for drawing area fills.
*
* @class Fills
* @constructor
* @submodule series-fill-util
*/
function Fills() {}
Fills.ATTRS = {
area: {
getter: function()
{
return this._defaults || this._getAreaDefaults();
},
setter: function(val)
{
var defaults = this._defaults || this._getAreaDefaults();
this._defaults = Y.merge(defaults, val);
}
}
};
Fills.prototype = {
/**
* Returns a path shape used for drawing fills.
*
* @method _getPath
* @return Path
* @private
*/
_getPath: function()
{
var path = this._path;
if(!path)
{
path = this.get("graphic").addShape({type:"path"});
this._path = path;
}
return path;
},
/**
* Toggles visibility
*
* @method _toggleVisible
* @param {Boolean} visible indicates visibilitye
* @private
*/
_toggleVisible: function(visible)
{
if(this._path)
{
this._path.set("visible", visible);
}
},
/**
* Draws fill
*
* @method drawFill
* @param {Array} xcoords The x-coordinates for the series.
* @param {Array} ycoords The y-coordinates for the series.
* @protected
*/
drawFill: function(xcoords, ycoords)
{
if(xcoords.length < 1)
{
return;
}
var isNumber = Y_Lang.isNumber,
len = xcoords.length,
firstX = xcoords[0],
firstY = ycoords[0],
lastValidX = firstX,
lastValidY = firstY,
nextX,
nextY,
pointValid,
noPointsRendered = true,
i = 0,
styles = this.get("styles").area,
path = this._getPath(),
color = styles.color || this._getDefaultColor(this.get("graphOrder"), "slice");
path.clear();
path.set("fill", {
color: color,
opacity: styles.alpha
});
path.set("stroke", {weight: 0});
for(; i < len; i = ++i)
{
nextX = xcoords[i];
nextY = ycoords[i];
pointValid = isNumber(nextX) && isNumber(nextY);
if(!pointValid)
{
continue;
}
if(noPointsRendered)
{
this._firstValidX = nextX;
this._firstValidY = nextY;
noPointsRendered = false;
path.moveTo(nextX, nextY);
}
else
{
path.lineTo(nextX, nextY);
}
lastValidX = nextX;
lastValidY = nextY;
}
this._lastValidX = lastValidX;
this._lastValidY = lastValidY;
path.end();
},
/**
* Draws a fill for a spline
*
* @method drawAreaSpline
* @protected
*/
drawAreaSpline: function()
{
if(this.get("xcoords").length < 1)
{
return;
}
var xcoords = this.get("xcoords"),
ycoords = this.get("ycoords"),
curvecoords = this.getCurveControlPoints(xcoords, ycoords),
len = curvecoords.length,
cx1,
cx2,
cy1,
cy2,
x,
y,
i = 0,
firstX = xcoords[0],
firstY = ycoords[0],
styles = this.get("styles").area,
path = this._getPath(),
color = styles.color || this._getDefaultColor(this.get("graphOrder"), "slice");
path.set("fill", {
color: color,
opacity: styles.alpha
});
path.set("stroke", {weight: 0});
path.moveTo(firstX, firstY);
for(; i < len; i = ++i)
{
x = curvecoords[i].endx;
y = curvecoords[i].endy;
cx1 = curvecoords[i].ctrlx1;
cx2 = curvecoords[i].ctrlx2;
cy1 = curvecoords[i].ctrly1;
cy2 = curvecoords[i].ctrly2;
path.curveTo(cx1, cy1, cx2, cy2, x, y);
}
if(this.get("direction") === "vertical")
{
path.lineTo(this._leftOrigin, y);
path.lineTo(this._leftOrigin, firstY);
}
else
{
path.lineTo(x, this._bottomOrigin);
path.lineTo(firstX, this._bottomOrigin);
}
path.lineTo(firstX, firstY);
path.end();
},
/**
* Draws a a stacked area spline
*
* @method drawStackedAreaSpline
* @protected
*/
drawStackedAreaSpline: function()
{
if(this.get("xcoords").length < 1)
{
return;
}
var xcoords = this.get("xcoords"),
ycoords = this.get("ycoords"),
curvecoords,
order = this.get("order"),
seriesCollection = this.get("seriesTypeCollection"),
prevXCoords,
prevYCoords,
len,
cx1,
cx2,
cy1,
cy2,
x,
y,
i = 0,
firstX,
firstY,
styles = this.get("styles").area,
path = this._getPath(),
color = styles.color || this._getDefaultColor(this.get("graphOrder"), "slice");
firstX = xcoords[0];
firstY = ycoords[0];
curvecoords = this.getCurveControlPoints(xcoords, ycoords);
len = curvecoords.length;
path.set("fill", {
color: color,
opacity: styles.alpha
});
path.set("stroke", {weight: 0});
path.moveTo(firstX, firstY);
for(; i < len; i = ++i)
{
x = curvecoords[i].endx;
y = curvecoords[i].endy;
cx1 = curvecoords[i].ctrlx1;
cx2 = curvecoords[i].ctrlx2;
cy1 = curvecoords[i].ctrly1;
cy2 = curvecoords[i].ctrly2;
path.curveTo(cx1, cy1, cx2, cy2, x, y);
}
if(order > 0)
{
prevXCoords = seriesCollection[order - 1].get("xcoords").concat().reverse();
prevYCoords = seriesCollection[order - 1].get("ycoords").concat().reverse();
curvecoords = this.getCurveControlPoints(prevXCoords, prevYCoords);
i = 0;
len = curvecoords.length;
path.lineTo(prevXCoords[0], prevYCoords[0]);
for(; i < len; i = ++i)
{
x = curvecoords[i].endx;
y = curvecoords[i].endy;
cx1 = curvecoords[i].ctrlx1;
cx2 = curvecoords[i].ctrlx2;
cy1 = curvecoords[i].ctrly1;
cy2 = curvecoords[i].ctrly2;
path.curveTo(cx1, cy1, cx2, cy2, x, y);
}
}
else
{
if(this.get("direction") === "vertical")
{
path.lineTo(this._leftOrigin, ycoords[ycoords.length-1]);
path.lineTo(this._leftOrigin, firstY);
}
else
{
path.lineTo(xcoords[xcoords.length-1], this._bottomOrigin);
path.lineTo(firstX, this._bottomOrigin);
}
}
path.lineTo(firstX, firstY);
path.end();
},
/**
* Storage for default area styles.
*
* @property _defaults
* @type Object
* @private
*/
_defaults: null,
/**
* Concatenates coordinate array with correct coordinates for closing an area fill.
*
* @method _getClosingPoints
* @return Array
* @protected
*/
_getClosingPoints: function()
{
var xcoords = this.get("xcoords").concat(),
ycoords = this.get("ycoords").concat(),
firstValidIndex,
lastValidIndex;
if(this.get("direction") === "vertical")
{
lastValidIndex = this._getLastValidIndex(xcoords);
firstValidIndex = this._getFirstValidIndex(xcoords);
ycoords.push(ycoords[lastValidIndex]);
ycoords.push(ycoords[firstValidIndex]);
xcoords.push(this._leftOrigin);
xcoords.push(this._leftOrigin);
}
else
{
lastValidIndex = this._getLastValidIndex(ycoords);
firstValidIndex = this._getFirstValidIndex(ycoords);
xcoords.push(xcoords[lastValidIndex]);
xcoords.push(xcoords[firstValidIndex]);
ycoords.push(this._bottomOrigin);
ycoords.push(this._bottomOrigin);
}
xcoords.push(xcoords[0]);
ycoords.push(ycoords[0]);
return [xcoords, ycoords];
},
/**
* Returns the order of the series closest to the current series that has a valid value for the current index.
*
* @method _getHighestValidOrder
* @param {Array} seriesCollection Array of series of a given type.
* @param {Number} index Index of the series item.
* @param {Number} order Index of the the series in the seriesCollection
* @param {String} direction Indicates the direction of the series
* @return Number
* @private
*/
_getHighestValidOrder: function(seriesCollection, index, order, direction)
{
var coords = direction === "vertical" ? "stackedXCoords" : "stackedYCoords",
coord;
while(isNaN(coord) && order > -1)
{
order = order - 1;
if(order > -1)
{
coord = seriesCollection[order].get(coords)[index];
}
}
return order;
},
/**
* Returns an array containing the x and y coordinates for a given series and index.
*
* @method _getCoordsByOrderAndIndex
* @param {Array} seriesCollection Array of series of a given type.
* @param {Number} index Index of the series item.
* @param {Number} order Index of the the series in the seriesCollection
* @param {String} direction Indicates the direction of the series
* @return Array
* @private
*/
_getCoordsByOrderAndIndex: function(seriesCollection, index, order, direction)
{
var xcoord,
ycoord;
if(direction === "vertical")
{
xcoord = order < 0 ? this._leftOrigin : seriesCollection[order].get("stackedXCoords")[index];
ycoord = this.get("stackedYCoords")[index];
}
else
{
xcoord = this.get("stackedXCoords")[index];
ycoord = order < 0 ? this._bottomOrigin : seriesCollection[order].get("stackedYCoords")[index];
}
return [xcoord, ycoord];
},
/**
* Concatenates coordinate array with the correct coordinates for closing an area stack.
*
* @method _getStackedClosingPoints
* @return Array
* @protected
*/
_getStackedClosingPoints: function()
{
var order = this.get("order"),
direction = this.get("direction"),
seriesCollection = this.get("seriesTypeCollection"),
firstValidIndex,
lastValidIndex,
xcoords = this.get("stackedXCoords"),
ycoords = this.get("stackedYCoords"),
limit,
previousSeries,
previousSeriesFirstValidIndex,
previousSeriesLastValidIndex,
previousXCoords,
previousYCoords,
coords,
closingXCoords,
closingYCoords,
currentIndex,
highestValidOrder,
oldOrder;
if(order < 1)
{
return this._getClosingPoints();
}
previousSeries = seriesCollection[order - 1];
previousXCoords = previousSeries.get("stackedXCoords").concat();
previousYCoords = previousSeries.get("stackedYCoords").concat();
if(direction === "vertical")
{
firstValidIndex = this._getFirstValidIndex(xcoords);
lastValidIndex = this._getLastValidIndex(xcoords);
previousSeriesFirstValidIndex = previousSeries._getFirstValidIndex(previousXCoords);
previousSeriesLastValidIndex = previousSeries._getLastValidIndex(previousXCoords);
}
else
{
firstValidIndex = this._getFirstValidIndex(ycoords);
lastValidIndex = this._getLastValidIndex(ycoords);
previousSeriesFirstValidIndex = previousSeries._getFirstValidIndex(previousYCoords);
previousSeriesLastValidIndex = previousSeries._getLastValidIndex(previousYCoords);
}
if(previousSeriesLastValidIndex >= firstValidIndex && previousSeriesFirstValidIndex <= lastValidIndex)
{
previousSeriesFirstValidIndex = Math.max(firstValidIndex, previousSeriesFirstValidIndex);
previousSeriesLastValidIndex = Math.min(lastValidIndex, previousSeriesLastValidIndex);
previousXCoords = previousXCoords.slice(previousSeriesFirstValidIndex, previousSeriesLastValidIndex + 1);
previousYCoords = previousYCoords.slice(previousSeriesFirstValidIndex, previousSeriesLastValidIndex + 1);
limit = previousSeriesFirstValidIndex;
}
else
{
limit = lastValidIndex;
}
closingXCoords = [xcoords[firstValidIndex]];
closingYCoords = [ycoords[firstValidIndex]];
currentIndex = firstValidIndex;
while((isNaN(highestValidOrder) || highestValidOrder < order - 1) && currentIndex <= limit)
{
oldOrder = highestValidOrder;
highestValidOrder = this._getHighestValidOrder(seriesCollection, currentIndex, order, direction);
if(!isNaN(oldOrder) && highestValidOrder > oldOrder)
{
coords = this._getCoordsByOrderAndIndex(seriesCollection, currentIndex, oldOrder, direction);
closingXCoords.push(coords[0]);
closingYCoords.push(coords[1]);
}
coords = this._getCoordsByOrderAndIndex(seriesCollection, currentIndex, highestValidOrder, direction);
closingXCoords.push(coords[0]);
closingYCoords.push(coords[1]);
currentIndex = currentIndex + 1;
}
if(previousXCoords &&
previousXCoords.length > 0 &&
previousSeriesLastValidIndex > firstValidIndex &&
previousSeriesFirstValidIndex < lastValidIndex)
{
closingXCoords = closingXCoords.concat(previousXCoords);
closingYCoords = closingYCoords.concat(previousYCoords);
highestValidOrder = order -1;
}
currentIndex = Math.max(firstValidIndex, previousSeriesLastValidIndex);
order = order - 1;
highestValidOrder = NaN;
while(currentIndex <= lastValidIndex)
{
oldOrder = highestValidOrder;
highestValidOrder = this._getHighestValidOrder(seriesCollection, currentIndex, order, direction);
if(!isNaN(oldOrder))
{
if(highestValidOrder > oldOrder)
{
coords = this._getCoordsByOrderAndIndex(seriesCollection, currentIndex, oldOrder, direction);
closingXCoords.push(coords[0]);
closingYCoords.push(coords[1]);
}
else if(highestValidOrder < oldOrder)
{
coords = this._getCoordsByOrderAndIndex(seriesCollection, currentIndex - 1, highestValidOrder, direction);
closingXCoords.push(coords[0]);
closingYCoords.push(coords[1]);
}
}
coords = this._getCoordsByOrderAndIndex(seriesCollection, currentIndex, highestValidOrder, direction);
closingXCoords.push(coords[0]);
closingYCoords.push(coords[1]);
currentIndex = currentIndex + 1;
}
closingXCoords.reverse();
closingYCoords.reverse();
return [xcoords.concat(closingXCoords), ycoords.concat(closingYCoords)];
},
/**
* Returns default values for area styles.
*
* @method _getAreaDefaults
* @return Object
* @private
*/
_getAreaDefaults: function()
{
return {
};
}
};
Y.augment(Fills, Y.Attribute);
Y.Fills = Fills;
}, '3.18.1');