Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d6f983e
agignore dist
alexcjohnson Dec 27, 2015
e536a91
point in polygon routine, with tests
alexcjohnson Dec 27, 2015
5cad4ff
lasso and selectbox skeleton
alexcjohnson Dec 28, 2015
ca60e63
propagate dragbox cursor to coverSlip while dragging
alexcjohnson Dec 29, 2015
76926d7
fix modebar logic and tests for select dragmodes
alexcjohnson Dec 29, 2015
78d2867
change polygon and its tests to multi-exports form
alexcjohnson Dec 29, 2015
f0e6cfb
polygon filtering algorithm
alexcjohnson Dec 29, 2015
c0a94f7
polygon filtering test
alexcjohnson Dec 29, 2015
12b43c6
special case of polygon for rectangles
alexcjohnson Dec 30, 2015
07e5cef
selection on scatter points
alexcjohnson Dec 31, 2015
b1a1c24
clear hover when drag starts
alexcjohnson Dec 31, 2015
1958475
didn't end up using a separate lasso handler
alexcjohnson Dec 31, 2015
3c40c41
crosshair it is
alexcjohnson Jan 4, 2016
188a0db
inline rectFirstEdgeTest
alexcjohnson Jan 4, 2016
8d0afb5
Merge branch 'master' into lasso
alexcjohnson Jan 4, 2016
1c5f325
lasso like it's 2016 baby!
alexcjohnson Jan 4, 2016
d0203c8
scatter.selectPoints uses scatter.hasMarkers
alexcjohnson Jan 4, 2016
5be72de
:cow2:
alexcjohnson Jan 4, 2016
057e4ac
prep for adding selection bounds to event data
alexcjohnson Jan 5, 2016
556cb83
split out scatter.selectPoints to a new file
alexcjohnson Jan 5, 2016
7b07a25
support selecting scatter text
alexcjohnson Jan 5, 2016
2a970fc
fx constants file
alexcjohnson Jan 5, 2016
d7abd18
more fx constants
alexcjohnson Jan 6, 2016
7addcec
BENDPX into constants
alexcjohnson Jan 6, 2016
d02d612
horizontal and vertical select boxes
alexcjohnson Jan 6, 2016
698376e
off-by-one error in select outline
alexcjohnson Jan 6, 2016
89c1655
clear selection on zoom/pan
alexcjohnson Jan 6, 2016
d8ed7a7
selection range event data
alexcjohnson Jan 6, 2016
7d897a4
show select icons only when they apply
alexcjohnson Jan 6, 2016
96e01b6
update modebar tests for new select icon logic
alexcjohnson Jan 6, 2016
bc04a15
desciption attribute value delimiters
alexcjohnson Jan 6, 2016
710791d
fix nonlinear axes in select
alexcjohnson Jan 6, 2016
342f991
:cow2:
alexcjohnson Jan 6, 2016
b5c090f
MINSELECT bigger than MINDRAG
alexcjohnson Jan 6, 2016
1d7745f
add lasso and selectbox icon
etpinard Jan 6, 2016
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
Prev Previous commit
Next Next commit
change polygon and its tests to multi-exports form
  • Loading branch information
alexcjohnson committed Dec 29, 2015
commit 78d2867fa28dfa1f5addbc01a2d6cebd4f76ebfd
6 changes: 5 additions & 1 deletion src/lib/polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
* don't double-count the edge where they meet.
* returns boolean: is pt inside the polygon (including on its edges)
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

🐄 put the jsDoc block above

polygon.tester = function tester(ptsIn) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh right... that's where it started, when this was the only export 🙈

module.exports = function polygon(ptsIn) {
var polygon = module.exports = {};

polygon.tester = function tester(ptsIn) {
var pts = ptsIn.slice(),
xmin = pts[0][0],
xmax = xmin,
Expand Down Expand Up @@ -115,3 +117,5 @@ module.exports = function polygon(ptsIn) {
contains: contains
};
};


17 changes: 9 additions & 8 deletions test/jasmine/tests/polygon_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var polygon = require('@src/lib/polygon');
var polygon = require('@src/lib/polygon'),
polygonTester = polygon.tester;

describe('polygon', function() {
describe('polygon.tester', function() {
'use strict';

var squareCW = [[0, 0], [0, 1], [1, 1], [1, 0]],
Expand Down Expand Up @@ -51,7 +52,7 @@ describe('polygon', function() {
notInDonut = [[1.5, -0.5], [1.5, 1.5], [1.5, 3.5], [-0.5, 1.5], [3.5, 1.5]];

it('should exclude points outside the bounding box', function() {
var poly = polygon([[1,2], [3,4]]);
var poly = polygonTester([[1,2], [3,4]]);
var pts = [[0, 3], [4, 3], [2, 1], [2, 5]];
pts.forEach(function(pt) {
expect(poly.contains(pt)).toBe(false);
Expand All @@ -67,7 +68,7 @@ describe('polygon', function() {
];

polyPts.forEach(function(polyPt) {
var poly = polygon(polyPt),
var poly = polygonTester(polyPt),
xArray = polyPt.map(function(pt) { return pt[0]; }),
yArray = polyPt.map(function(pt) { return pt[1]; });

Expand All @@ -89,7 +90,7 @@ describe('polygon', function() {
var np = 6; // number of intermediate points on each edge to test

polyPts.forEach(function(polyPt) {
var poly = polygon(polyPt);
var poly = polygonTester(polyPt);
poly.pts.forEach(function(pt1, i) {
if(!i) return;
var pt0 = poly.pts[i - 1],
Expand Down Expand Up @@ -123,16 +124,16 @@ describe('polygon', function() {
});

it('should find only the right interior points', function() {
var zzpoly = polygon(zigzag);
var zzpoly = polygonTester(zigzag);
inZigzag.forEach(function(pt) {
expect(zzpoly.contains(pt)).toBe(true);
});
notInZigzag.forEach(function(pt) {
expect(zzpoly.contains(pt)).toBe(false);
});

var donutpoly = polygon(donut),
donut2poly = polygon(donut2);
var donutpoly = polygonTester(donut),
donut2poly = polygonTester(donut2);
inDonut.forEach(function(pt) {
expect(donutpoly.contains(pt)).toBe(true);
expect(donut2poly.contains(pt)).toBe(true);
Expand Down