From 2b66af4f76dcd72d22f5844cb7684f3cb79fde42 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sat, 24 Oct 2015 22:17:58 -0400 Subject: [PATCH] Fix errors/warnings in tests/*.html --- scripts/casperscript.js | 28 ++++++++++++++++++++++++++++ src/dygraph-tickers.js | 13 ------------- src/dygraph.js | 7 +++++++ src/extras/smooth-plotter.js | 5 ++++- tests/customLabel.html | 6 +++++- tests/customLabelCss3.html | 6 +++++- tests/dashed-canvas.html | 3 --- tests/exported-symbols.html | 3 --- tests/iframe.html | 2 +- tests/interaction.html | 6 ++++-- tests/interaction.js | 6 ++++-- tests/labelsKMB.html | 6 +++++- tests/logscale.html | 2 +- tests/multi-scale.html | 6 +++++- tests/plugins.html | 2 +- tests/range-selector.html | 1 + tests/smooth-plots.html | 2 +- tests/spacing.html | 12 ++++++++++-- tests/two-axes-vr.html | 12 ++++++++---- tests/two-axes.html | 4 +++- tests/value-axis-formatters.html | 6 +++--- tests/x-axis-formatter.html | 11 +++++++---- 22 files changed, 103 insertions(+), 46 deletions(-) create mode 100644 scripts/casperscript.js diff --git a/scripts/casperscript.js b/scripts/casperscript.js new file mode 100644 index 0000000..a7ad3d1 --- /dev/null +++ b/scripts/casperscript.js @@ -0,0 +1,28 @@ +// This script can be used to check for errors/console warnings in _all_ the +// files in tests/*.html. +// +// Suggested usage: +// +// npm install casperjs +// for x in tests/*.html; casperjs scripts/casperscript.js $x + +var casper = require('casper').create({ + verbose: true +}); +var filename = casper.cli.args[0]; + +casper.echo(filename); +casper.on('remote.message', function(message) { + this.echo('page console: ' + message); +}); + +casper.on('resource.error', function(e) { + this.echo('resource.error: ' + e); +}); +casper.on('page.error', function(e) { + this.echo('error! ' + e); +}); + +casper.start(filename, function() { }); + +casper.run(); diff --git a/src/dygraph-tickers.js b/src/dygraph-tickers.js index 31ae852..f152bf9 100644 --- a/src/dygraph-tickers.js +++ b/src/dygraph-tickers.js @@ -443,16 +443,3 @@ export var getDateAxis = function(start_time, end_time, granularity, opts, dg) { } return ticks; }; - -// These are set here so that this file can be included after dygraph.js -// or independently. -// if (Dygraph && -// Dygraph.DEFAULT_ATTRS && -// Dygraph.DEFAULT_ATTRS['axes'] && -// Dygraph.DEFAULT_ATTRS['axes']['x'] && -// Dygraph.DEFAULT_ATTRS['axes']['y'] && -// Dygraph.DEFAULT_ATTRS['axes']['y2']) { -// Dygraph.DEFAULT_ATTRS['axes']['x']['ticker'] = Dygraph.dateTicker; -// Dygraph.DEFAULT_ATTRS['axes']['y']['ticker'] = Dygraph.numericTicks; -// Dygraph.DEFAULT_ATTRS['axes']['y2']['ticker'] = Dygraph.numericTicks; -// } diff --git a/src/dygraph.js b/src/dygraph.js index cb8639f..634520c 100644 --- a/src/dygraph.js +++ b/src/dygraph.js @@ -3582,4 +3582,11 @@ Dygraph.moveZoom = DygraphInteraction.moveZoom; Dygraph.endPan = DygraphInteraction.endPan; Dygraph.endZoom = DygraphInteraction.endZoom; +Dygraph.numericLinearTicks = DygraphTickers.numericLinearTicks; +Dygraph.numericTicks = DygraphTickers.numericTicks; +Dygraph.dateTicker = DygraphTickers.dateTicker; +Dygraph.Granularity = DygraphTickers.Granularity; +Dygraph.getDateAxis = DygraphTickers.getDateAxis; +Dygraph.floatFormat = utils.floatFormat; + export default Dygraph; diff --git a/src/extras/smooth-plotter.js b/src/extras/smooth-plotter.js index d0182f4..69685ec 100644 --- a/src/extras/smooth-plotter.js +++ b/src/extras/smooth-plotter.js @@ -75,6 +75,10 @@ function getControlPoints(p0, p1, p2, opt_alpha, opt_allowFalseExtrema) { return [l1x, l1y, r1x, r1y]; } +// i.e. is none of (null, undefined, NaN) +function isOK(x) { + return !!x && !isNaN(x); +}; // A plotter which uses splines to create a smooth curve. // See tests/plotters.html for a demo. @@ -88,7 +92,6 @@ function smoothPlotter(e) { // right control point for previous point var lastRightX = points[0].canvasx, lastRightY = points[0].canvasy; - var isOK = Dygraph.isOK; // i.e. is none of (null, undefined, NaN) for (var i = 1; i < points.length; i++) { var p0 = points[i - 1], diff --git a/tests/customLabel.html b/tests/customLabel.html index 1402325..c4ebee7 100644 --- a/tests/customLabel.html +++ b/tests/customLabel.html @@ -46,7 +46,11 @@ rollPeriod: 14, errorBars: true, labelsSeparateLines: true, - yAxisLabelWidth: 20 + axes: { + y: { + axisLabelWidth: 20 + } + } } ); diff --git a/tests/customLabelCss3.html b/tests/customLabelCss3.html index 462a4d6..2b1b55a 100644 --- a/tests/customLabelCss3.html +++ b/tests/customLabelCss3.html @@ -29,7 +29,11 @@ 'boxShadow': '4px 4px 4px #888' }, labelsSeparateLines: true, - yAxisLabelWidth: 20 + axes: { + y: { + axisLabelWidth: 20 + } + } } ); diff --git a/tests/dashed-canvas.html b/tests/dashed-canvas.html index e12d998..c80b3fc 100644 --- a/tests/dashed-canvas.html +++ b/tests/dashed-canvas.html @@ -1,7 +1,4 @@ - - -

You should see solid black and blue lines with a dashed red line in between them:

diff --git a/tests/exported-symbols.html b/tests/exported-symbols.html index 4a80f67..0800823 100644 --- a/tests/exported-symbols.html +++ b/tests/exported-symbols.html @@ -20,10 +20,7 @@ windowProps[k] = true; } - - diff --git a/tests/plugins.html b/tests/plugins.html index c92cda7..92cd104 100644 --- a/tests/plugins.html +++ b/tests/plugins.html @@ -5,7 +5,7 @@ - +

Plugins Demo

diff --git a/tests/range-selector.html b/tests/range-selector.html index 4b13fc3..b257fe4 100644 --- a/tests/range-selector.html +++ b/tests/range-selector.html @@ -118,6 +118,7 @@ drawAxis : false } }, + labels: ['X', 'Y'], showRangeSelector: true, rangeSelectorHeight: 30 } diff --git a/tests/smooth-plots.html b/tests/smooth-plots.html index dbd9e4e..55ebb1c 100644 --- a/tests/smooth-plots.html +++ b/tests/smooth-plots.html @@ -3,7 +3,7 @@ Plotters demo - +