diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index e2407f94fe8..5d4a72a161b 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -2306,6 +2306,9 @@ function _relayout(gd, aobj) { ) { flags.plot = true; } + else if(fullLayout._has('gl2d')) { + flags.plot = true; + } else if(valObject) editTypes.update(flags, valObject); else flags.calc = true; diff --git a/src/plots/gl2d/convert.js b/src/plots/gl2d/convert.js index 8a3a0ecf41f..41eec41b8ce 100644 --- a/src/plots/gl2d/convert.js +++ b/src/plots/gl2d/convert.js @@ -85,7 +85,7 @@ function Axes2DOptions(scene) { [0, 0, 0, 1] ]; - this.borderColor = false; + this.borderColor = [0, 0, 0, 0]; this.backgroundColor = [0, 0, 0, 0]; this.static = this.scene.staticPlot; diff --git a/test/jasmine/tests/gl2d_pointcloud_test.js b/test/jasmine/tests/gl2d_pointcloud_test.js index b83326824f0..92002313df1 100644 --- a/test/jasmine/tests/gl2d_pointcloud_test.js +++ b/test/jasmine/tests/gl2d_pointcloud_test.js @@ -9,6 +9,7 @@ var createGraphDiv = require('../assets/create_graph_div'); var destroyGraphDiv = require('../assets/destroy_graph_div'); var failTest = require('../assets/fail_test'); var delay = require('../assets/delay'); +var mouseEvent = require('../assets/mouse_event'); var readPixel = require('../assets/read_pixel'); var multipleScatter2dMock = require('@mocks/gl2d_scatter2d-multiple-colors.json'); @@ -158,16 +159,15 @@ describe('pointcloud traces', function() { }); it('@gl renders without raising an error', function(done) { - Plotly.plot(gd, plotData) + Plotly.plot(gd, Lib.extendDeep({}, plotData)) .catch(failTest) .then(done); }); it('@gl should update properly', function(done) { - var mock = plotData; var scene2d; - Plotly.plot(gd, mock) + Plotly.plot(gd, Lib.extendDeep({}, plotData)) .then(function() { scene2d = gd._fullLayout._plots.xy._scene2d; expect(scene2d.traces[gd._fullData[0].uid].type).toBe('pointcloud'); @@ -210,4 +210,49 @@ describe('pointcloud traces', function() { .catch(failTest) .then(done); }); + + it('@gl should respond to drag', function(done) { + function _drag(p0, p1) { + mouseEvent('mousemove', p0[0], p0[1], {buttons: 1}); + mouseEvent('mousedown', p0[0], p0[1], {buttons: 1}); + mouseEvent('mousemove', (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2, {buttons: 1}); + mouseEvent('mousemove', p1[0], p1[1], {buttons: 0}); + mouseEvent('mouseup', p1[0], p1[1], {buttons: 0}); + } + + function _assertRange(msg, xrng, yrng) { + expect(gd._fullLayout.xaxis.range).toBeCloseToArray(xrng, 2, msg); + expect(gd._fullLayout.yaxis.range).toBeCloseToArray(yrng, 2, msg); + } + + Plotly.plot(gd, Lib.extendDeep({}, plotData)) + .then(delay(40)) + .then(function() { + _assertRange('base', [-0.548, 9.548], [-1.415, 10.415]); + }) + .then(function() { _drag([200, 200], [350, 350]); }) + .then(delay(40)) + .then(function() { + _assertRange('after zoombox drag', [0.768, 1.591], [5.462, 7.584]); + }) + .then(function() { + return Plotly.relayout(gd, { + 'xaxis.autorange': true, + 'yaxis.autorange': true + }); + }) + .then(function() { + _assertRange('back to base', [-0.548, 9.548], [-1.415, 10.415]); + }) + .then(function() { + return Plotly.relayout(gd, 'dragmode', 'pan'); + }) + .then(function() { _drag([200, 200], [350, 350]); }) + .then(delay(40)) + .then(function() { + _assertRange('after pan drag', [0.2743, 10.3719], [-3.537, 8.292]); + }) + .catch(failTest) + .then(done); + }); });