Skip to content

Commit

Permalink
Merge pull request #852 from OpenGeoscience/point-position-calls
Browse files Browse the repository at this point in the history
Ensure that all point position calls pass the data index.
  • Loading branch information
manthey committed Jul 12, 2018
2 parents 900a03b + 97bf156 commit 91f4095
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pointFeature.js
Expand Up @@ -148,7 +148,7 @@ var pointFeature = function (arg) {
} else {
var isFunc = util.isFunction(val);
m_this.style('position', function (d, i) {
if (d.__cluster) {
if (d !== null && d !== undefined && d.__cluster) {
return d;
} else if (isFunc) {
return val(d, i);
Expand Down Expand Up @@ -181,7 +181,7 @@ var pointFeature = function (arg) {

// create an array of positions in geo coordinates
pts = m_this.data().map(function (d, i) {
var pt = position(d);
var pt = position(d, i);

// store the maximum point radius
m_maxRadius = Math.max(
Expand Down Expand Up @@ -275,7 +275,7 @@ var pointFeature = function (arg) {
idx = [];
// TODO: use the range tree
m_this.data().forEach(function (d, i) {
var p = pos(d);
var p = pos(d, i);
if (p.x >= lowerLeft.x &&
p.x <= upperRight.x &&
p.y >= lowerLeft.y &&
Expand Down
3 changes: 3 additions & 0 deletions tests/cases/pointFeature.js
Expand Up @@ -53,6 +53,9 @@ describe('geo.pointFeature', function () {
point = geo.pointFeature({layer: layer, position: pos});
point._init({position: pos});
expect(point.position()('a')).toEqual(pos);
// with null data
point.position(function (d, i) { return i; });
expect(point.position()(null, 2)).toBe(2);
});

it('data', function () {
Expand Down

0 comments on commit 91f4095

Please sign in to comment.