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
* 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) {
}
};
+/**
+ * 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;
+};
+
})();