Skip to content

1852 persistent click via select points #2944

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 56 commits into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
2fbaaaa
Tracer-bullet impl of fast click-to-select [1852]
rmoestl Aug 10, 2018
346bad9
Set correct blank outlines path in case of zero select polygons [1852]
rmoestl Aug 16, 2018
4f8dd92
Fix select_test.js Jasmine tests [1852]
rmoestl Aug 16, 2018
6a87769
Add click-to-select specific tests to select_test.js [1852]
rmoestl Aug 17, 2018
2d59365
Make click-to-select work in pan/zoom dragmodes [1852]
rmoestl Aug 21, 2018
5a13573
Introduce layout attribute 'clickmode' [1852]
rmoestl Aug 21, 2018
d3b4a0f
Simplify signature of selection testers' contains function [1852]
rmoestl Aug 21, 2018
36145df
Support click-to-select for histograms [1852]
rmoestl Aug 22, 2018
73e5085
Fix click-to-select bug when clearing selection with Shift [1852]
rmoestl Aug 22, 2018
1a89040
Enable click-to-select for scattergl in pan/zoom mode [1852]
rmoestl Aug 22, 2018
a6e49fd
Add click-to-select support to box plots [1852]
rmoestl Aug 22, 2018
bb44b6d
Fix bug when clearing selections and add/subtract mode on [1852]
rmoestl Aug 23, 2018
48a0a36
Test violin trace type's support for click-to-test [1852]
rmoestl Aug 23, 2018
4639718
Add click-to-select support to ohlc and candlestick [1852]
rmoestl Aug 23, 2018
497747b
Add click-to-select support to geo base plot [1852]
rmoestl Aug 23, 2018
744ab56
Add click-to-select support to mapbox and scattermapbox [1852]
rmoestl Aug 24, 2018
7da973b
Add @flaky flag to click-to-select tests [1852]
rmoestl Aug 24, 2018
ee5f990
Reactivate unhover on mouseout event in geo base plot [1852]
rmoestl Aug 24, 2018
6ac1a08
Add click-to-select support to scattergeo [1852]
rmoestl Aug 24, 2018
e11faf5
Add click-to-select support to ternary base plot [1852]
rmoestl Aug 24, 2018
bef47a3
Add test of scattercarpet's click-to-select support [1852]
rmoestl Aug 24, 2018
c394a8b
Add click-to-select support to polar base plot [1852]
rmoestl Aug 24, 2018
5b08a2c
Add testing scatterpolargl's click-to-select support [1852]
rmoestl Aug 24, 2018
e763964
Add click-to-select support to splom [1852]
rmoestl Aug 24, 2018
41e3ba5
Activate persistent selection for ternary plots [1852]
rmoestl Aug 27, 2018
6a2ae3b
Refine click-to-select TODO comments that'll be solved later [1852]
rmoestl Aug 27, 2018
e7c2240
Clean up box' custom eventData function [1852]
rmoestl Aug 27, 2018
23024b2
Call click-to-select's isPointOrBinSelected as late as possible [1852]
rmoestl Aug 27, 2018
cbd9f07
Refactor selection testing namings and structure [1852]
rmoestl Aug 27, 2018
7eba640
Add comment for multiTester's contains function [1852]
rmoestl Aug 27, 2018
92ee0fa
Remove two obsolete comments from cartesian/select.js [1852]
rmoestl Aug 27, 2018
3073f61
Merge branch 'master' into 1852-persistent-click-via-selectPoints
rmoestl Aug 27, 2018
3767ce2
Fix test-syntax linting errors in select_test.js [1852]
rmoestl Aug 27, 2018
8a4fc99
Fix further test-syntax linting errors in select_test.js [1852]
rmoestl Aug 27, 2018
db3e126
Fix for-loop bug in cartesian/select.js caught by ESLint [1852]
rmoestl Aug 27, 2018
b3984f7
Adapt description of of `clickmode` attribute [1852]
rmoestl Aug 29, 2018
2f7ad27
Simplify check if clicked point is the sole selected point [1852]
rmoestl Aug 30, 2018
d7c1434
Flag click-to-select tests of gl-based traces with @gl [1852]
rmoestl Aug 30, 2018
e895efd
Rename variable in `lib/select.js` [1852]
rmoestl Aug 30, 2018
60317b1
Adapt uninitialized var declarations in click-to-select code [1852]
rmoestl Aug 30, 2018
61b1a32
Add 'none' as an extra flag to clickmode [1852]
rmoestl Aug 30, 2018
e460e46
Simplify code for coercing selection cache state [1852]
rmoestl Aug 30, 2018
2ef3fce
Resolve TODO in cartesian/select.js regarding binned traces [1852]
rmoestl Aug 30, 2018
ac4b909
Remove lib/select.js and integrate code in cartesian/select.js [1852]
rmoestl Aug 30, 2018
05b50b9
Fix mapbox click-to-select bug caused by multiple click listeners [1852]
rmoestl Aug 30, 2018
88e9993
Fix testing click-to-select is inactive if clickmode is 'event' [1852]
rmoestl Sep 4, 2018
f247d93
Ensure 'plotly_click' is fired after 'plotly_selected' [1852]
rmoestl Sep 4, 2018
90ba209
Replace dynamic CI tags with static ones in select_test.js [1852]
rmoestl Sep 5, 2018
2bc582b
Apply @noCI tag to mapbox tests in select_test.js [1852]
rmoestl Sep 5, 2018
96fcdd7
Minor change: move helper method in select_test.s [1852]
rmoestl Sep 5, 2018
a5a90f9
Add a comment to select_test.js test [1852]
rmoestl Sep 6, 2018
87d0497
Default hovermode to closest if clickmode is select [1852]
rmoestl Sep 7, 2018
30789dd
Remove :hocho: obsolete polygon.multitester function [1852]
rmoestl Sep 7, 2018
cc2c9ba
Merge branch 'master' into 1852-persistent-click-via-selectPoints
rmoestl Sep 7, 2018
32aa219
Simplify clickmode / hovermode coercion code [1852]
rmoestl Sep 7, 2018
b6bd813
Not throw error for no longer valid polygon.tester argument [1852]
rmoestl Sep 10, 2018
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
8 changes: 4 additions & 4 deletions src/plots/cartesian/dragbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
if(numClicks === 2 && !singleEnd) doubleClick();

if(isMainDrag) {
if(clickmode.indexOf('event') > -1) {
Fx.click(gd, evt, plotinfo.id);
}

if(clickmode.indexOf('select') > -1) {
selectOnClick(evt, gd, xaxes, yaxes, plotinfo.id, dragOptions);
}

if(clickmode.indexOf('event') > -1) {
Fx.click(gd, evt, plotinfo.id);
}
}
else if(numClicks === 1 && singleEnd) {
var ax = ns ? ya0 : xa0,
Expand Down
10 changes: 5 additions & 5 deletions src/plots/geo/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,18 +452,18 @@ proto.updateFx = function(fullLayout, geoLayout) {
bgRect.on('click', function() {
// For select and lasso the dragElement is handling clicks
if(dragMode !== 'select' && dragMode !== 'lasso') {
if(clickMode.indexOf('select') > -1) {
selectOnClick(d3.event, gd, [_this.xaxis], [_this.yaxis],
_this.id, dragOptions);
}

if(clickMode.indexOf('event') > -1) {
// TODO: like pie and mapbox, this doesn't support right-click
// actually this one is worse, as right-click starts a pan, or leaves
// select in a weird state.
// Also, only tangentially related, we should cancel hover during pan
Fx.click(gd, d3.event);
}

if(clickMode.indexOf('select') > -1) {
selectOnClick(d3.event, gd, [_this.xaxis], [_this.yaxis],
_this.id, dragOptions);
}
}
});
};
Expand Down
22 changes: 9 additions & 13 deletions src/plots/mapbox/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,6 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
Fx.hover(gd, evt, self.id);
});

map.on('click', function(evt) {
// TODO: this does not support right-click. If we want to support it, we
// would likely need to change mapbox to use dragElement instead of straight
// mapbox event binding. Or perhaps better, make a simple wrapper with the
// right mousedown, mousemove, and mouseup handlers just for a left/right click
// pie would use this too.
Fx.click(gd, evt.originalEvent);
});

function unhover() {
Fx.loneUnhover(fullLayout._toppaper);
}
Expand Down Expand Up @@ -236,13 +227,18 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
return function(evt) {
var clickMode = gd._fullLayout.clickmode;

if(clickMode.indexOf('event') > -1) {
Fx.click(gd, evt.originalEvent);
}

if(clickMode.indexOf('select') > -1) {
selectOnClick(evt.originalEvent, gd, [self.xaxis], [self.yaxis], self.id, dragOptions);
}

if(clickMode.indexOf('event') > -1) {
// TODO: this does not support right-click. If we want to support it, we
// would likely need to change mapbox to use dragElement instead of straight
// mapbox event binding. Or perhaps better, make a simple wrapper with the
// right mousedown, mousemove, and mouseup handlers just for a left/right click
// pie would use this too.
Fx.click(gd, evt.originalEvent);
}
};
};
};
Expand Down
8 changes: 4 additions & 4 deletions src/plots/polar/polar.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,13 +849,13 @@ proto.updateMainDrag = function(fullLayout, polarLayout) {
Registry.call('relayout', gd, updateObj);
}

if(clickMode.indexOf('event') > -1) {
Fx.click(gd, evt, _this.id);
}

