Removed unused plugins, added axis labels

Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
This commit is contained in:
Roman Schmerold (BNoiZe)
2013-12-27 15:00:38 +01:00
parent 5cb0256a58
commit f3b61ce87c
3 changed files with 34 additions and 54 deletions

View File

@@ -1,41 +0,0 @@
/* The MIT License
Copyright (c) 2011 by Michael Zinsmaier and nergal.dev
Copyright (c) 2012 by Thomas Ritou
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
(function($){var options={series:{curvedLines:{active:false,apply:false,fit:false,curvePointFactor:20,fitPointDist:undefined}}};function init(plot){plot.hooks.processOptions.push(processOptions);function processOptions(plot,options){if(options.series.curvedLines.active){plot.hooks.processDatapoints.unshift(processDatapoints);}}
function processDatapoints(plot,series,datapoints){var nrPoints=datapoints.points.length/datapoints.pointsize;var EPSILON=0.5;if(series.curvedLines.apply==true&&series.originSeries===undefined&&nrPoints>(1+EPSILON)){if(series.lines.fill){var pointsTop=calculateCurvePoints(datapoints,series.curvedLines,1),pointsBottom=calculateCurvePoints(datapoints,series.curvedLines,2);datapoints.pointsize=3;datapoints.points=[];var j=0;var k=0;var i=0;var ps=2;while(i<pointsTop.length||j<pointsBottom.length){if(pointsTop[i]==pointsBottom[j]){datapoints.points[k]=pointsTop[i];datapoints.points[k+1]=pointsTop[i+1];datapoints.points[k+2]=pointsBottom[j+1];j+=ps;i+=ps;}else if(pointsTop[i]<pointsBottom[j]){datapoints.points[k]=pointsTop[i];datapoints.points[k+1]=pointsTop[i+1];datapoints.points[k+2]=k>0?datapoints.points[k-1]:null;i+=ps;}else{datapoints.points[k]=pointsBottom[j];datapoints.points[k+1]=k>1?datapoints.points[k-2]:null;datapoints.points[k+2]=pointsBottom[j+1];j+=ps;}
k+=3;}
if(series.lines.lineWidth>0){var newSerie=$.extend({},series);newSerie.lines=$.extend({},series.lines);newSerie.lines.fill=undefined;newSerie.label=undefined;newSerie.datapoints=$.extend({},series.datapoints);newSerie.datapoints.points=pointsTop;newSerie.datapoints.pointsize=2;newSerie.curvedLines.apply=false;var allSeries=plot.getData();for(i=0;i<allSeries.length;i++){if(allSeries[i]==series){plot.getData().splice(i+1,0,newSerie);break;}}
series.lines.lineWidth=0;}}else if(series.lines.lineWidth>0){datapoints.points=calculateCurvePoints(datapoints,series.curvedLines,1);datapoints.pointsize=2;}}}
function calculateCurvePoints(datapoints,curvedLinesOptions,yPos){var points=datapoints.points,ps=datapoints.pointsize;var num=curvedLinesOptions.curvePointFactor*(points.length/ps);var xdata=new Array;var ydata=new Array;var X=0;var Y=yPos;var curX=-1;var curY=-1;var j=0;if(curvedLinesOptions.fit){var fpDist;if(typeof curvedLinesOptions.fitPointDist=='undefined'){var minX=points[0];var maxX=points[points.length-ps];fpDist=(maxX-minX)/(500*100);}else{fpDist=curvedLinesOptions.fitPointDist;}
for(var i=0;i<points.length;i+=ps){var front=new Array;var back=new Array;curX=i;curY=i+yPos;front[X]=points[curX]-fpDist;back[X]=points[curX]+fpDist;var factor=2;while(front[X]==points[curX]||back[X]==points[curX]){front[X]=points[curX]-(fpDist*factor);back[X]=points[curX]+(fpDist*factor);factor++;}
back[Y]=points[curY];front[Y]=points[curY];var frontPointY=points[curY];var backPointY=points[curY];if(i>=ps){frontPointY=points[curY-ps];}
if((i+ps)<points.length){backPointY=points[curY+ps];}
if((frontPointY<=points[curY]&&backPointY<=points[curY])||(frontPointY>=points[curY]&&backPointY>=points[curY])){xdata[j]=front[X];ydata[j]=front[Y];j++;xdata[j]=points[curX];ydata[j]=points[curY];j++;xdata[j]=back[X];ydata[j]=back[Y];j++;}else{xdata[j]=points[curX];ydata[j]=points[curY];j++;}}}else{for(var i=0;i<points.length;i+=ps){curX=i;curY=i+yPos;xdata[j]=points[curX];ydata[j]=points[curY];j++;}}
var n=xdata.length;var y2=new Array();var delta=new Array();y2[0]=0;y2[n-1]=0;delta[0]=0;for(var i=1;i<n-1;++i){var d=(xdata[i+1]-xdata[i-1]);if(d==0){return[];}
var s=(xdata[i]-xdata[i-1])/d;var p=s*y2[i-1]+2;y2[i]=(s-1)/p;delta[i]=(ydata[i+1]-ydata[i])/(xdata[i+1]-xdata[i])-(ydata[i]-ydata[i-1])/(xdata[i]-xdata[i-1]);delta[i]=(6*delta[i]/(xdata[i+1]-xdata[i-1])-s*delta[i-1])/p;}
for(var j=n-2;j>=0;--j){y2[j]=y2[j]*y2[j+1]+delta[j];}
var step=(xdata[n-1]-xdata[0])/(num-1);var xnew=new Array;var ynew=new Array;var result=new Array;xnew[0]=xdata[0];ynew[0]=ydata[0];result.push(xnew[0]);result.push(ynew[0]);for(j=1;j<num;++j){xnew[j]=xnew[0]+j*step;var max=n-1;var min=0;while(max-min>1){var k=Math.round((max+min)/2);if(xdata[k]>xnew[j]){max=k;}else{min=k;}}
var h=(xdata[max]-xdata[min]);if(h==0){return[];}
var a=(xdata[max]-xnew[j])/h;var b=(xnew[j]-xdata[min])/h;ynew[j]=a*ydata[min]+b*ydata[max]+((a*a*a-a)*y2[min]+(b*b*b-b)*y2[max])*(h*h)/6;result.push(xnew[j]);result.push(ynew[j]);}
return result;}}
$.plot.plugins.push({init:init,options:options,name:'curvedLines',version:'0.5'});})(jQuery);

View File

@@ -5,6 +5,7 @@ $(document).ready(function() {
var ftp = [];
var http = [];
var mail = [];
var ticks = [];
var i = 1;
var links = [];
$('#datatable tbody tr').reverse().each(function() {
@@ -14,6 +15,9 @@ $(document).ready(function() {
var maild = $(row).children().first().next().next().next().text();
if ($(row).children().first().find("a").length > 0) {
links.push($(row).children().first().html());
ticks.push([i, $(row).children().first().find("a").html().split(" ")[0]]);
} else {
ticks.push([i, $(row).children().first().html()]);
}
ftp.push([i, parseFloat(ftpd / 1024)]);
http.push([i, parseFloat(httpd / 1024)]);
@@ -39,25 +43,31 @@ $(document).ready(function() {
var ftpdata = [{
label: 'FTP',
data: ftp,
color: '#019522'
color: '#1db34f'
}];
var httpdata = [{
label: 'HTTP',
data: http,
color: '#0000FF'
color: '#0a90d8'
}];
var maildata = [{
label: 'Mail',
data: mail,
color: '#800000'
color: '#f17f49'
}];
var options = {
series: {
shadowSize: 0
shadowSize: 0,
curvedLines: {
active: true,
apply: false,
fitPointDist: true
}
},
lines: {
show: true
show: true,
fill: true
},
points: {
radius: 2,
@@ -72,10 +82,13 @@ $(document).ready(function() {
},
xaxis: {
tickSize: 1,
tickLength: 0
tickLength: 0,
ticks: ticks,
labelAngle: 45
},
yaxis: {
tickColor: '#eee'
tickColor: '#eee',
min: 0
}
};

View File

@@ -5,6 +5,7 @@ $(document).ready(function() {
var ftp = [];
var http = [];
var mail = [];
var ticks = [];
var i = 1;
var links = [];
$('#datatable tbody tr').reverse().each(function() {
@@ -14,6 +15,9 @@ $(document).ready(function() {
var maild = $(row).children().first().next().next().next().text();
if ($(row).children().first().find("a").length > 0) {
links.push($(row).children().first().html());
ticks.push([i, $(row).children().first().find("a").html().split(" ")[0]]);
} else {
ticks.push([i, $(row).children().first().html()]);
}
ftp.push([i, parseFloat(ftpd / 1024)]);
http.push([i, parseFloat(httpd / 1024)]);
@@ -39,17 +43,17 @@ $(document).ready(function() {
var ftpdata = [{
label: 'FTP',
data: ftp,
color: '#019522'
color: '#1db34f'
}];
var httpdata = [{
label: 'HTTP',
data: http,
color: '#0000FF'
color: '#0a90d8'
}];
var maildata = [{
label: 'Mail',
data: mail,
color: '#800000'
color: '#f17f49'
}];
var options = {
@@ -62,7 +66,8 @@ $(document).ready(function() {
}
},
lines: {
show: true
show: true,
fill: true
},
points: {
radius: 2,
@@ -77,10 +82,13 @@ $(document).ready(function() {
},
xaxis: {
tickSize: 1,
tickLength: 0
tickLength: 0,
ticks: ticks,
labelAngle: 45
},
yaxis: {
tickColor: '#eee'
tickColor: '#eee',
min: 0
}
};