From: Dan Vanderkam Date: Thu, 18 Jul 2013 20:01:50 +0000 (+0200) Subject: remove strftime-min.js X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=026bc5a444e7cef3e84c9ccbcda9c334dee3d5b7;p=dygraphs.git remove strftime-min.js --- diff --git a/auto_tests/tests/axis_labels-deprecated.js b/auto_tests/tests/axis_labels-deprecated.js index 972362a..d2d1412 100644 --- a/auto_tests/tests/axis_labels-deprecated.js +++ b/auto_tests/tests/axis_labels-deprecated.js @@ -85,7 +85,7 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedDateAxisLabelFormatter = fu assertEquals('number', typeof(granularity)); assertEquals('function', typeof(opts)); assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + x.strftime('%Y/%m/%d'); + return 'x' + Dygraph.dateString_(x); }, yAxisLabelFormatter: function(y, granularity, opts, dg) { assertEquals('number', typeof(y)); @@ -159,7 +159,7 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedDateValueFormatter = functi assertEquals('function', typeof(opts)); assertEquals('string', typeof(series_name)); assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + new Date(x).strftime('%Y/%m/%d'); + return 'x' + Dygraph.dateString_(new Date(x)); }, yValueFormatter: function(y, opts, series_name, dg) { assertEquals('number', typeof(y)); diff --git a/auto_tests/tests/axis_labels.js b/auto_tests/tests/axis_labels.js index c9f60f8..ae26439 100644 --- a/auto_tests/tests/axis_labels.js +++ b/auto_tests/tests/axis_labels.js @@ -206,7 +206,7 @@ AxisLabelsTestCase.prototype.testDateAxisLabelFormatter = function () { assertEquals('number', typeof(granularity)); assertEquals('function', typeof(opts)); assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + x.strftime('%Y/%m/%d'); + return 'x' + Dygraph.dateString_(x); } }, y : { @@ -292,7 +292,7 @@ AxisLabelsTestCase.prototype.testDateValueFormatter = function () { assertEquals('function', typeof(opts)); assertEquals('string', typeof(series_name)); assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + new Date(x).strftime('%Y/%m/%d'); + return 'x' + Dygraph.dateString_(new Date(x)); } }, y : { diff --git a/chopping-block.txt b/chopping-block.txt index 28a91fb..6eb738a 100644 --- a/chopping-block.txt +++ b/chopping-block.txt @@ -6,3 +6,25 @@ Things to do to make dygraph-combine.js smaller: - (2645) Simplify or eliminate dygraph-interaction-model.js. - (1983) Remove stacktrace.js from dygraph-combined.js - (????) Switch to Closure Compiler, which is more aggressive about dead code removal. +- (????) Unify Dygraph.prototype.log vs. Dygraph.log +- (????) Combined findPos{X,Y}, page{X,Y} +- (????) merge update, updateDeep, clone +- (????) can we kill the iterator stuff? +- (????) move kberg's polygon stuff into a plugin +- (????) unify/simplify date processing code (dateString_, hmsString_, ...) + +To measure size: +$ ./generate-combined.sh cat_minified | wc -c + +To test correctness: +$ make test-combined + + 135782 Initial + 130557 removed stacktrace.js + 130142 removed stacktrace logic from combined + 129932 remove unused Dygraph.compareArrays_ + 125996 remove strftime-min.js + + +TODO: +- remove all references to strftime-min.js diff --git a/dygraph.js b/dygraph.js index 6ff258e..eb998ef 100644 --- a/dygraph.js +++ b/dygraph.js @@ -211,6 +211,12 @@ Dygraph.dateString_ = function(date) { }; /** + * @type {!Array.} + * @private + */ +Dygraph.shortMonthNames_ = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + +/** * Convert a JS date to a string appropriate to display on an axis that * is displaying values at the stated granularity. * @param {Date} date The date to format @@ -220,13 +226,17 @@ Dygraph.dateString_ = function(date) { */ Dygraph.dateAxisFormatter = function(date, granularity) { if (granularity >= Dygraph.DECADAL) { - return date.strftime('%Y'); + // e.g. '2013' (%Y) + return '' + date.getFullYear(); } else if (granularity >= Dygraph.MONTHLY) { - return date.strftime('%b %y'); + // e.g. 'Jan 13' (%b %y) + return Dygraph.shortMonthNames_[date.getMonth()] + ' ' + date.getFullYear(); } else { var frac = date.getHours() * 3600 + date.getMinutes() * 60 + date.getSeconds() + date.getMilliseconds(); if (frac === 0 || granularity >= Dygraph.DAILY) { - return new Date(date.getTime() + 3600*1000).strftime('%d%b'); + // e.g. '21Jan' (%d%b) + var nd = new Date(date.getTime() + 3600*1000); + return Dygraph.zeropad(nd.getDate()) + Dygraph.shortMonthNames_[nd.getMonth()]; } else { return Dygraph.hmsString_(date.getTime()); } diff --git a/generate-combined.sh b/generate-combined.sh index 132e7a8..33c410e 100755 --- a/generate-combined.sh +++ b/generate-combined.sh @@ -5,7 +5,6 @@ GetSources () { # This list needs to be kept in sync w/ the one in dygraph-dev.js # and the one in jsTestDriver.conf. Order matters, except for the plugins. for F in \ - strftime/strftime-min.js \ rgbcolor/rgbcolor.js \ dashed-canvas.js \ dygraph-options.js \