Skip to content

Commit

Permalink
Merge pull request markmarkoh#225 from thebenedict/master
Browse files Browse the repository at this point in the history
add option to update bubbles in place when lat/lng unchanged
  • Loading branch information
markmarkoh committed Sep 14, 2015
2 parents b994a14 + 2a8fa57 commit db310a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,19 @@ If the aspect ratio of your custom map is not the default `16:9` (`0.5625`), you
borderWidth: 2,
borderColor: '#FFFFFF',
popupOnHover: true,
radius: null,
popupTemplate: function(geography, data) {
return '<div class="hoverinfo"><strong>' + data.name + '</strong></div>';
return '<div class="hoverinfo"><strong>' + data.name + '</strong></div>';
},
fillOpacity: 0.75,
animate: true,
highlightOnHover: true,
highlightFillColor: '#FC8D59',
highlightBorderColor: 'rgba(250, 15, 160, 0.2)',
highlightBorderWidth: 2,
highlightFillOpacity: 0.85
highlightFillOpacity: 0.85,
exitDelay: 100,
key: JSON.stringify
},
arcConfig: {
strokeColor: '#DD1C77',
Expand Down
16 changes: 9 additions & 7 deletions src/js/datamaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
highlightBorderColor: 'rgba(250, 15, 160, 0.2)',
highlightBorderWidth: 2,
highlightFillOpacity: 0.85,
exitDelay: 100
exitDelay: 100,
key: JSON.stringify
},
arcConfig: {
strokeColor: '#DD1C77',
Expand Down Expand Up @@ -442,7 +443,7 @@
throw "Datamaps Error - bubbles must be an array";
}

var bubbles = layer.selectAll('circle.datamaps-bubble').data( data, JSON.stringify );
var bubbles = layer.selectAll('circle.datamaps-bubble').data( data, options.key );

bubbles
.enter()
Expand Down Expand Up @@ -532,10 +533,12 @@

d3.selectAll('.datamaps-hoverover').style('display', 'none');
})
.transition().duration(400)
.attr('r', function ( datum ) {
return val(datum.radius, options.radius, datum);
});

bubbles.transition()
.duration(400)
.attr('r', function ( datum ) {
return val(datum.radius, options.radius, datum);
});

bubbles.exit()
.transition()
Expand All @@ -546,7 +549,6 @@
function datumHasCoords (datum) {
return typeof datum !== 'undefined' && typeof datum.latitude !== 'undefined' && typeof datum.longitude !== 'undefined';
}

}

//stolen from underscore.js
Expand Down

0 comments on commit db310a7

Please sign in to comment.