سؤال

If I want the maximum value of an array, I can do this:

var data = [1,2,3,4,5];
console.log(d3.max(data));             //output 5

But if I try with an associative array, I get 'undefined':

var data = {'foo' : 4, 'baz' : 8};
console.log(d3.max(data));             //output undefined

How do I use d3.max() with an associative array?

هل كانت مفيدة؟

المحلول

Based on help from the comments to the question, this was the solution:

 d3.max(d3.values(data));
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top