Wednesday, 14 August 2013

D3 - Returning the whole array with the max count

D3 - Returning the whole array with the max count

I'm new to D3 JS and having trouble looking for the solution to this.
I have the following pie data object:
pieData = [
{ title: "U", count: 10 },
{ title: "D", count: 30 },
{ title: "N", count: 50 }
];
I simply need to return the array with the highest count:
{ title: "N", count: 50 }
Now if I execute the following code, it only returns the maximum count.
But I need to access the whole array so I can print the title and the
count.
var maxData = d3.max(pieData, function(d) {
d.count;
});
I'm sure the solution to this is really simple. I hope some of you can
share a possible solution or some alternatives.

No comments:

Post a Comment