Skip to content

Commit 5235ffd

Browse files
committed
Update number checks to include isFinite
1 parent 21a41ea commit 5235ffd

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/gallery-charts-stockindicators/js/CanvasAxis.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ Y.CanvasAxis = Y.Base.create("canvasAxis", Y.AxisBase, [Y.Renderer], Y.merge(Y.A
8181
explicitLabels = this._labelValuesExplicitlySet ? this.get("labelValues") : null,
8282
direction = (position === "left" || position === "right") ? "vertical" : "horizontal";
8383
if(margin) {
84-
marginLeft = typeof margin.left === "number" ? margin.left : 0;
85-
marginRight = typeof margin.right === "number" ? margin.right : 0;
86-
marginTop = typeof margin.top === "number" ? margin.top : 0;
87-
marginBottom = typeof margin.bottom === "number" ? margin.bottom : 0;
84+
marginLeft = typeof margin.left === "number" && isFinite(margin.left) ? margin.left : 0;
85+
marginRight = typeof margin.right === "number" && isFinite(margin.right) ? margin.right : 0;
86+
marginTop = typeof margin.top === "number" && isFinite(margin.top) ? margin.top : 0;
87+
marginBottom = typeof margin.bottom === "number" && isFinite(margin.bottom) ? margin.bottom : 0;
8888
}
8989
//need to defaultMargins method to the layout classes.
9090
for(i in defaultMargins)

src/gallery-charts-stockindicators/js/Crosshair.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Y.Crosshair.prototype = {
107107
for(i = 0; i < len; i = i + 1) {
108108
graph = series[i];
109109
y = graph.coords[index];
110-
isNumber = typeof y === "number";
110+
isNumber = typeof y === "number" && isFinite(y);
111111

112112
if(graph.marker) {
113113
if(isNumber) {

src/gallery-charts-stockindicators/js/MultipleLineSeries.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Y.MultipleLineSeries = Y.Base.create("multipleLineSeries", Y.CartesianSeries, [Y
6969
{
7070
nextX = Math.round(xcoords[i] * 1000)/1000;
7171
nextY = Math.round(ycoords[i] * 1000)/1000;
72-
pointValid = typeof nextX === "number" && typeof nextY === "number";
72+
pointValid = typeof nextX === "number" && isFinite(nextX) && typeof nextY === "number" && isFinite(nextY);
7373
if(pointValid) {
7474
thresholdIndex = 0;
7575
if(thresholds) {
@@ -91,7 +91,7 @@ Y.MultipleLineSeries = Y.Base.create("multipleLineSeries", Y.CartesianSeries, [Y
9191
m = Math.round(((nextY - lastValidY) / (nextX - lastValidX)) * 1000)/1000;
9292
intersectX = ((thresholdCoords[thresholdIndex] - nextY)/m) + nextX;
9393
intersectY = thresholdCoords[thresholdIndex];
94-
if(typeof lastPathIndex === "number") {
94+
if(typeof lastPathIndex === "number" && isFinite(lastPathIndex)) {
9595
this._lineTo(graphPaths[lastPathIndex], intersectX, intersectY);
9696
}
9797
this._moveTo(graphPaths[pathIndex], intersectX, intersectY);

src/gallery-charts-stockindicators/js/StockIndicatorsChart.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ Y.StockIndicatorsChart = Y.Base.create("stockIndicatorsChart", Y.Widget, [Y.Ren
10651065
config.legend.width = graphConfig.width;
10661066
}
10671067
legend = this._addLegend(config, cb);
1068-
if(thresholdStyles && typeof previousClose === "number") {
1068+
if(thresholdStyles && typeof previousClose === "number" && isFinite(previousClose)) {
10691069
thresholdConfig = {
10701070
type: "thresholdline",
10711071
thresholds: [previousClose],

0 commit comments

Comments
 (0)