Skip to content

Instantly share code, notes, and snippets.

@ESeufert
Created May 2, 2014 09:20
Show Gist options
  • Save ESeufert/6aedcd73c9b1c2f7011e to your computer and use it in GitHub Desktop.
Save ESeufert/6aedcd73c9b1c2f7011e to your computer and use it in GitHub Desktop.
function getMaxObjectValue(metric, graph_metric) {
var values = [];
for (var i = 0; i < metric.length; i++) {
for (var k = 0; k < graph_metric.length; k++) {
if (parseFloat(metric[i][""+graph_metric[k]]) &lt; 1) {
values.push(parseFloat(metric[i][""+graph_metric[k]]));
} else {
values.push(Math.ceil(parseFloat(metric[i][""+graph_metric[k]])));
}
}
}
values.sort(function(a,b){return a-b});
return values[values.length-1];
}
function getMinObjectValue(metric, graph_metric) {
var values = [];
for (var i = 0; i < metric.length; i++) {
for (var k = 0; k < graph_metric.length; k++) {
if (parseFloat(metric[i][""+graph_metric[k]]) &lt; 1) {
values.push(parseFloat(metric[i][""+graph_metric[k]]));
} else {
values.push(Math.floor(parseFloat(metric[i][""+graph_metric[k]])));
}
}
}
values.sort(function(a,b){return a-b});
return values[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment