Missing semicolon
[dygraphs.git] / datahandler / datahandler.js
index b9eb67c..2b637b5 100644 (file)
@@ -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
@@ -161,7 +161,6 @@ handler.prototype.onPointsCreated_ = function(series, points) {
  *          data format where series[i] = [x,y,{extras}].
  * @param {!number} rollPeriod The number of points over which to average the data
  * @param {!DygraphOptions} options The dygraph options.
- * TODO(danvk): be more specific than "Array" here.
  * @return {!Array.<[!number,?number,?]>} the rolled series.
  */
 handler.prototype.rollingAverage = function(series, rollPeriod, options) {
@@ -250,4 +249,21 @@ 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}
+ * @protected
+ */
+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;
+};
+
 })();