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

Skip to content

Commit ebaf705

Browse files
committed
fix select/lasso click event + test
1 parent 1075d87 commit ebaf705

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

src/plots/cartesian/select.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var polygon = require('../../lib/polygon');
1414
var throttle = require('../../lib/throttle');
1515
var color = require('../../components/color');
1616
var makeEventData = require('../../components/fx/helpers').makeEventData;
17+
var Fx = require('../../components/fx');
1718

1819
var axes = require('./axes');
1920
var constants = require('./constants');
@@ -258,7 +259,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
258259
);
259260
};
260261

261-
dragOptions.clickFn = function(numClicks) {
262+
dragOptions.clickFn = function(numClicks, evt) {
262263
corners.remove();
263264

264265
throttle.done(throttleID).then(function() {
@@ -279,6 +280,8 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
279280
// but in case anyone depends on it we don't want to break it now.
280281
gd.emit('plotly_selected', undefined);
281282
}
283+
284+
Fx.click(gd, evt);
282285
});
283286
};
284287

test/jasmine/tests/gl2d_click_test.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,84 @@ describe('Test hover and click interactions', function() {
221221
.then(done);
222222
});
223223

224+
it('should output correct event data for scattergl in *select* dragmode', function(done) {
225+
var _mock = Lib.extendDeep({}, mock1);
226+
227+
_mock.layout.dragmode = 'select';
228+
229+
_mock.layout.hoverlabel = {
230+
font: {
231+
size: 20,
232+
color: 'yellow'
233+
}
234+
};
235+
_mock.data[0].hoverinfo = _mock.data[0].x.map(function(_, i) { return i % 2 ? 'y' : 'x'; });
236+
237+
_mock.data[0].hoverlabel = {
238+
bgcolor: 'blue',
239+
bordercolor: _mock.data[0].x.map(function(_, i) { return i % 2 ? 'red' : 'green'; })
240+
};
241+
242+
var run = makeRunner([634, 321], {
243+
x: 15.772,
244+
y: 0.387,
245+
label: ['0.387', null],
246+
curveNumber: 0,
247+
pointNumber: 33,
248+
bgcolor: 'rgb(0, 0, 255)',
249+
bordercolor: 'rgb(255, 0, 0)',
250+
fontSize: 20,
251+
fontFamily: 'Arial',
252+
fontColor: 'rgb(255, 255, 0)'
253+
}, {
254+
msg: 'scattergl'
255+
});
256+
257+
Plotly.plot(gd, _mock)
258+
.then(run)
259+
.catch(fail)
260+
.then(done);
261+
});
262+
263+
it('should output correct event data for scattergl in *lasso* dragmode', function(done) {
264+
var _mock = Lib.extendDeep({}, mock1);
265+
266+
_mock.layout.dragmode = 'lasso';
267+
268+
_mock.layout.hoverlabel = {
269+
font: {
270+
size: 20,
271+
color: 'yellow'
272+
}
273+
};
274+
_mock.data[0].hoverinfo = _mock.data[0].x.map(function(_, i) { return i % 2 ? 'y' : 'x'; });
275+
276+
_mock.data[0].hoverlabel = {
277+
bgcolor: 'blue',
278+
bordercolor: _mock.data[0].x.map(function(_, i) { return i % 2 ? 'red' : 'green'; })
279+
};
280+
281+
var run = makeRunner([634, 321], {
282+
x: 15.772,
283+
y: 0.387,
284+
label: ['0.387', null],
285+
curveNumber: 0,
286+
pointNumber: 33,
287+
bgcolor: 'rgb(0, 0, 255)',
288+
bordercolor: 'rgb(255, 0, 0)',
289+
fontSize: 20,
290+
fontFamily: 'Arial',
291+
fontColor: 'rgb(255, 255, 0)'
292+
}, {
293+
msg: 'scattergl'
294+
});
295+
296+
Plotly.plot(gd, _mock)
297+
.then(run)
298+
.catch(fail)
299+
.then(done);
300+
});
301+
224302
it('should output correct event data for scattergl with hoverinfo: \'none\'', function(done) {
225303
var _mock = Lib.extendDeep({}, mock1);
226304
_mock.data[0].hoverinfo = 'none';

0 commit comments

Comments
 (0)