From: Dan Vanderkam Date: Sat, 24 Oct 2015 17:41:00 +0000 (-0400) Subject: fix some tests & gallery entries X-Git-Tag: v2.0.0~38^2~4 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=178b1e0a5023bd55b8636242623e7eb82ac12d5d;p=dygraphs.git fix some tests & gallery entries --- diff --git a/gallery/drawing.js b/gallery/drawing.js index c664650..d4da18d 100644 --- a/gallery/drawing.js +++ b/gallery/drawing.js @@ -174,13 +174,19 @@ Gallery.register( g.updateOptions({ dateWindow: dateWindow }); - Dygraph.cancelEvent(event); + event.preventDefault(); } }, strokeWidth: 1.5, gridLineColor: 'rgb(196, 196, 196)', - drawYGrid: false, - drawYAxis: false + axes: { + x: { + drawAxis: false + }, + y: { + drawGrid: false + } + } }); window.onmouseup = finishDraw; } diff --git a/gallery/edge-padding.js b/gallery/edge-padding.js index b60e37c..be79054 100644 --- a/gallery/edge-padding.js +++ b/gallery/edge-padding.js @@ -39,7 +39,7 @@ Gallery.register( var g = new Dygraph(gdiv, data, { labels: ['x', 'A', 'B'], - labelDivWidth: 100, + labelsDivWidth: 100, gridLineColor: '#ccc', includeZero: true, width: 250, diff --git a/gallery/independent-series.js b/gallery/independent-series.js index 59da519..1a1e902 100644 --- a/gallery/independent-series.js +++ b/gallery/independent-series.js @@ -155,7 +155,6 @@ Gallery.register( '8,8, \n' + '10,10, \n', { - labels: ['x', 'A', 'B' ], connectSeparatedPoints: true, drawPoints: true } diff --git a/gallery/index.html b/gallery/index.html index ddfe5ba..c953deb 100644 --- a/gallery/index.html +++ b/gallery/index.html @@ -4,7 +4,7 @@ Dygraphs Gallery - + diff --git a/gallery/interaction-api.js b/gallery/interaction-api.js index ebdfce9..8f6d706 100644 --- a/gallery/interaction-api.js +++ b/gallery/interaction-api.js @@ -84,7 +84,7 @@ var lastClickedGraph = null; function clickV3(event, g, context) { lastClickedGraph = g; - Dygraph.cancelEvent(event); + event.preventDefault();; } function scrollV3(event, g, context) { @@ -106,7 +106,7 @@ function scrollV3(event, g, context) { var yPct = percentages[1]; zoom(g, percentage, xPct, yPct); - Dygraph.cancelEvent(event); + event.preventDefault(); } // Adjusts [x, y] toward each other by zoomInPercentage% diff --git a/gallery/interaction.js b/gallery/interaction.js index 5936189..a903737 100644 --- a/gallery/interaction.js +++ b/gallery/interaction.js @@ -50,9 +50,8 @@ Gallery.register( }, run: function() { var lastClickedGraph; - // TODO(konigsberg): Add cleanup to remove callbacks. - Dygraph.addEvent(document, "mousewheel", function() { lastClickedGraph = null; }); - Dygraph.addEvent(document, "click", function() { lastClickedGraph = null; }); + document.addEventListener("mousewheel", function() { lastClickedGraph = null; }); + document.addEventListener("click", function() { lastClickedGraph = null; }); new Dygraph(document.getElementById("div_g"), NoisyData, { errorBars : true }); new Dygraph(document.getElementById("div_g2"), @@ -85,5 +84,9 @@ Gallery.register( }, underlayCallback : captureCanvas }); + }, + clean: function() { + document.removeEventListener('mousewheel'); + document.removeEventListener('click'); } }); diff --git a/gallery/per-series.js b/gallery/per-series.js index 956cfc3..425043c 100644 --- a/gallery/per-series.js +++ b/gallery/per-series.js @@ -25,20 +25,22 @@ Gallery.register( }, { strokeWidth: 2, - 'parabola': { - strokeWidth: 0.0, - drawPoints: true, - pointSize: 4, - highlightCircleSize: 6 - }, - 'line': { - strokeWidth: 1.0, - drawPoints: true, - pointSize: 1.5 - }, - 'sine wave': { - strokeWidth: 3, - highlightCircleSize: 10 + series: { + 'parabola': { + strokeWidth: 0.0, + drawPoints: true, + pointSize: 4, + highlightCircleSize: 6 + }, + 'line': { + strokeWidth: 1.0, + drawPoints: true, + pointSize: 1.5 + }, + 'sine wave': { + strokeWidth: 3, + highlightCircleSize: 10 + } } } ); diff --git a/scripts/build-tests.sh b/scripts/build-tests.sh index 0fc2e9b..216296d 100755 --- a/scripts/build-tests.sh +++ b/scripts/build-tests.sh @@ -9,6 +9,4 @@ browserify \ -t [ envify --NODE_ENV development ] \ --debug \ -o dist/tests.js \ - auto_tests/tests/utils_test.js - -# auto_tests/tests/*.js + auto_tests/tests/*.js diff --git a/scripts/watch.sh b/scripts/watch.sh old mode 100644 new mode 100755 diff --git a/src/dygraph.js b/src/dygraph.js index 1060aab..cb8639f 100644 --- a/src/dygraph.js +++ b/src/dygraph.js @@ -3551,6 +3551,35 @@ Dygraph.PLUGINS = [ GridPlugin ]; +// There are many symbols which have historically been available through the +// Dygraph class. These are exported here for backwards compatibility. Dygraph.GVizChart = GVizChart; +Dygraph.DASHED_LINE = utils.DASHED_LINE; +Dygraph.DOT_DASH_LINE = utils.DOT_DASH_LINE; +Dygraph.dateAxisLabelFormatter = utils.dateAxisLabelFormatter; +Dygraph.toRGB_ = utils.toRGB_; +Dygraph.findPos = utils.findPos; +Dygraph.pageX = utils.pageX; +Dygraph.pageY = utils.pageY; +Dygraph.dateString_ = utils.dateString_; +Dygraph.defaultInteractionModel = DygraphInteraction.defaultModel; +Dygraph.nonInteractiveModel = Dygraph.nonInteractiveModel_ = DygraphInteraction.nonInteractiveModel_; +Dygraph.Circles = utils.Circles; + +Dygraph.Plugins = { + Legend: LegendPlugin, + Axes: AxesPlugin, + // ... +}; +Dygraph.DataHandlers = { + DefaultHandler +}; + +Dygraph.startPan = DygraphInteraction.startPan; +Dygraph.startZoom = DygraphInteraction.startZoom; +Dygraph.movePan = DygraphInteraction.movePan; +Dygraph.moveZoom = DygraphInteraction.moveZoom; +Dygraph.endPan = DygraphInteraction.endPan; +Dygraph.endZoom = DygraphInteraction.endZoom; export default Dygraph; diff --git a/src/extras/rebase.js b/src/extras/rebase.js index 1c518a8..2e93116 100644 --- a/src/extras/rebase.js +++ b/src/extras/rebase.js @@ -19,8 +19,15 @@ /*global Dygraph:false */ (function() { + "use strict"; + // Matches DefaultHandler.parseFloat + var parseFloat = function(val) { + if (val === null) return NaN; + return val; + }; + Dygraph.DataHandlers.RebaseHandler = function(baseOpt) { this.baseOpt = baseOpt; }; @@ -66,7 +73,7 @@ for (var i = 0; i <= lastIdx; ++i) { var item = series[i]; var yraw = item[1]; - var yval = yraw === null ? null : Dygraph.DataHandler.parseFloat(yraw); + var yval = yraw === null ? null : parseFloat(yraw); if (yval !== null) { if (i === firstIdx) { yval = (this.baseOpt === "percent") ? 0 : this.baseOpt; @@ -77,7 +84,7 @@ var point = { x: NaN, y: NaN, - xval: Dygraph.DataHandler.parseFloat(item[0]), + xval: parseFloat(item[0]), yval: yval, name: setName, idx: i + boundaryIdStart diff --git a/src/extras/shapes.js b/src/extras/shapes.js index a453177..2df07a9 100644 --- a/src/extras/shapes.js +++ b/src/extras/shapes.js @@ -68,7 +68,7 @@ var shapeFunction = function(sides, rotationRadians, delta) { }; }; -Dygraph.update(Dygraph.Circles, { +var customCircles = { TRIANGLE : shapeFunction(3), SQUARE : shapeFunction(4, Math.PI / 4), DIAMOND : shapeFunction(4), @@ -113,6 +113,11 @@ Dygraph.update(Dygraph.Circles, { ctx.closePath(); ctx.stroke(); } -}); +}; + +for (var k in customCircles) { + if (!customCircles.hasOwnProperty(k)) continue; + Dygraph.Circles[k] = customCircles[k]; +} })(); diff --git a/tests/drawing.html b/tests/drawing.html index 50be892..270b44e 100644 --- a/tests/drawing.html +++ b/tests/drawing.html @@ -147,13 +147,7 @@ if (tool == 'zoom') { Dygraph.defaultInteractionModel.mousedown(event, g, context); } else { - // prevents mouse drags from selecting page text. - if (event.preventDefault) { - event.preventDefault(); // Firefox, Chrome, etc. - } else { - event.returnValue = false; // IE - event.cancelBubble = true; - } + event.preventDefault(); // Firefox, Chrome, etc. isDrawing = true; setPoint(event, g, context); } @@ -195,7 +189,7 @@ g.updateOptions({ dateWindow: dateWindow }); - Dygraph.cancelEvent(event); + event.preventDefault(); } }, strokeWidth: 1.5, diff --git a/tests/hairlines.html b/tests/hairlines.html index 7ac23ee..1ffe163 100644 --- a/tests/hairlines.html +++ b/tests/hairlines.html @@ -10,8 +10,8 @@ - - + +