if(clickMode.indexOf('select') > -1 && numClicks === 1) {
selectOnClick(evt, gd, [_this.xaxis], [_this.yaxis], _this.id, dragOpts);
}

if(clickMode.indexOf('event') > -1) {
Fx.click(gd, evt, _this.id);
}
}

dragOpts.prepFn = function(evt, startX, startY) {
Expand Down
8 changes: 4 additions & 4 deletions src/plots/ternary/ternary.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,13 @@ proto.initInteractions = function() {
Registry.call('relayout', gd, attrs);
}

if(clickMode.indexOf('event') > -1) {
Fx.click(gd, evt, _this.id);
}

if(clickMode.indexOf('select') > -1 && numClicks === 1) {
selectOnClick(evt, gd, [_this.xaxis], [_this.yaxis], _this.id, dragOptions);
}

if(clickMode.indexOf('event') > -1) {
Fx.click(gd, evt, _this.id);
}
}

function zoomPrep(e, startX, startY) {
Expand Down
110 changes: 72 additions & 38 deletions test/jasmine/tests/select_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,28 +649,8 @@ describe('Click-to-select', function() {
]
.forEach(function(testCase) {
var ciAnnotation = testCase.gl ? 'gl' : 'flaky';
it('@' + ciAnnotation + ' trace type ' + testCase.traceType, function(done) {
var defaultLayoutOpts = {
layout: {
clickmode: 'event+select',
dragmode: 'pan',
hovermode: 'closest'
}
};
var customLayoutOptions = {
layout: testCase.layoutOptions
};
var customConfigOptions = {
config: testCase.configOptions
};
var mockCopy = Lib.extendDeep(
{},
testCase.mock,
defaultLayoutOpts,
customLayoutOptions,
customConfigOptions);

Plotly.plot(gd, mockCopy.data, mockCopy.layout, mockCopy.config)
it('@' + ciAnnotation + ' trace type ' + testCase.label, function(done) {
Plotly.plot(gd, testCase.mock.data, testCase.mock.layout, testCase.mock.config)
.then(function() {
return _immediateClickPt(testCase);
})
Expand All @@ -693,24 +673,78 @@ describe('Click-to-select', function() {
.then(done);
});
});
});

function testCase(traceType, mock, x, y, expectedPts, layoutOptions, configOptions) {
return {
traceType: traceType,
mock: mock,
layoutOptions: layoutOptions,
x: x,
y: y,
expectedPts: expectedPts,
configOptions: configOptions,
gl: false,
enableGl: function() {
this.gl = true;
return this;
}
};
}
describe('triggers \'plotly_selected\' before \'plotly_click\'', function() {
[
testCase('cartesian', require('@mocks/14.json'), 270, 160, [7]),
testCase('geo', require('@mocks/geo_scattergeo-locations.json'), 285, 240, [1]),
testCase('ternary', require('@mocks/ternary_markers.json'), 485, 335, [7]),
testCase('mapbox', require('@mocks/mapbox_0.json'), 650, 195, [[2], []], {},
{ mapboxAccessToken: require('@build/credentials.json').MAPBOX_ACCESS_TOKEN }),
testCase('polar', require('@mocks/polar_scatter.json'), 130, 290,
[[], [], [], [19], [], []], { dragmode: 'zoom' })
].forEach(function(testCase) {
it('@flaky for base plot ' + testCase.label, function(done) {
Plotly.plot(gd, testCase.mock.data, testCase.mock.layout, testCase.mock.config)
.then(function() {
var clickHandlerCalled = false;
var selectedHandlerCalled = false;

gd.on('plotly_selected', function() {
expect(clickHandlerCalled).toBe(false);
selectedHandlerCalled = true;
});
gd.on('plotly_click', function() {
clickHandlerCalled = true;
expect(selectedHandlerCalled).toBe(true);
done();
});

return click(testCase.x, testCase.y);
})
.catch(failTest)
.then(done);
});
});
});

function testCase(label, mock, x, y, expectedPts, layoutOptions, configOptions) {
var defaultLayoutOpts = {
layout: {
clickmode: 'event+select',
dragmode: 'pan',
hovermode: 'closest'
}
};
var customLayoutOptions = {
layout: layoutOptions
};
var customConfigOptions = {
config: configOptions
};
var mockCopy = Lib.extendDeep(
{},
mock,
defaultLayoutOpts,
customLayoutOptions,
customConfigOptions);

return {
label: label,
mock: mockCopy,
layoutOptions: layoutOptions,
x: x,
y: y,
expectedPts: expectedPts,
configOptions: configOptions,
gl: false,
enableGl: function() {
this.gl = true;
return this;
}
};
}
});

describe('Test select box and lasso in general:', function() {
Expand Down