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
27 changes: 12 additions & 15 deletions src/lib/polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,34 +174,31 @@ polygon.tester = function tester(ptsIn) {
};
};

// TODO Somewhat redundant to multiTester in 'lib/select.js'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think polygon.multiTester gets called anywhere now. Would you mind 🔪 ing it?

  • Extract multitester to new module lib/select.js because
    multitester is no longer to been seen in the
    sole context of polygons.

This makes perfect sense. Using a polygon multi-tester function for click-to-select would have been confusing 👌

That said, I don't think we need another file in lib/ for this thing. Plus, having files called select.js in plots/cartesian, all over traces/ and now lib/select.js probably isn't ideal. Would it be ok to just move the contents of your new lib/select.js to cartesian/select.js?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be ok to just move the contents of your new lib/select.js to cartesian/select.js?

It's not just used by cartesian though, right?

Copy link
Contributor Author

@rmoestl rmoestl Aug 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not just used by cartesian though, right?

Exactly. E.g. it is used in polar and choropleth.
Update: Sorry, I was referring to polygon.tester. cartesian/select.js is in fact the only module requiring lib/select.js. So I think it'd be better to move it there. Do you agree, @alexcjohnson ?

I don't think polygon.multiTester gets called anywhere now

Nope. It's called in polygon.tester in the first line.
Update: polygon.tester is used by polar, choropleth etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, all of cartesian/select.js should be moved out of cartesian/ - as @alexcjohnson said it is not just used for cartesian subplots anymore.

What I was suggesting is to move the contents of lib/select.js into the same file as cartesian/select.js as the contents of lib/select.js aren't used anywhere else.

Once that's done, we can move cartesian/select.js to either components/fx (side-by-side with the hover routines) or in a new components/ directory e.g. components/select.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Moved contents of lib/select.js into cartesian/select.js`.

Copy link
Contributor

@etpinard etpinard Sep 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmoestl thanks for moving the contents to cartesian/select.js 🚚

Now, would you mind 🔪 the multiTester routine and the TODO above from this file. polygon.multiTester isn't used anywhere now.

Copy link
Contributor Author

@rmoestl rmoestl Sep 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, to repeat that, but isnt't polygon.multiTester called here

if(Array.isArray(ptsIn[0][0])) return polygon.multitester(ptsIn);
?

Or can we 🔪 that line as well? I hesitated to do so back then because polygon.tester is called from multiple places other than selection code - potentially with a parameter type that requires this very line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad! I grep'ed for multiTester not multitester. You're correct, multitester is currently used in tester in lib/polygon.js.

Now, if I recall correctly, that polygon.multitester call in polygon.tester was only intended for mulit-selections. Git blame points us to b800e55 which is consistent.

When commenting out this line

if(Array.isArray(ptsIn[0][0])) return polygon.multitester(ptsIn);

no test fail.

So yeah, I think it's safe to 🔪 everything about multitester in lib/polygon.js.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think we have enough tests that you could try replacing that line with
if(Array.isArray(ptsIn[0][0])) throw new Error('multitester called!');
or something and see if it ever happens.

