I'm not sure if I understand correctly: retrieving data is much slower than running a logical operation on that data. So, instead of:
var maxX = Math.max.apply(Math, data.map(function(o) { return o[xAxis]; }));
var minY = Math.min.apply(Math, data.map(function(o) { return o[xAxis]; }));
var maxY = Math.max.apply(Math, data.map(function(o) { return o[yAxis]; }));
var minY = Math.min.apply(Math, data.map(function(o) { return o[yAxis]; }));
can I check for both min/max by traversing the data
set only once, and perhaps check for X and Y also at the same time (since data
is an array of JSON objects in this case)? And would this have any performance benefit in client(browser) or server(ex. Node.js)?
Thanks for any explanation.
Sample data:
[
{ date: '10.10.2000', xAxis: 20.9, yAxis: 120 },
{ date: '11.10.2000', xAxis: 35.1, yAxis: 121 },
{ date: '12.10.2000', xAxis: 21.2, yAxis: 109 },
{ date: '13.10.2000', xAxis: 28.4, yAxis: 119 },
{ date: '14.10.2000', xAxis: 24.4, yAxis: 121 }
]