Reputation: 11
I am using D3.js DataMaps for a Bubbles map. The problem of my map is that the biggest bubble is stacked on top of every other bubble. How do i get to sort these bubbles based on the radius??
Upvotes: 1
Views: 289
Reputation: 5043
since the bubbles data is an array of objects you could use a custom sort function like this
myBubblesData.sort(function(a, b){
if (a.radius < b.radius) {
return 1;
}
if (a.radius > b.radius) {
return -1;
}
return 0;
});
to return the objects sorted in the opposite order, just reverse the '1' and '-1' return statements.
Upvotes: 1