summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPiBa-NL <pba_2k3@yahoo.com>2017-03-04 00:07:21 +0100
committerPiBa-NL <pba_2k3@yahoo.com>2017-03-04 20:45:49 +0100
commiteddb01316c7ad06c1798e629b6158db505a86118 (patch)
tree6454552c26201416faf2aca7f771f76ba1b8512d /src
parent69860ee4f5ff9f1e5b87bc6fdcb6dfea66062726 (diff)
downloadpfsense-eddb01316c7ad06c1798e629b6158db505a86118.zip
pfsense-eddb01316c7ad06c1798e629b6158db505a86118.tar.gz
trafficgraphs, divide bandwidth by time when statistics where gathered to smooth out bumps in the graphs
Diffstat (limited to 'src')
-rw-r--r--src/usr/local/www/js/traffic-graphs.js27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/usr/local/www/js/traffic-graphs.js b/src/usr/local/www/js/traffic-graphs.js
index 79e3927..3b318b0 100644
--- a/src/usr/local/www/js/traffic-graphs.js
+++ b/src/usr/local/www/js/traffic-graphs.js
@@ -23,6 +23,7 @@ function draw_graph(refreshInterval, then, backgroundupdate) {
var invert = localStorage.getItem('invert');
var size = localStorage.getItem('size');
+ var lasttime = 0;
startTime = 120 * refreshInterval;
then.setSeconds(then.getSeconds() - startTime);
@@ -149,39 +150,45 @@ function draw_graph(refreshInterval, then, backgroundupdate) {
}
- now = new Date(Date.now());
-
+ var setTime = true;
+ var xtime = 0;
+ var timeDiff = 0;
$.each(json, function( key, ifVals ) {
+ if (setTime == true) {
+ var valueTime = ifVals[0].values[0];
+ timeDiff = valueTime - lasttime;
+ lasttime = valueTime;
+ xtime = valueTime * 1000;
+ setTime = false;
+ }
label = $('#traffic-chart-' + key + ' svg > .interface-label');
$(label).text(ifVals.name);
-
if(!myData[key][0].first) {
-
- var trafficIn = ((ifVals[0].values[1] * size) - latest[ifVals[0].key]) / refreshInterval;
- var trafficOut = ((ifVals[1].values[1] * size) - latest[ifVals[1].key]) / refreshInterval;
+ var trafficIn = ((ifVals[0].values[1] * size) - latest[ifVals[0].key]) / timeDiff;
+ var trafficOut = ((ifVals[1].values[1] * size) - latest[ifVals[1].key]) / timeDiff;
if((localStorage.getItem('invert') === "true")) {
trafficOut = 0 - trafficOut;
}
myData[key][0].values.push({
- x: now.getTime(),
+ x: xtime,
y: trafficIn
});
myData[key][1].values.push({
- x: now.getTime(),
+ x: xtime,
y: trafficOut
});
} else {
myData[key][0].values.push({
- x: now.getTime(),
+ x: xtime,
y: 0
});
myData[key][1].values.push({
- x: now.getTime(),
+ x: xtime,
y: 0
});
}
OpenPOWER on IntegriCloud