Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da86f27

Browse files
committed
add subplot scale on drag test case
1 parent 9d80ae2 commit da86f27

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/jasmine/tests/click_test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var Lib = require('@src/lib');
33
var Drawing = require('@src/components/drawing');
44
var DBLCLICKDELAY = require('@src/plots/cartesian/constants').DBLCLICKDELAY;
55

6+
var d3 = require('d3');
67
var createGraphDiv = require('../assets/create_graph_div');
78
var destroyGraphDiv = require('../assets/destroy_graph_div');
89
var mouseEvent = require('../assets/mouse_event');
@@ -809,3 +810,48 @@ describe('Test click interactions:', function() {
809810
});
810811
});
811812
});
813+
814+
describe('dragbox', function() {
815+
816+
afterEach(destroyGraphDiv);
817+
818+
it('should scale subplot and inverse scale scatter points', function(done) {
819+
var mock = Lib.extendDeep({}, require('@mocks/bar_line.json'));
820+
821+
function assertScale(node, x, y) {
822+
var scale = Drawing.getScale(node);
823+
expect(scale.x).toBeCloseTo(x, 1);
824+
expect(scale.y).toBeCloseTo(y, 1);
825+
}
826+
827+
Plotly.plot(createGraphDiv(), mock).then(function() {
828+
var node = d3.select('rect.nedrag').node();
829+
var pos = getRectCenter(node);
830+
831+
assertScale(d3.select('.plot').node(), 1, 1);
832+
833+
d3.selectAll('.point').each(function() {
834+
assertScale(this, 1, 1);
835+
});
836+
837+
mouseEvent('mousemove', pos[0], pos[1]);
838+
mouseEvent('mousedown', pos[0], pos[1]);
839+
mouseEvent('mousemove', pos[0] + 50, pos[1]);
840+
841+
setTimeout(function() {
842+
assertScale(d3.select('.plot').node(), 1.14, 1);
843+
844+
d3.select('.scatterlayer').selectAll('.point').each(function() {
845+
assertScale(this, 0.87, 1);
846+
});
847+
d3.select('.barlayer').selectAll('.point').each(function() {
848+
assertScale(this, 1, 1);
849+
});
850+
851+
mouseEvent('mouseup', pos[0] + 50, pos[1]);
852+
done();
853+
}, DBLCLICKDELAY / 4);
854+
});
855+
});
856+
857+
});

0 commit comments

Comments
 (0)