From: Dan Vanderkam Date: Mon, 8 Aug 2011 18:14:17 +0000 (-0400) Subject: cleanup X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=b1a5569d9f6b56313e9f7f61a7c1aa341e92b643;p=dygraphs.git cleanup --- diff --git a/auto_tests/tests/axis_labels.js b/auto_tests/tests/axis_labels.js index bc8bf72..c8b3bab 100644 --- a/auto_tests/tests/axis_labels.js +++ b/auto_tests/tests/axis_labels.js @@ -52,7 +52,6 @@ AxisLabelsTestCase.prototype.testMinusOneToOne = function() { // TODO(danvk): would ['-1.0','-0.5','0.0','0.5','1.0'] be better? assertEquals(['-1','-0.5','0','0.5','1'], getYLabels()); - assertEquals("X,Y\n" + "0,-1\n" + "1,0\n" + "2,1\n" + "3,0\n", g.file_); // Go up to 2 data += "4,2\n"; diff --git a/auto_tests/tests/range_tests.js b/auto_tests/tests/range_tests.js index 7621c9d..32c511e 100644 --- a/auto_tests/tests/range_tests.js +++ b/auto_tests/tests/range_tests.js @@ -71,9 +71,7 @@ RangeTestCase.prototype.testRangeSetOperations = function() { assertEquals([12, 18], g.xAxisRange()); assertEquals([10, 40], g.yAxisRange(0)); - console.log(g.user_attrs_); g.updateOptions({ dateWindow : null, valueRange : null }); - console.log(g.user_attrs_); assertEquals([10, 20], g.xAxisRange()); assertEquals([0, 55], g.yAxisRange(0)); }; diff --git a/auto_tests/tests/simple_drawing.js b/auto_tests/tests/simple_drawing.js index be8efe8..ca19301 100644 --- a/auto_tests/tests/simple_drawing.js +++ b/auto_tests/tests/simple_drawing.js @@ -55,4 +55,4 @@ SimpleDrawingTestCase.prototype.testDrawSimpleRangePlusOne = function() { strokeStyle: "#008080", lineWidth: 1 }); -}; +} diff --git a/auto_tests/tests/tickers.js b/auto_tests/tests/tickers.js index 6ee9641..c3ae456 100644 --- a/auto_tests/tests/tickers.js +++ b/auto_tests/tests/tickers.js @@ -1,3 +1,11 @@ +/** + * @fileoverview Test cases for the tick-generating functions. + * These were generated by adding logging code to the old ticker functions. The + * tests serve to track existing behavior should it change in the future. + * + * @author danvdk@gmail.com (Dan Vanderkam) + */ + var TickerTestCase = TestCase("ticker-tests"); TickerTestCase.prototype.setUp = function() { diff --git a/auto_tests/tests/to_dom_coords.js b/auto_tests/tests/to_dom_coords.js index 8ce303e..c70b704 100644 --- a/auto_tests/tests/to_dom_coords.js +++ b/auto_tests/tests/to_dom_coords.js @@ -119,4 +119,4 @@ ToDomCoordsTestCase.prototype.testChartWithAxesAndLabels = function() { assertEquals([100, 0], g.toDataCoords(500, 425)); this.checkForInverses(g); -}; +} diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 477eac4..042c2ee 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -260,7 +260,7 @@ DygraphCanvasRenderer.prototype._renderAxis = function() { // height: this.attr_('axisLabelFontSize') + 2 + "px", overflow: "hidden" }; - var makeDiv = function(txt, axis, precise_axis) { + var makeDiv = function(txt, axis, prec_axis) { var div = document.createElement("div"); for (var name in labelStyle) { if (labelStyle.hasOwnProperty(name)) { @@ -268,10 +268,9 @@ DygraphCanvasRenderer.prototype._renderAxis = function() { } } var inner_div = document.createElement("div"); - // TODO(danvk): separate class for secondary y-axis inner_div.className = 'dygraph-axis-label' + ' dygraph-axis-label-' + axis + - (precise_axis ? ' dygraph-axis-label-' + precise_axis : ''); + (prec_axis ? ' dygraph-axis-label-' + prec_axis : ''); inner_div.appendChild(document.createTextNode(txt)); div.appendChild(inner_div); return div; diff --git a/dygraph-dev.js b/dygraph-dev.js index 16a6955..3f1e792 100644 --- a/dygraph-dev.js +++ b/dygraph-dev.js @@ -7,20 +7,20 @@ var src=document.getElementsByTagName('script'); var script = src[src.length-1].getAttribute("src"); - // This list needs to be kept in sync w/ the one in generate-combined.sh - // and the one in jsTestDriver.conf. - var source_files = [ - "strftime/strftime-min.js", - "rgbcolor/rgbcolor.js", - "dygraph-layout.js", - "dygraph-canvas.js", - "dygraph.js", - "dygraph-utils.js", - "dygraph-gviz.js", - "dygraph-interaction-model.js", - "dygraph-options-reference.js" // Shouldn't be included in generate-combined.sh - , "dygraph-tickers.js" - ]; + // This list needs to be kept in sync w/ the one in generate-combined.sh + // and the one in jsTestDriver.conf. + var source_files = [ + "strftime/strftime-min.js", + "rgbcolor/rgbcolor.js", + "dygraph-layout.js", + "dygraph-canvas.js", + "dygraph.js", + "dygraph-utils.js", + "dygraph-gviz.js", + "dygraph-interaction-model.js", + "dygraph-options-reference.js", // Shouldn't be included in generate-combined.sh + "dygraph-tickers.js" + ]; for (var i = 0; i < source_files.length; i++) { document.write('\n'); diff --git a/dygraph.js b/dygraph.js index 32348dd..99ac7c6 100644 --- a/dygraph.js +++ b/dygraph.js @@ -182,13 +182,12 @@ Dygraph.DEFAULT_ATTRS = { maxNumberWidth: 6, sigFigs: null, - xAxisLabelWidth: 50, - yAxisLabelWidth: 50, - strokeWidth: 1.0, axisTickSize: 3, axisLabelFontSize: 14, + xAxisLabelWidth: 50, + yAxisLabelWidth: 50, rightGap: 5, showRoller: false, @@ -363,6 +362,7 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { this.user_attrs_ = {}; Dygraph.update(this.user_attrs_, attrs); + // This sequence ensures that Dygraph.DEFAULT_ATTRS is never modified. this.attrs_ = {}; Dygraph.updateDeep(this.attrs_, Dygraph.DEFAULT_ATTRS); @@ -2729,7 +2729,9 @@ Dygraph.prototype.updateOptions = function(input_attrs, block_redraw) { }; /** - * Returns a copy of the options with deprecated names converted into current names. + * Returns a copy of the options with deprecated names converted into current + * names. Also drops the (potentially-large) 'file' attribute. If the caller is + * interested in that, they should save a copy before calling this. * @private */ Dygraph.mapLegacyOptions_ = function(attrs) { @@ -2751,6 +2753,7 @@ Dygraph.mapLegacyOptions_ = function(attrs) { } }; + // This maps, e.g., xValueFormater -> axes: { x: { valueFormatter: ... } } map('xValueFormatter', 'x', 'valueFormatter'); map('pixelsPerXLabel', 'x', 'pixelsPerLabel'); map('xAxisLabelFormatter', 'x', 'axisLabelFormatter');