var d = imageData.data;
return [d[i], d[i+1], d[i+2], d[i+3]];
};
+
+/**
+ * Format a date as 2000/01/23
+ * @param {number} date_ms Millis since epoch.
+ * @return {string} The date formatted as YYYY-MM-DD.
+ */
+Util.formatDate = function(date_ms) {
+ var zeropad = function(x) { if (x < 10) return "0" + x; else return "" + x; };
+ var d = new Date(date_ms);
+
+ // Get the year:
+ var year = "" + d.getFullYear();
+ // Get a 0 padded month string
+ var month = zeropad(d.getMonth() + 1); //months are 0-offset, sigh
+ // Get a 0 padded day string
+ var day = zeropad(d.getDate());
+
+ return year + "/" + month + "/" + day;
+};
assertEquals('number', typeof(granularity));
assertEquals('function', typeof(opts));
assertEquals('[Dygraph graph]', dg.toString());
- return 'x' + Dygraph.dateString_(x);
+ return 'x' + Util.formatDate(x);
},
yAxisLabelFormatter: function(y, granularity, opts, dg) {
assertEquals('number', typeof(y));
assertEquals('function', typeof(opts));
assertEquals('string', typeof(series_name));
assertEquals('[Dygraph graph]', dg.toString());
- return 'x' + Dygraph.dateString_(new Date(x));
+ return 'x' + Util.formatDate(x);
},
yValueFormatter: function(y, opts, series_name, dg) {
assertEquals('number', typeof(y));
assertEquals('number', typeof(granularity));
assertEquals('function', typeof(opts));
assertEquals('[Dygraph graph]', dg.toString());
- return 'x' + Dygraph.dateString_(x);
+ return 'x' + Util.formatDate(x);
}
},
y : {
assertEquals('function', typeof(opts));
assertEquals('string', typeof(series_name));
assertEquals('[Dygraph graph]', dg.toString());
- return 'x' + Dygraph.dateString_(new Date(x));
+ return 'x' + Util.formatDate(x);
}
},
y : {