From 63918ef410a18bfe8fc3f46d1ead3c30eeb1aeeb Mon Sep 17 00:00:00 2001 From: kanoi Date: Wed, 18 Mar 2015 02:14:03 +1100 Subject: [PATCH] php - add display options to the graph --- html/can.js | 19 +++++++++++-------- pool/page.php | 1 + pool/page_usperf.php | 12 +++++++++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/html/can.js b/html/can.js index a6c43794..032e8c65 100644 --- a/html/can.js +++ b/html/can.js @@ -15,6 +15,7 @@ function glwr(c,rat){c['ctx'].lineWidth*=rat} function gfz(c,x,y,ox,oy,t,co,a){gfs(c,co);c['ctx'].textAlign=a;c['ctx'].fillText(t,gchx(c,x)+ox,gchy(c,y)-oy)} function gbe(c,x,y){c['ctx'].beginPath();c['ctx'].moveTo(gchx(c,x),gchy(c,y))} function gln(c,x,y){c['ctx'].lineTo(gchx(c,x),gchy(c,y))} +function gct(c,x1,y1,x2,y2,x3,y3){c['ctx'].bezierCurveTo(gchx(c,x1),gchy(c,y1),gchx(c,x2),gchy(c,y2),gchx(c,x3),gchy(c,y3))} function glm(c,x,y){c['ctx'].moveTo(gchx(c,x),gchy(c,y))} function gle(c){c['ctx'].closePath()} function gfl(c){c['ctx'].fill()} @@ -26,16 +27,17 @@ gtso(c,xs,ys); gss(c,'black');glw(c,0.2); gbe(c,0,1);gln(c,0,0);gln(c,1,0);gst(c); glw(c,0.01); -var hi=c['ctx'].measureText('M').width; -var wi=c['ctx'].measureText('1').width; +var hi=c['ctx'].measureText('M').width, wi=c['ctx'].measureText('1').width; for(var i=0;i<11;i++){var y=i/10.0;gbe(c,-0.01,y);gln(c,1,y);gst(c);var t=''+(((y1-y0)*i/10+y0).toFixed(2));gfz(c,0,y,-wi,0,t,'black','end')} gfz(c,gx0(c),0.55,wi,0,yt,'#0080ff','left'); var m=Math.round(0.5+xn/20.0); var f=1; -for(var i=0;ic['xm']){c['ym']=c['xm']}c['xo']=0.0;c['yo']=0.0;c['ctx']=c['can'].getContext('2d');c['ctx'].canvas.width=c['xm']+1;c['ctx'].canvas.height=c['ym']+1;div.appendChild(c['can']);c['ok']=ok} -function gdrw(ok,d){var c={};gc(c,ok); +function gc(c){var div=document.getElementById('can0');while(div.firstChild){div.removeChild(div.firstChild)}c['can']=document.createElement('canvas');c['can'].id='can';c['wx']=window.innerWidth;c['wy']=window.innerHeight;c['xm']=Math.round(c['wx']*0.9+0.5);c['ym']=Math.round(c['wy']*0.8+0.5);if(c['ym']>c['xm']){c['ym']=c['xm']}c['xo']=0.0;c['yo']=0.0;c['ctx']=c['can'].getContext('2d');c['ctx'].canvas.width=c['xm']+1;c['ctx'].canvas.height=c['ym']+1;div.appendChild(c['can']);div=document.getElementById('smooth');c['smooth']=(div&&div.checked);div=document.getElementById('vlines');c['vlines']=(div&&div.checked);div=document.getElementById('zerob');c['zerob']=(div&&div.checked)} +function gdrw(d){var c={};gc(c); gfs(c,'white');gss(c,'#0000c0');glw(c,0.5);gbd(c); -var rows=d['rows'];var ymin=-1;var ymax=0;var xmin=-1;var xmax=0; +var rows=d['rows'],ymin=-1,ymax=0,xmin=-1,xmax=0; var tda=0; for(var i=0;iths){ymin=ths}if(ths>ymax)ymax=ths;d['nx:'+i]=sn(i,d['shift:'+i]);if(xmin==-1||xmin>s){xmin=s}if(xmax