1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

feature #3748: Add derivative for graphs

This commit is contained in:
Daniel Molina 2015-06-09 12:58:09 +02:00
parent d9ee6a91d3
commit 3116a6d8db

View File

@ -14,9 +14,9 @@ define(function(require) {
CONSTRUCTOR
*/
return {
return {
'plot': _plotGraph
}
}
/*
FUNCTION DEFINITIONS
@ -91,4 +91,21 @@ define(function(require) {
$.plot(info.div_graph, series, options);
};
}
function derivative(data) {
for (var i = 0; i < data.length - 1; i++) {
// Each elem is [timestamp, cumulative value]
var first = data[i];
var second = data[i + 1];
// value now - value before / seconds
var speed = (second[1] - first[1]) / (second[0] - first[0]);
// The first element is replaced with the second one
data[i] = [first[0], speed];
}
// The last elem must be removed
data.pop();
}
});