How to find max and min values from JSON data. I want the maximum number of checks and control data data1, data2 ... data (n). My code is:
var max = d3.max(data, function(d) { return d.Checkintimes;} );
var min = d3.min(data, function(d) { return d.Checkintimes;} );
I tried this option too
d3.json("Values.json", function(data) {
var maxmbt = d3.max(d3.values(data) );
var maxcheckins = d3.max(d3.values(data));
console.log(maxmbt);
console.log(maxcheckins);
xScale.domain([0,maxcheckins]);
xScale.domain([0,maxmbt]);
});
I have json in this format:
[
{
"name":"data1",
"checkins":[[1,0],[2,0],[3,0],[4,3],[5,0],[6,0],[7,0],[8,3],[9,0],[10,0],[11,0],[12,0]],
"teamsize":[[1,0],[2,0],[3,0],[4,3],[5,0],[6,0],[7,0],[8,1],[9,0],[10,0],[11,0],[12,0]],
"Checkintimes":[[1,0],[2,0],[3,0],[4,184],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,0],[12,0]]
},
{"name":"data2",
"checkins":[[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,27],[12,12]],
"teamsize":[[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,11],[12,11]],
"Checkintimes":[[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,10],[12,12]]
}
]
Currently, when I use the return value, it is an array. not unitary value. For example, for example, the maximum value of checkins is 27 and Checkintimes is 184 in the above example.