Commit 6f1c4ebb authored by SteffTek's avatar SteffTek

Update networkUsage.js

parent fba85fd5
......@@ -2,14 +2,14 @@ var ctx = document.getElementById("network").getContext('2d');
var networkChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['','',''],
labels: [''],
datasets: [{
label: 'In Going',
backgroundColor: "rgba(255, 99, 99, 0)",
steppedLine: false,
borderColor: "rgba(255, 99, 132, 0.2)",
pointBorderColor: "rgba(255, 99, 99, 0)",
data: [1,1,1],
data: [0,0],
fill: false
},{
label: 'Out Going',
......@@ -17,7 +17,7 @@ var networkChart = new Chart(ctx, {
steppedLine: false,
borderColor: "rgba(54, 162, 235, 0.2)",
pointBorderColor: "rgba(54, 162, 235, 0)",
data: [2,2,2],
data: [0,0],
fill: false
}]
},
......@@ -34,7 +34,7 @@ var networkChart = new Chart(ctx, {
display: true,
scaleLabel: {
display: true,
labelString: 'KBit/s'
labelString: 'KByte/s'
},
ticks: {
beginAtZero:true
......@@ -69,6 +69,8 @@ var bandwidth_rx = 0;
var bandwidth_tx = 0;
setInterval(function(){
networkChart.data.labels.push("");
$.get("https://dev.stefftek.de/backend/network.php?get=rx", function( text_var ) {
var recived = parseInt(text_var);
if(last_rx != 0){
......@@ -76,7 +78,6 @@ setInterval(function(){
bandwidth_rx = (recived - last_rx) / 1000;
last_rx = recived;
networkChart.data.labels.push("");
networkChart.data.datasets[0].data.push(bandwidth_rx);
networkChart.update();
} else {
......@@ -90,11 +91,10 @@ setInterval(function(){
bandwidth_tx = (recived - last_tx) / 1000;
last_tx = recived;
networkChart.data.labels.push("");
networkChart.data.datasets[1].data.push(bandwidth_tx);
networkChart.update();
} else {
last_tx = recived;
}
}, 'text');
}, 1000);
}, 1000);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment