From: Dan Vanderkam Date: Mon, 30 Mar 2015 18:50:03 +0000 (-0400) Subject: Fix most warnings X-Git-Tag: v2.0.0~63^2~2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=65129ba82d4efe12714be88fa3c792149c00ca10;p=dygraphs.git Fix most warnings --- diff --git a/auto_tests/tests/axis_labels.js b/auto_tests/tests/axis_labels.js index a819214..abff8b2 100644 --- a/auto_tests/tests/axis_labels.js +++ b/auto_tests/tests/axis_labels.js @@ -125,7 +125,8 @@ it('testSmallRangeAwayFromZero', function() { it('testXAxisTimeLabelFormatter', function() { var opts = { width: 480, - height: 320 + height: 320, + labels: ['X', 'Y1'] }; var data = [[5.0,0],[5.1,1],[5.2,2],[5.3,3],[5.4,4],[5.5,5],[5.6,6],[5.7,7],[5.8,8],[5.9,9]]; var graph = document.getElementById("graph"); @@ -672,7 +673,11 @@ it('testSmallLabelKMG2', function() { * Verify that log scale axis range is properly specified. */ it('testLogScale', function() { - var g = new Dygraph("graph", [[0, 5], [1, 1000]], { logscale : true }); + var g = new Dygraph("graph", + [[0, 5], [1, 1000]], { + logscale: true, + labels: ['X', 'Y'] + }); var nonEmptyLabels = Util.getYLabels().filter(function(x) { return x.length > 0; }); assert.deepEqual(["5","10","20","50","100","200","500","1000"], nonEmptyLabels); @@ -684,7 +689,11 @@ it('testLogScale', function() { * Verify that include zero range is properly specified. */ it('testIncludeZero', function() { - var g = new Dygraph("graph", [[0, 500], [1, 1000]], { includeZero : true }); + var g = new Dygraph("graph", + [[0, 500], [1, 1000]], { + includeZero: true, + labels: ['X', 'Y1'] + }); assert.deepEqual(['0','200','400','600','800','1000'], Util.getYLabels()); g.updateOptions({ includeZero : false }); @@ -701,18 +710,18 @@ it('testAxisLabelFontSize', function() { var assertFontSize = function(selector, expected) { Util.assertStyleOfChildren(selector, "font-size", expected); } - + assertFontSize(document.querySelectorAll(".dygraph-axis-label-x"), "14px"); - assertFontSize(document.querySelectorAll(".dygraph-axis-label-y") , "14px"); + assertFontSize(document.querySelectorAll(".dygraph-axis-label-y"), "14px"); - g.updateOptions({ axisLabelFontSize : 8}); + g.updateOptions({axisLabelFontSize : 8}); assertFontSize(document.querySelectorAll(".dygraph-axis-label-x"), "8px"); assertFontSize(document.querySelectorAll(".dygraph-axis-label-y"), "8px"); g.updateOptions({ axisLabelFontSize : null, - axes : { - x : { axisLabelFontSize : 5 }, + axes: { + x: { axisLabelFontSize : 5 }, } }); @@ -720,8 +729,8 @@ it('testAxisLabelFontSize', function() { assertFontSize(document.querySelectorAll(".dygraph-axis-label-y"), "14px"); g.updateOptions({ - axes : { - y : { axisLabelFontSize : 20 }, + axes: { + y: { axisLabelFontSize : 20 }, } }); @@ -729,11 +738,11 @@ it('testAxisLabelFontSize', function() { assertFontSize(document.querySelectorAll(".dygraph-axis-label-y"), "20px"); g.updateOptions({ - series : { - Y2 : { axis : "y2" } // copy y2 series to y2 axis. + series: { + Y2: { axis : "y2" } // copy y2 series to y2 axis. }, - axes : { - y2 : { axisLabelFontSize : 12 }, + axes: { + y2: { axisLabelFontSize : 12 }, } }); diff --git a/auto_tests/tests/callback.js b/auto_tests/tests/callback.js index b10cf16..d41d91e 100644 --- a/auto_tests/tests/callback.js +++ b/auto_tests/tests/callback.js @@ -696,9 +696,9 @@ it('testDrawHighlightPointCallback_idx', function() { }; var testdata = [[1, 2], [2, 3], [3, NaN], [4, 2], [5, NaN], [6, 3]]; var graph = document.getElementById("graph"); - var g = new Dygraph(graph, testdata, - { - drawHighlightPointCallback : drawHighlightPointCallback + var g = new Dygraph(graph, testdata, { + drawHighlightPointCallback: drawHighlightPointCallback, + labels: ['X', 'Y'] }); assert.isNull(idxToCheck); diff --git a/auto_tests/tests/custom_bars.js b/auto_tests/tests/custom_bars.js index 523d93a..cbffe7e 100644 --- a/auto_tests/tests/custom_bars.js +++ b/auto_tests/tests/custom_bars.js @@ -99,19 +99,20 @@ it('testCustomBarsAtTop', function() { width: 500, height: 350, customBars: true, errorBars: true, - axes : { - x : { + axes: { + x: { drawGrid: false, drawAxis: false, }, - y : { + y: { drawGrid: false, drawAxis: false, } }, valueRange: [0, 120], fillAlpha: 0.15, - colors: [ '#00FF00' ] + colors: ['#00FF00'], + labels: ['X', 'Y'] }); var sampler = new PixelSampler(g); @@ -142,7 +143,8 @@ it('testCustomBarsLogScale', function() { }, fillAlpha: 1.0, logscale: true, - colors: [ '#00FF00' ] + colors: ['#00FF00'], + labels: ['X', 'Y'] }); // The following assertions describe the sides of the custom bars, which are @@ -180,8 +182,9 @@ it('testCustomBarsWithNegativeValuesInLogScale', function() { ], { drawPoints: true, - drawPointCallback : drawPointCallback, - customBars: true + drawPointCallback: drawPointCallback, + customBars: true, + labels: ['X', 'Y'] }); // Normally all three points would be drawn. diff --git a/auto_tests/tests/error_bars.js b/auto_tests/tests/error_bars.js index bb6c1d9..2fd5ae4 100644 --- a/auto_tests/tests/error_bars.js +++ b/auto_tests/tests/error_bars.js @@ -36,7 +36,8 @@ it('testErrorBarsDrawn', function() { } }, customBars: true, - errorBars: true + errorBars: true, + labels: ['X', 'Y'] }; var data = [ [1, [10, 10, 100]], diff --git a/auto_tests/tests/formats.js b/auto_tests/tests/formats.js index 36b36c9..9ff3dab 100644 --- a/auto_tests/tests/formats.js +++ b/auto_tests/tests/formats.js @@ -24,6 +24,7 @@ var dataArray = [1,0], [2,1], [3,0]]; +var BASE_OPTS = {labels: ['X', 'Y']}; it('testCsv', function() { var data = dataString; @@ -35,7 +36,7 @@ it('testCsv', function() { it('testArray', function() { var data = dataArray; var graph = document.getElementById("graph"); - var g = new Dygraph(graph, data, {}); + var g = new Dygraph(graph, data, BASE_OPTS); assertData(g); }); @@ -54,7 +55,7 @@ it('testFunctionDefinesArray', function() { var data = function() { return array; } var graph = document.getElementById("graph"); - var g = new Dygraph(graph, data, {}); + var g = new Dygraph(graph, data, BASE_OPTS); assertData(g); }); diff --git a/auto_tests/tests/interaction_model.js b/auto_tests/tests/interaction_model.js index 41d0e43..834613c 100644 --- a/auto_tests/tests/interaction_model.js +++ b/auto_tests/tests/interaction_model.js @@ -19,15 +19,16 @@ var data1 = "X,Y\n" + "23,0\n"; var data2 = - [[1, 10], - [2, 20], - [3, 30], - [4, 40], - [5, 120], - [6, 50], - [7, 70], - [8, 90], - [9, 50]]; + "X,Y\n" + + "1,10\n" + + "2,20\n" + + "3,30\n" + + "4,40\n" + + "5,120\n" + + "6,50\n" + + "7,70\n" + + "8,90\n" + + "9,50\n"; function getXLabels() { var x_labels = document.getElementsByClassName("dygraph-axis-label-x"); @@ -169,15 +170,16 @@ it('testClickCallbackIsCalledWithNonInteractiveModel', function() { * A sanity test to ensure pointClickCallback is called. */ it('testPointClickCallback', function() { - var clicked; - var g = new Dygraph(document.getElementById("graph"), data2, { - pointClickCallback : function(event, point) { + var clicked = null; + var g = new Dygraph('graph', data2, { + pointClickCallback: function(event, point) { clicked = point; } }); clickAt(g, 4, 40); + assert.isNotNull(clicked); assert.equal(4, clicked.xval); assert.equal(40, clicked.yval); }); diff --git a/auto_tests/tests/missing_points.js b/auto_tests/tests/missing_points.js index cc1ae00..84b875f 100644 --- a/auto_tests/tests/missing_points.js +++ b/auto_tests/tests/missing_points.js @@ -61,7 +61,7 @@ it('testSeparatedPointsDontDraw_expanded', function() { [2, null], [3, 13], [4, 14]], - { colors: ['blue']}); + { colors: ['blue'], labels: ['X', 'Y']}); var htx = g.hidden_ctx_; assert.equal(2, CanvasAssertions.numLinesDrawn(htx, '#0000ff')); @@ -80,7 +80,11 @@ it('testSeparatedPointsDontDraw_expanded_connected', function() { [2, null], [3, 13], [4, 14]], - { colors: ['blue'], connectSeparatedPoints: true}); + { + colors: ['blue'], + connectSeparatedPoints: true, + labels: ['X', 'Y'] + }); var htx = g.hidden_ctx_; var num_lines = 0; @@ -107,7 +111,8 @@ it('testConnectSeparatedPoints', function() { { connectSeparatedPoints: true, drawPoints: true, - colors: ['red', 'blue'] + colors: ['red', 'blue'], + labels: ['X', 'Y1', 'Y2'] } ); @@ -182,7 +187,8 @@ it('testErrorBarsWithMissingPoints', function() { data, { errorBars: true, - colors: ['red'] + colors: ['red'], + labels: ['X', 'Y'] } ); @@ -216,7 +222,8 @@ it('testErrorBarsWithMissingPointsConnected', function() { connectSeparatedPoints: true, drawPoints: true, errorBars: true, - colors: ['red'] + colors: ['red'], + labels: ['X', 'Y'] } ); @@ -251,7 +258,8 @@ it('testCustomBarsWithMissingPoints', function() { data, { customBars: true, - colors: ['red'] + colors: ['red'], + labels: ['X', 'Y'] } ); @@ -292,7 +300,8 @@ it('testCustomBarsWithMissingPointsConnected', function() { connectSeparatedPoints: true, drawPoints: true, customBars: true, - colors: ['red'] + colors: ['red'], + labels: ['X', 'Y'] } ); @@ -323,7 +332,8 @@ it('testLeftBoundaryWithMisingPoints', function() { { connectSeparatedPoints: true, drawPoints: true, - colors: ['red','blue'] + colors: ['red','blue'], + labels: ['X', 'Y1', 'Y2'] } ); g.updateOptions({ dateWindow : [ 2.5, 4.5 ] }); diff --git a/auto_tests/tests/range_tests.js b/auto_tests/tests/range_tests.js index 6cef4f9..1391a2a 100644 --- a/auto_tests/tests/range_tests.js +++ b/auto_tests/tests/range_tests.js @@ -50,8 +50,9 @@ var createGraph = function(opts, data, expectRangeX, expectRangeY) { if (data === undefined) data = ZERO_TO_FIFTY_STEPS; if (expectRangeX === undefined) expectRangeX = [10, 20]; if (expectRangeY === undefined) expectRangeY = [0, 55]; - var graph = document.getElementById("graph"); - var g = new Dygraph(graph, data, opts); + if (!opts) opts = {}; + opts['labels'] = ['X', 'Y']; + var g = new Dygraph('graph', data, opts); assertDeepCloseTo(expectRangeX, g.xAxisRange(), 0.01); assertDeepCloseTo(expectRangeY, g.yAxisRange(0), 0.01); @@ -172,7 +173,10 @@ it('testRestoreOriginalRanges_viaUpdateOptions', function() { * Verify that log scale axis range is properly specified. */ it('testLogScaleExcludesZero', function() { - var g = new Dygraph("graph", FIVE_TO_ONE_THOUSAND, { logscale : true }); + var g = new Dygraph("graph", FIVE_TO_ONE_THOUSAND, { + logscale: true, + labels: ['X', 'Y'] + }); assert.deepEqual([10, 1099], g.yAxisRange(0)); g.updateOptions({ logscale : false }); @@ -183,7 +187,10 @@ it('testLogScaleExcludesZero', function() { * Verify that includeZero range is properly specified. */ it('testIncludeZeroIncludesZero', function() { - var g = new Dygraph("graph", [[0, 500], [500, 1000]], { includeZero : true }); + var g = new Dygraph("graph", [[0, 500], [500, 1000]], { + includeZero: true, + labels: ['X', 'Y'] + }); assert.deepEqual([0, 1100], g.yAxisRange(0)); g.updateOptions({ includeZero : false }); @@ -233,7 +240,10 @@ it('testIncludeZeroPerAxis', function() { * Verify that very large Y ranges don't break things. */ it('testHugeRange', function() { - var g = new Dygraph("graph", [[0, -1e120], [1, 1e230]], { includeZero : true }); + var g = new Dygraph("graph", [[0, -1e120], [1, 1e230]], { + includeZero: true, + labels: ['X', 'Y'] + }); assert.closeTo(1, -1e229 / g.yAxisRange(0)[0], 0.001); assert.closeTo(1, 1.1e230 / g.yAxisRange(0)[1], 0.001); }); diff --git a/auto_tests/tests/sanity.js b/auto_tests/tests/sanity.js index 9eeb7f3..6a2ee5f 100644 --- a/auto_tests/tests/sanity.js +++ b/auto_tests/tests/sanity.js @@ -24,8 +24,8 @@ * * @author konigsberg@google.com (Robert Konigsberg) */ -var DEAD_SIMPLE_DATA = [[ 10, 2100 ]]; -var ZERO_TO_FIFTY = [[ 10, 0 ] , [ 20, 50 ]]; +var DEAD_SIMPLE_DATA = 'X,Y\n10,2100'; +var ZERO_TO_FIFTY = 'X,Y\n10,0\n20,50'; describe("dygraphs-sanity", function() {