diff --git a/src/pointFeature.js b/src/pointFeature.js index 7910a4f109..8f0c60a7a8 100644 --- a/src/pointFeature.js +++ b/src/pointFeature.js @@ -274,6 +274,7 @@ var pointFeature = function (arg) { var min, max, data, idx = [], found = [], ifound = [], map, pt, fgcs = m_this.gcs(), // this feature's gcs corners, + fill = m_this.style.get('fill'), stroke = m_this.style.get('stroke'), strokeWidth = m_this.style.get('strokeWidth'), radius = m_this.style.get('radius'); @@ -314,11 +315,14 @@ var pointFeature = function (arg) { // Filter by circular region idx.forEach(function (i) { var d = data[i], - p = m_this.position()(d, i), + hasstroke = stroke(data[i], i); + if (!hasstroke && !fill(data[i], i)) { + return; + } + var p = m_this.position()(d, i), dx, dy, rad, rad2; - rad = radius(data[i], i); - rad += stroke(data[i], i) ? strokeWidth(data[i], i) : 0; + rad += hasstroke ? strokeWidth(data[i], i) : 0; if (rad) { rad2 = rad * rad; p = map.gcsToDisplay(p, fgcs); diff --git a/tests/cases/pointFeature.js b/tests/cases/pointFeature.js index cbcafd2e7f..49e98cbf03 100644 --- a/tests/cases/pointFeature.js +++ b/tests/cases/pointFeature.js @@ -129,9 +129,16 @@ describe('geo.pointFeature', function () { expect(pt.found.length).toBe(1); pt = point.pointSearch(map.displayToGcs({x: p.x, y: p.y + 4.05})); expect(pt.found.length).toBe(0); - /* We should match two coincident pointss */ + /* We should match two coincident points */ pt = point.pointSearch({x: 50, y: 10}); expect(pt.found.length).toBe(2); + /* If a point has no fill or stroke, it won't be found. */ + point.style({ + fill: function (d, i) { return i !== 16; }, + stroke: function (d, i) { return i !== 16; } + }); + pt = point.pointSearch({x: 50, y: 10}); + expect(pt.found.length).toBe(1); /* If we have zero-length data, we get no matches */ point.data([]); pt = point.pointSearch({x: 22, y: 10});