javascript - Basic d3js max returning multiple values -


i'm trying 1 value d3's max function it's returning entire array. here example:

var data = {     "jim" : [         {             "value" : [10,11,12]         }     ] }  var mymax = d3.max(data.jim, function(d){         var maxval = d["value"];          return maxval;     })      console.log(mymax + "max") 

it returns 10,11,12max. should return 12.

you're trying find maximum of array data.jim has 1 element = {"value" : [10,11,12]} d3 promptly returns maximum using given accessor function. try changing code following:

var mymax = d3.max(data.jim, function(d){     var maxval = d3.max(d["value"]);     return maxval; }) 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -