I have code that finds the max of two properties, but I don't know that it's the best way to do this. I am inside jQuery's $.getJSON(URI, function(json){}) call.
The goal is to make a bar chart with 2 bars that's exactly the width of the longest bar.
Currently to find the maximum value:
var max = Math.max.apply(this, $.map(json, function(d){ return Math.max(d.bar1, d.bar2); })); Is there a better way?
Edit: A json string, as requested:
[ { "bar1": "15", "bar2": "13" }, { "bar1": "20", "bar2": "25" }, { "bar1": "10", "bar2": "18" } ] max should be equal to 25 with this as an input.