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??
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.