diff options
author | Stephan Schwaer | 2016-03-15 17:13:47 +0100 |
---|---|---|
committer | Stephan Schwaer | 2016-03-15 17:13:47 +0100 |
commit | a98c7d78eb78419e765a19909744ddfb8c893569 (patch) | |
tree | 6487e119c343a9cadc3d922c37695220117ffca3 /static | |
parent | Fixed typo in calculation. (diff) | |
download | dnbd3-status-a98c7d78eb78419e765a19909744ddfb8c893569.tar.gz dnbd3-status-a98c7d78eb78419e765a19909744ddfb8c893569.tar.xz dnbd3-status-a98c7d78eb78419e765a19909744ddfb8c893569.zip |
Fix for download rate.
Diffstat (limited to 'static')
-rw-r--r-- | static/status-dnbd3.html | 86 |
1 files changed, 47 insertions, 39 deletions
diff --git a/static/status-dnbd3.html b/static/status-dnbd3.html index 6b4e68d..c3313b2 100644 --- a/static/status-dnbd3.html +++ b/static/status-dnbd3.html @@ -151,47 +151,55 @@ function myGraph(el) { // calculate download rate for clients and color links. if (link.lastTimestamp != 0) { - var maxIntensitiy = 50000; - - link.downloadRate = ((edge.received - link.lastReceived) / (timestamp - lastTime)) *4; - - // link.downloadRate = 30000; - // fading speed - var fadingValue = (link.colorIntensity*0,85) + 100; - if (fadingValue > 0) link.colorIntensity -= fadingValue; - - if (link.colorIntensity < 0) link.colorIntensity = 0; - link.colorIntensity += link.downloadRate; - if (link.colorIntensity >= maxIntensitiy) link.colorIntensity = maxIntensitiy; - - var red, green, blue; - // Green colors between 0 - 1 MB/s - if( link.colorIntensity <= 1000 ) { - // if(link.downloadRate > 1) { - // console.log("downloadRate: " + link.downloadRate); - // console.log("Intensity: " + link.colorIntensity); - // } - - // Blending idle (blue) and active (green) color - var factor = link.colorIntensity / 1000; //Math.log(link.colorIntensity+1) / Math.log(maxIntensitiy); - var cFactor = 1 - factor; - - red = cFactor * idleColor.r + factor * activeColor.r; - green = cFactor * idleColor.g + factor * activeColor.g; - blue = cFactor * idleColor.b + factor * activeColor.b; - } else { // Over 1MB/s - - // Blending active (green) and peak (red) color - var factor = (link.colorIntensity - 1000)/ 49000; //Math.log(link.colorIntensity+1) / Math.log(maxIntensitiy); - var cFactor = 1 - factor; + var maxIntensity = 50000; + + if(timestamp - lastTime > 0) { + link.downloadRate = ((edge.received - link.lastReceived) / (timestamp - lastTime)) * 4 * 1000; + if(link.downloadRate < 0) link.downloadRate = 0; + + // link.downloadRate = 30000; + // fading speed + var fadingValue = (link.colorIntensity*0.15) + 100; + link.colorIntensity -= fadingValue; + if (link.colorIntensity < 0) link.colorIntensity = 0; + + + + link.colorIntensity += link.downloadRate; + if (link.colorIntensity >= maxIntensity) link.colorIntensity = maxIntensity; + console.log(link.downloadRate) + var red, green, blue; + // Green colors between 0 - 1 MB/s - red = cFactor * activeColor.r + factor * peakColor.r; - green = cFactor * activeColor.g + factor * peakColor.g; - blue = cFactor * activeColor.b + factor * peakColor.b; - + if( link.colorIntensity <= 1000 ) { + + // if(link.downloadRate > 1) { + // console.log("downloadRate: " + link.downloadRate); + // console.log("Intensity: " + link.colorIntensity); + // } + + // Blending idle (blue) and active (green) color + var factor = link.colorIntensity / 1000; //Math.log(link.colorIntensity+1) / Math.log(maxIntensity); + var cFactor = 1 - factor; + + red = cFactor * idleColor.r + factor * activeColor.r; + green = cFactor * idleColor.g + factor * activeColor.g; + blue = cFactor * idleColor.b + factor * activeColor.b; + } else { // Over 1MB/s + console.log(link.colorIntensity) + + // Blending active (green) and peak (red) color + var factor = (link.colorIntensity - 1000)/ (maxIntensity - 1000); //Math.log(link.colorIntensity+1) / Math.log(maxIntensity); + var cFactor = 1 - factor; + + red = cFactor * activeColor.r + factor * peakColor.r; + green = cFactor * activeColor.g + factor * peakColor.g; + blue = cFactor * activeColor.b + factor * peakColor.b; + console.log(" " + red + " " + " " + green + " " + " " + blue) + } + //console.log(" " + red + " " + " " + green + " " + " " + blue) + link.color = "rgb("+ Math.floor(red) + ", " + Math.floor(green) + ", " + Math.floor(blue) + ")"; } - //console.log(" " + red + " " + " " + green + " " + " " + blue) - link.color = "rgb("+ Math.floor(red) + ", " + Math.floor(green) + ", " + Math.floor(blue) + ")"; } else { link['downloadRate'] = 0; |