Merge branch 'ent-2555-fix-incremental-realtime-charts' into 'develop'
Fixed the incremental realtime charts See merge request artica/pandorafms!1695
This commit is contained in:
commit
e1a3eaf236
|
@ -42,13 +42,14 @@
|
|||
}
|
||||
|
||||
function requestData () {
|
||||
var rel_path = $("#hidden-rel_path").val();
|
||||
var ajaxPath = $("#hidden-ajax_path").val();
|
||||
|
||||
currentXHR = $.ajax({
|
||||
url: rel_path + "extensions/realtime_graphs/ajax.php",
|
||||
url: ajaxPath,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {
|
||||
page: "extensions/realtime_graphs/ajax",
|
||||
graph: $('#graph :selected').val(),
|
||||
graph_title: $('#graph :selected').html(),
|
||||
snmp_community: $('#text-snmp_community').val(),
|
||||
|
@ -61,6 +62,16 @@
|
|||
var timestamp = serie.data[0][0];
|
||||
var data = plot.getData();
|
||||
|
||||
if (incremental) {
|
||||
var currentVal = serie.data[0][1];
|
||||
// Try to avoid the first value, cause we need at least two values to get the increment
|
||||
serie.data[0][1] = lastIncVal == null ? 0 : currentVal - lastIncVal;
|
||||
// Incremental is always positive
|
||||
if (serie.data[0][1] < 0) serie.data[0][1] = 0;
|
||||
// Store the current value to use it into the next request
|
||||
lastIncVal = currentVal;
|
||||
}
|
||||
|
||||
if (data.length === 0) {
|
||||
for (i = 0; i < numberOfPoints; i++) {
|
||||
var step = i * (refresh / 1000);
|
||||
|
@ -77,16 +88,6 @@
|
|||
data[0].data.shift();
|
||||
}
|
||||
|
||||
if (incremental) {
|
||||
var currentVal = serie.data[0][1];
|
||||
// Try to avoid the first value, cause we need at least two values to get the increment
|
||||
serie.data[0][1] = lastIncVal == null ? 0 : currentVal - lastIncVal;
|
||||
// Incremental is always positive
|
||||
if (serie.data[0][1] < 0) serie.data[0][1] = 0;
|
||||
// Store the current value to use it into the next request
|
||||
lastIncVal = currentVal;
|
||||
}
|
||||
|
||||
data[0].data.push(serie.data[0]);
|
||||
updatePlot(data);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue