X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-utils.js;h=689f8eb09d42de8a80e0326bc210f11cb33d252e;hb=e27878d929f79c34d7f4cf201aa3b3ccfb372a8e;hp=3827d9134085b05f00fd178af3256d4db4ddd596;hpb=d0e6d1763b71a98f957cd5a690132709e57ba17b;p=dygraphs.git diff --git a/dygraph-utils.js b/dygraph-utils.js index 3827d91..689f8eb 100644 --- a/dygraph-utils.js +++ b/dygraph-utils.js @@ -332,6 +332,21 @@ Dygraph.isOK = function(x) { }; /** + * @private + * @param { Object } p The point to consider, valid points are {x, y} objects + * @param { Boolean } allowNaNY Treat point with y=NaN as valid + * @return { Boolean } Whether the point has numeric x and y. + */ +Dygraph.isValidPoint = function(p, allowNaNY) { + if (!p) return false; // null or undefined object + if (p.yval === null) return false; // missing point + if (p.x === null || p.x === undefined) return false; + if (p.y === null || p.y === undefined) return false; + if (isNaN(p.x) || (!allowNaNY && isNaN(p.y))) return false; + return true; +}; + +/** * Number formatting function which mimicks the behavior of %g in printf, i.e. * either exponential or fixed format (without trailing 0s) is used depending on * the length of the generated string. The advantage of this format is that