Skip to content

gl2d fixes #3647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/plots/gl2d/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
51 changes: 48 additions & 3 deletions test/jasmine/tests/gl2d_pointcloud_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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);
});
});