But if it does, could that line just point to the new multiTester? Of course doing that would make a circular reference unless these are brought into the same file - which might be better anyway, I feel like these belong together (even if we can't quite agree on where that together should be...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running all tests didn't throw the error. I left throwing the error in place and added a nice comment to it, so that future readers understand the "why".

/**
* Test multiple polygons
*/
polygon.multitester = function multitester(list) {
var testers = [],
xmin = list[0].contains ? 0 : list[0][0][0],
xmin = list[0][0][0],
xmax = xmin,
ymin = list[0].contains ? 0 : list[0][0][1],
ymin = list[0][0][1],
ymax = ymin;

for(var i = 0; i < list.length; i++) {
if(list[i].contains) {
testers.push(list[i]);
} else {
var tester = polygon.tester(list[i]);
tester.subtract = list[i].subtract;
testers.push(tester);
xmin = Math.min(xmin, tester.xmin);
xmax = Math.max(xmax, tester.xmax);
ymin = Math.min(ymin, tester.ymin);
ymax = Math.max(ymax, tester.ymax);
}
var tester = polygon.tester(list[i]);
tester.subtract = list[i].subtract;
testers.push(tester);
xmin = Math.min(xmin, tester.xmin);
xmax = Math.max(xmax, tester.xmax);
ymin = Math.min(ymin, tester.ymin);
ymax = Math.max(ymax, tester.ymax);
}

function contains(pt, arg, pointNumber, searchInfo) {
function contains(pt, arg) {
var yes = false;
for(var i = 0; i < testers.length; i++) {
if(testers[i].contains(pt, arg, pointNumber, searchInfo)) {
if(testers[i].contains(pt, arg)) {
// if contained by subtract polygon - exclude the point
yes = testers[i].subtract === false;
}
Expand Down
116 changes: 116 additions & 0 deletions src/lib/select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var polygon = require('./polygon');

var select = module.exports = {};

/**
* Constructs a new point selection definition.
*
* @param pointNumber the point number of the point as in `data`
* @param searchInfo identifies the trace the point is contained in
* @param subtract true if the selection definition should mark a deselection
* @return {{pointNumber: Number, searchInfo: Object, subtract: boolean}}
*/
select.pointSelectionDef = function(pointNumber, searchInfo, subtract) {
return {
pointNumber: pointNumber,
searchInfo: searchInfo,
subtract: subtract
};
};

function isPointSelectionDef(o) {
return 'pointNumber' in o && 'searchInfo' in o;
}

function pointNumberTester(pointSelectionDef) {
return {
xmin: 0,
xmax: 0,
ymin: 0,
ymax: 0,
pts: [],
contains: function(pt, omitFirstEdge, pointNumber, searchInfo) {
return searchInfo.cd[0].trace._expandedIndex === pointSelectionDef.searchInfo.cd[0].trace._expandedIndex &&
pointNumber === pointSelectionDef.pointNumber;
},
isRect: false,
degenerate: false,
subtract: pointSelectionDef.subtract
};
}

/**
* Wraps multiple selection testers.
*
* @param list an array of selection testers
*
* @return a selection tester object with a contains function
* that can be called to evaluate a point against all wrapped
* selection testers that were passed in list.
*/
select.multiTester = function multiTester(list) {
var testers = [];
var xmin = isPointSelectionDef(list[0]) ? 0 : list[0][0][0];
var xmax = xmin;
var ymin = isPointSelectionDef(list[0]) ? 0 : list[0][0][1];
var ymax = ymin;

for(var i = 0; i < list.length; i++) {
if(isPointSelectionDef(list[i])) {
testers.push(pointNumberTester(list[i]));
} else {
var tester = polygon.tester(list[i]);
tester.subtract = list[i].subtract;
testers.push(tester);
xmin = Math.min(xmin, tester.xmin);
xmax = Math.max(xmax, tester.xmax);
ymin = Math.min(ymin, tester.ymin);
ymax = Math.max(ymax, tester.ymax);
}
}

// TODO Consider making signature of contains more lean
/**
* Tests if the given point is within this tester.
*
* @param pt an object having an `x` and a `y` property defining the location
* of the point
* @param arg parameter to pass additional arguments down to wrapped testers
* @param pointNumber the point number of the point
* @param searchInfo identifies the trace the point is contained in
* @return {boolean}
*/
function contains(pt, arg, pointNumber, searchInfo) {
var yes = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐄 I'd use a somewhat less prejudiced name - yes is a bit too much of a synonym for true.
contained perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I wasn't looking through that code too much since I just moved multiTester from lib/polygon.js. But I remember this yes identifier catching my attention once in a while. I'm going to change it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I hadn't noticed that it was already there before. Well, moving is the best time to clean house :) thanks!

for(var i = 0; i < testers.length; i++) {
if(testers[i].contains(pt, arg, pointNumber, searchInfo)) {
// if contained by subtract tester - exclude the point
yes = testers[i].subtract === false;
}
}

return yes;
}

return {
xmin: xmin,
xmax: xmax,
ymin: ymin,
ymax: ymax,
pts: [],
contains: contains,
isRect: false,
degenerate: false
};
};
62 changes: 23 additions & 39 deletions src/plots/cartesian/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var Color = require('../../components/color');
var Fx = require('../../components/fx');

var polygon = require('../../lib/polygon');
var select = require('../../lib/select');
var throttle = require('../../lib/throttle');
var makeEventData = require('../../components/fx/helpers').makeEventData;
var getFromId = require('./axis_ids').getFromId;
Expand All @@ -26,7 +27,8 @@ var MINSELECT = constants.MINSELECT;

var filteredPolygon = polygon.filter;
var polygonTester = polygon.tester;
var multipolygonTester = polygon.multitester;
var pointSelectionDef = select.pointSelectionDef;
var multiTester = select.multiTester;

function getAxId(ax) { return ax._id; }

Expand All @@ -50,7 +52,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
var allAxes = dragOptions.xaxes.concat(dragOptions.yaxes);
var subtract = e.altKey;

var filterPoly, testPoly, mergedPolygons, currentPolygon;
var filterPoly, selectionTester, mergedPolygons, currentPolygon;
var i, searchInfo, eventData;

coerceSelectionsCache(e, gd, dragOptions);
Expand Down Expand Up @@ -185,14 +187,14 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
}

// create outline & tester
if(dragOptions.polygons && dragOptions.polygons.length) {
if(dragOptions.selectionDefs && dragOptions.selectionDefs.length) {
mergedPolygons = mergePolygons(dragOptions.mergedPolygons, currentPolygon, subtract);
currentPolygon.subtract = subtract;
testPoly = multipolygonTester(dragOptions.polygons.concat([currentPolygon]));
selectionTester = multiTester(dragOptions.selectionDefs.concat([currentPolygon]));
}
else {
mergedPolygons = [currentPolygon];
testPoly = polygonTester(currentPolygon);
selectionTester = polygonTester(currentPolygon);
}

// draw selection
Expand All @@ -209,7 +211,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
for(i = 0; i < searchTraces.length; i++) {
searchInfo = searchTraces[i];

traceSelection = searchInfo._module.selectPoints(searchInfo, testPoly);
traceSelection = searchInfo._module.selectPoints(searchInfo, selectionTester);
traceSelections.push(traceSelection);

thisSelection = fillSelectionItem(traceSelection, searchInfo);
Expand Down Expand Up @@ -276,10 +278,10 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
throttle.clear(throttleID);
dragOptions.gd.emit('plotly_selected', eventData);

if(currentPolygon && dragOptions.polygons) {
if(currentPolygon && dragOptions.selectionDefs) {
// save last polygons
currentPolygon.subtract = subtract;
dragOptions.polygons.push(currentPolygon);
dragOptions.selectionDefs.push(currentPolygon);

// we have to keep reference to arrays container
dragOptions.mergedPolygons.length = 0;
Expand All @@ -296,8 +298,8 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli
var selection = [];
var searchTraces;
var searchInfo;
var currentPolygon;
var testPoly;
var currentSelectionDef;
var selectionTester;
var traceSelection;
var thisTracesSelection;
var pointOrBinSelected;
Expand Down Expand Up @@ -338,13 +340,13 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli
(pointOrBinSelected !== undefined ?
pointOrBinSelected :
isPointOrBinSelected(clickedPtInfo));
currentPolygon = createPtNumTester(clickedPtInfo.pointNumber, clickedPtInfo.searchInfo, subtract);
currentSelectionDef = pointSelectionDef(clickedPtInfo.pointNumber, clickedPtInfo.searchInfo, subtract);

var concatenatedPolygons = dragOptions.polygons.concat([currentPolygon]);
testPoly = multipolygonTester(concatenatedPolygons);
var allSelectionDefs = dragOptions.selectionDefs.concat([currentSelectionDef]);
selectionTester = multiTester(allSelectionDefs);

for(i = 0; i < searchTraces.length; i++) {
traceSelection = searchTraces[i]._module.selectPoints(searchTraces[i], testPoly);
traceSelection = searchTraces[i]._module.selectPoints(searchTraces[i], selectionTester);
thisTracesSelection = fillSelectionItem(traceSelection, searchTraces[i]);

if(selection.length) {
Expand All @@ -358,8 +360,8 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli
eventData = {points: selection};
updateSelectedState(gd, searchTraces, eventData);

if(currentPolygon && dragOptions) {
dragOptions.polygons.push(currentPolygon);
if(currentSelectionDef && dragOptions) {
dragOptions.selectionDefs.push(currentSelectionDef);
}

if(polygonOutlines) drawSelection(dragOptions.mergedPolygons, polygonOutlines);
Expand All @@ -384,11 +386,11 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
if(
selectingOnSameSubplot &&
(evt.shiftKey || evt.altKey) &&
(plotinfo.selection && plotinfo.selection.polygons) &&
!dragOptions.polygons
(plotinfo.selection && plotinfo.selection.selectionDefs) &&
!dragOptions.selectionDefs
) {
// take over selection polygons from prev mode, if any
dragOptions.polygons = plotinfo.selection.polygons;
// take over selection definitions from prev mode, if any
dragOptions.selectionDefs = plotinfo.selection.selectionDefs;
dragOptions.mergedPolygons = plotinfo.selection.mergedPolygons;
} else if(
(!evt.shiftKey && !evt.altKey) ||
Expand All @@ -408,7 +410,7 @@ function clearSelectionsCache(dragOptions) {
var plotinfo = dragOptions.plotinfo;

plotinfo.selection = {};
plotinfo.selection.polygons = dragOptions.polygons = [];
plotinfo.selection.selectionDefs = dragOptions.selectionDefs = [];
plotinfo.selection.mergedPolygons = dragOptions.mergedPolygons = [];
}

Expand Down Expand Up @@ -515,24 +517,6 @@ function extractClickedPtInfo(hoverData, searchTraces) {
};
}

function createPtNumTester(wantedPointNumber, wantedSearchInfo, subtract) {
return {
xmin: 0,
xmax: 0,
ymin: 0,
ymax: 0,
pts: [],
// TODO Consider making signature of contains more lean
contains: function(pt, omitFirstEdge, pointNumber, searchInfo) {
return searchInfo.cd[0].trace._expandedIndex === wantedSearchInfo.cd[0].trace._expandedIndex &&
pointNumber === wantedPointNumber;
},
isRect: false,
degenerate: false,
subtract: subtract
};
}

function isPointOrBinSelected(clickedPtInfo) {
var trace = clickedPtInfo.searchInfo.cd[0].trace;
var ptNum = clickedPtInfo.pointNumber;
Expand Down
6 changes: 3 additions & 3 deletions src/traces/bar/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

'use strict';

module.exports = function selectPoints(searchInfo, polygon) {
module.exports = function selectPoints(searchInfo, selectionTester) {
var cd = searchInfo.cd;
var xa = searchInfo.xaxis;
var ya = searchInfo.yaxis;
var selection = [];
var i;

if(polygon === false) {
if(selectionTester === false) {
// clear selection
for(i = 0; i < cd.length; i++) {
cd[i].selected = 0;
Expand All @@ -24,7 +24,7 @@ module.exports = function selectPoints(searchInfo, polygon) {
for(i = 0; i < cd.length; i++) {
var di = cd[i];

if(polygon.contains(di.ct, false, i, searchInfo)) {
if(selectionTester.contains(di.ct, false, i, searchInfo)) {
selection.push({
pointNumber: i,
x: xa.c2d(di.x),
Expand Down
6 changes: 3 additions & 3 deletions src/traces/box/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

'use strict';

module.exports = function selectPoints(searchInfo, polygon) {
module.exports = function selectPoints(searchInfo, selectionTester) {
var cd = searchInfo.cd;
var xa = searchInfo.xaxis;
var ya = searchInfo.yaxis;
var selection = [];
var i, j;

if(polygon === false) {
if(selectionTester === false) {
for(i = 0; i < cd.length; i++) {
for(j = 0; j < (cd[i].pts || []).length; j++) {
// clear selection
Expand All @@ -29,7 +29,7 @@ module.exports = function selectPoints(searchInfo, polygon) {
var x = xa.c2p(pt.x);
var y = ya.c2p(pt.y);

if(polygon.contains([x, y], null, pt.i, searchInfo)) {
if(selectionTester.contains([x, y], null, pt.i, searchInfo)) {
selection.push({
pointNumber: pt.i,
x: xa.c2d(pt.x),
Expand Down
6 changes: 3 additions & 3 deletions src/traces/choropleth/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

'use strict';

module.exports = function selectPoints(searchInfo, polygon) {
module.exports = function selectPoints(searchInfo, selectionTester) {
var cd = searchInfo.cd;
var xa = searchInfo.xaxis;
var ya = searchInfo.yaxis;
var selection = [];

var i, di, ct, x, y;

if(polygon === false) {
if(selectionTester === false) {
for(i = 0; i < cd.length; i++) {
cd[i].selected = 0;
}
Expand All @@ -30,7 +30,7 @@ module.exports = function selectPoints(searchInfo, polygon) {
x = xa.c2p(ct);
y = ya.c2p(ct);

if(polygon.contains([x, y], null, i, searchInfo)) {
if(selectionTester.contains([x, y], null, i, searchInfo)) {
selection.push({
pointNumber: i,
lon: ct[0],
Expand Down
Loading