Skip to content

Commit 89c86cb

Browse files
authored
Merge pull request #3647 from plotly/gl2d-fixes
gl2d fixes
2 parents 448cb14 + bc87c01 commit 89c86cb

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

src/plot_api/plot_api.js

+3
Original file line numberDiff line numberDiff line change
@@ -2306,6 +2306,9 @@ function _relayout(gd, aobj) {
23062306
) {
23072307
flags.plot = true;
23082308
}
2309+
else if(fullLayout._has('gl2d')) {
2310+
flags.plot = true;
2311+
}
23092312
else if(valObject) editTypes.update(flags, valObject);
23102313
else flags.calc = true;
23112314

src/plots/gl2d/convert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function Axes2DOptions(scene) {
8585
[0, 0, 0, 1]
8686
];
8787

88-
this.borderColor = false;
88+
this.borderColor = [0, 0, 0, 0];
8989
this.backgroundColor = [0, 0, 0, 0];
9090

9191
this.static = this.scene.staticPlot;

test/jasmine/tests/gl2d_pointcloud_test.js

+48-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var createGraphDiv = require('../assets/create_graph_div');
99
var destroyGraphDiv = require('../assets/destroy_graph_div');
1010
var failTest = require('../assets/fail_test');
1111
var delay = require('../assets/delay');
12+
var mouseEvent = require('../assets/mouse_event');
1213
var readPixel = require('../assets/read_pixel');
1314

1415
var multipleScatter2dMock = require('@mocks/gl2d_scatter2d-multiple-colors.json');
@@ -158,16 +159,15 @@ describe('pointcloud traces', function() {
158159
});
159160

160161
it('@gl renders without raising an error', function(done) {
161-
Plotly.plot(gd, plotData)
162+
Plotly.plot(gd, Lib.extendDeep({}, plotData))
162163
.catch(failTest)
163164
.then(done);
164165
});
165166

166167
it('@gl should update properly', function(done) {
167-
var mock = plotData;
168168
var scene2d;
169169

170-
Plotly.plot(gd, mock)
170+
Plotly.plot(gd, Lib.extendDeep({}, plotData))
171171
.then(function() {
172172
scene2d = gd._fullLayout._plots.xy._scene2d;
173173
expect(scene2d.traces[gd._fullData[0].uid].type).toBe('pointcloud');
@@ -210,4 +210,49 @@ describe('pointcloud traces', function() {
210210
.catch(failTest)
211211
.then(done);
212212
});
213+
214+
it('@gl should respond to drag', function(done) {
215+
function _drag(p0, p1) {
216+
mouseEvent('mousemove', p0[0], p0[1], {buttons: 1});
217+
mouseEvent('mousedown', p0[0], p0[1], {buttons: 1});
218+
mouseEvent('mousemove', (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2, {buttons: 1});
219+
mouseEvent('mousemove', p1[0], p1[1], {buttons: 0});
220+
mouseEvent('mouseup', p1[0], p1[1], {buttons: 0});
221+
}
222+
223+
function _assertRange(msg, xrng, yrng) {
224+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray(xrng, 2, msg);
225+
expect(gd._fullLayout.yaxis.range).toBeCloseToArray(yrng, 2, msg);
226+
}
227+
228+
Plotly.plot(gd, Lib.extendDeep({}, plotData))
229+
.then(delay(40))
230+
.then(function() {
231+
_assertRange('base', [-0.548, 9.548], [-1.415, 10.415]);
232+
})
233+
.then(function() { _drag([200, 200], [350, 350]); })
234+
.then(delay(40))
235+
.then(function() {
236+
_assertRange('after zoombox drag', [0.768, 1.591], [5.462, 7.584]);
237+
})
238+
.then(function() {
239+
return Plotly.relayout(gd, {
240+
'xaxis.autorange': true,
241+
'yaxis.autorange': true
242+
});
243+
})
244+
.then(function() {
245+
_assertRange('back to base', [-0.548, 9.548], [-1.415, 10.415]);
246+
})
247+
.then(function() {
248+
return Plotly.relayout(gd, 'dragmode', 'pan');
249+
})
250+
.then(function() { _drag([200, 200], [350, 350]); })
251+
.then(delay(40))
252+
.then(function() {
253+
_assertRange('after pan drag', [0.2743, 10.3719], [-3.537, 8.292]);
254+
})
255+
.catch(failTest)
256+
.then(done);
257+
});
213258
});

0 commit comments

Comments
 (0)