From: Dan Vanderkam Date: Mon, 14 Oct 2013 01:49:48 +0000 (-0400) Subject: move parseFloat_ method around X-Git-Tag: v1.1.0~79^2~3 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=66c953562e2255253c3f11eaecad9eff41b11024;p=dygraphs.git move parseFloat_ method around --- diff --git a/datahandler/bars.js b/datahandler/bars.js index a6b0cc5..7100148 100644 --- a/datahandler/bars.js +++ b/datahandler/bars.js @@ -66,8 +66,8 @@ BarsHandler.prototype.onPointsCreated_ = function(series, points) { var point = points[i]; point.y_top = NaN; point.y_bottom = NaN; - point.yval_minus = Dygraph.parseFloat(item[2][0]); - point.yval_plus = Dygraph.parseFloat(item[2][1]); + point.yval_minus = Dygraph.DataHandler.parseFloat(item[2][0]); + point.yval_plus = Dygraph.DataHandler.parseFloat(item[2][1]); } }; diff --git a/datahandler/datahandler.js b/datahandler/datahandler.js index b9eb67c..0261794 100644 --- a/datahandler/datahandler.js +++ b/datahandler/datahandler.js @@ -123,11 +123,11 @@ handler.prototype.seriesToPoints = function(series, setName, boundaryIdStart) { for ( var i = 0; i < series.length; ++i) { var item = series[i]; var yraw = item[1]; - var yval = yraw === null ? null : Dygraph.parseFloat(yraw); + var yval = yraw === null ? null : handler.parseFloat(yraw); var point = { x : NaN, y : NaN, - xval : Dygraph.parseFloat(item[0]), + xval : handler.parseFloat(item[0]), yval : yval, name : setName, // TODO(danvk): is this really necessary? idx : i + boundaryIdStart @@ -250,4 +250,20 @@ handler.prototype.getIndexesInWindow_ = function(series, dateWindow) { } }; +/** + * Optimized replacement for parseFloat, which was way too slow when almost + * all values were type number, with few edge cases, none of which were strings. + * @param {?number} val + * @return {number} + */ +handler.parseFloat = function(val) { + // parseFloat(null) is NaN + if (val === null) { + return NaN; + } + + // Assume it's a number or NaN. If it's something else, I'll be shocked. + return val; +}; + })(); diff --git a/dygraph-layout.js b/dygraph-layout.js index e8be590..057e7c6 100644 --- a/dygraph-layout.js +++ b/dygraph-layout.js @@ -254,20 +254,6 @@ DygraphLayout.prototype._evaluateLineCharts = function() { } }; -/** - * Optimized replacement for parseFloat, which was way too slow when almost - * all values were type number, with few edge cases, none of which were strings. - */ -DygraphLayout.parseFloat_ = function(val) { - // parseFloat(null) is NaN - if (val === null) { - return NaN; - } - - // Assume it's a number or NaN. If it's something else, I'll be shocked. - return val; -}; - DygraphLayout.prototype._evaluateLineTicks = function() { var i, tick, label, pos; this.xticks = [];