phpservermon/static/plugin/jqplot/jqplot.dateAxisRenderer.min.js

4 lines
9.1 KiB
JavaScript

/* jqplot 1.0.9 | (c) 2009-2016 Chris Leonello | jplot.com
jsDate | (c) 2010-2016 Chris Leonello
*/
!function(t){t.jqplot.DateAxisRenderer=function(){t.jqplot.LinearAxisRenderer.call(this),this.date=new t.jsDate};var i=36e5,e=24*i,s=7*e,n=30.4368499*e,a=365.242199*e,r=["%M:%S.%#N","%M:%S.%#N","%M:%S.%#N","%M:%S","%M:%S","%M:%S","%M:%S","%H:%M:%S","%H:%M:%S","%H:%M","%H:%M","%H:%M","%H:%M","%H:%M","%H:%M","%a %H:%M","%a %H:%M","%b %e %H:%M","%b %e %H:%M","%b %e %H:%M","%b %e %H:%M","%v","%v","%v","%v","%v","%v","%v"],h=[100,200,500,1e3,2e3,5e3,1e4,15e3,3e4,6e4,12e4,3e5,6e5,9e5,18e5,i,2*i,4*i,6*i,8*i,12*i,e,2*e,3*e,4*e,5*e,s,2*s];t.jqplot.DateAxisRenderer.prototype=new t.jqplot.LinearAxisRenderer,t.jqplot.DateAxisRenderer.prototype.constructor=t.jqplot.DateAxisRenderer,t.jqplot.DateTickFormatter=function(i,e){return i||(i="%Y/%m/%d"),t.jsDate.strftime(e,i)},t.jqplot.DateAxisRenderer.prototype.init=function(i){this.tickOptions.formatter=t.jqplot.DateTickFormatter,this.tickInset=0,this.drawBaseline=!0,this.baselineWidth=null,this.baselineColor=null,this.daTickInterval=null,this._daTickInterval=null,t.extend(!0,this,i);for(var e,s,n,a,r,h,l,o=this._dataBounds,m=0;m<this._series.length;m++){e={intervals:[],frequencies:{},sortedIntervals:[],min:null,max:null,mean:null},s=0,a=(n=this._series[m]).data,r=n._plotData,h=n._stackData,l=0;for(var c=0;c<a.length;c++)"xaxis"==this.name||"x2axis"==this.name?(a[c][0]=new t.jsDate(a[c][0]).getTime(),r[c][0]=new t.jsDate(a[c][0]).getTime(),h[c][0]=new t.jsDate(a[c][0]).getTime(),(null!=a[c][0]&&a[c][0]<o.min||null==o.min)&&(o.min=a[c][0]),(null!=a[c][0]&&a[c][0]>o.max||null==o.max)&&(o.max=a[c][0]),c>0&&(l=Math.abs(a[c][0]-a[c-1][0]),e.intervals.push(l),e.frequencies.hasOwnProperty(l)?e.frequencies[l]+=1:e.frequencies[l]=1),s+=l):(a[c][1]=new t.jsDate(a[c][1]).getTime(),r[c][1]=new t.jsDate(a[c][1]).getTime(),h[c][1]=new t.jsDate(a[c][1]).getTime(),(null!=a[c][1]&&a[c][1]<o.min||null==o.min)&&(o.min=a[c][1]),(null!=a[c][1]&&a[c][1]>o.max||null==o.max)&&(o.max=a[c][1]),c>0&&(l=Math.abs(a[c][1]-a[c-1][1]),e.intervals.push(l),e.frequencies.hasOwnProperty(l)?e.frequencies[l]+=1:e.frequencies[l]=1)),s+=l;if(n.renderer.bands){if(n.renderer.bands.hiData.length){c=0;for(var u=(k=n.renderer.bands.hiData).length;c<u;c++)"xaxis"===this.name||"x2axis"===this.name?(k[c][0]=new t.jsDate(k[c][0]).getTime(),(null!=k[c][0]&&k[c][0]>o.max||null==o.max)&&(o.max=k[c][0])):(k[c][1]=new t.jsDate(k[c][1]).getTime(),(null!=k[c][1]&&k[c][1]>o.max||null==o.max)&&(o.max=k[c][1]))}var k;if(n.renderer.bands.lowData.length)for(c=0,u=(k=n.renderer.bands.lowData).length;c<u;c++)"xaxis"===this.name||"x2axis"===this.name?(k[c][0]=new t.jsDate(k[c][0]).getTime(),(null!=k[c][0]&&k[c][0]<o.min||null==o.min)&&(o.min=k[c][0])):(k[c][1]=new t.jsDate(k[c][1]).getTime(),(null!=k[c][1]&&k[c][1]<o.min||null==o.min)&&(o.min=k[c][1]))}for(var d in e.frequencies)e.sortedIntervals.push({interval:d,frequency:e.frequencies[d]});e.sortedIntervals.sort(function(t,i){return i.frequency-t.frequency}),e.min=t.jqplot.arrayMin(e.intervals),e.max=t.jqplot.arrayMax(e.intervals),e.mean=s/a.length,this._intervalStats.push(e),e=s=n=a=r=h=null}o=null},t.jqplot.DateAxisRenderer.prototype.reset=function(){this.min=this._options.min,this.max=this._options.max,this.tickInterval=this._options.tickInterval,this.numberTicks=this._options.numberTicks,this._autoFormatString="",this._overrideFormatString&&this.tickOptions&&this.tickOptions.formatString&&(this.tickOptions.formatString=""),this.daTickInterval=this._daTickInterval},t.jqplot.DateAxisRenderer.prototype.createTicks=function(i){this._ticks;var s,l,o=this.ticks,m=this.name,c=this._dataBounds,u=(this._intervalStats,"x"===this.name.charAt(0)?this._plotDimensions.width:this._plotDimensions.height),k=1,d=null;if(null!=this.tickInterval)if(Number(this.tickInterval))d=[Number(this.tickInterval),"seconds"];else if("string"==typeof this.tickInterval){var v=this.tickInterval.split(" ");1==v.length?d=[1,v[0]]:2==v.length&&(d=[v[0],v[1]])}this.tickInterval,z=new t.jsDate(null!=this.min?this.min:c.min).getTime(),s=new t.jsDate(null!=this.max?this.max:c.max).getTime();var T=i.plugins.cursor;T&&T._zoom&&T._zoom.zooming&&(this.min=null,this.max=null);var g=s-z;if(null!=this.tickOptions&&this.tickOptions.formatString||(this._overrideFormatString=!0),o.length){for(p=0;p<o.length;p++){var w=o[p],x=new this.tickRenderer(this.tickOptions);w.constructor==Array?(x.value=new t.jsDate(w[0]).getTime(),x.label=w[1],this.showTicks?this.showTickMarks||(x.showMark=!1):(x.showLabel=!1,x.showMark=!1),x.setTick(x.value,this.name),this._ticks.push(x)):(x.value=new t.jsDate(w).getTime(),this.showTicks?this.showTickMarks||(x.showMark=!1):(x.showLabel=!1,x.showMark=!1),x.setTick(x.value,this.name),this._ticks.push(x))}this.numberTicks=o.length,this.min=this._ticks[0].value,this.max=this._ticks[this.numberTicks-1].value,this.daTickInterval=[(this.max-this.min)/(this.numberTicks-1)/1e3,"seconds"]}else if(null==this.min&&null==this.max&&c.min==c.max){var f=t.extend(!0,{},this.tickOptions,{name:this.name,value:null});this.min=c.min-3e5,this.max=c.max+3e5,this.numberTicks=3;for(var p=this.min;p<=this.max;p+=3e5)f.value=p,x=new this.tickRenderer(f),this._overrideFormatString&&""!=this._autoFormatString&&(x.formatString=this._autoFormatString),x.showLabel=!1,x.showMark=!1,this._ticks.push(x);this.showTicks&&(this._ticks[1].showLabel=!0),this.showTickMarks&&(this._ticks[1].showTickMarks=!0)}else if(null==this.min&&null==this.max){var M,_,D=t.extend(!0,{},this.tickOptions,{name:this.name,value:null});if(this.tickInterval||this.numberTicks)this.tickInterval?_=new t.jsDate(0).add(d[0],d[1]).getTime():this.numberTicks&&(_=(s-z)/((M=this.numberTicks)-1));else{var b=Math.max(u,31),j=115;this.tickRenderer===t.jqplot.CanvasAxisTickRenderer&&this.tickOptions.angle&&(j=115-40*Math.abs(Math.sin(this.tickOptions.angle/180*Math.PI))),_=(s-z)/((M=Math.ceil((b-30)/j+1))-1)}if(_<=19*e){var I=function(t,i,e){for(var s,n,a,l=Number.MAX_VALUE,o=0,m=h.length;o<m;o++)(s=Math.abs(e-h[o]))<l&&(l=s,n=h[o],a=r[o]);return[n,a]}(0,0,_),S=I[0];for(this._autoFormatString=I[1],z=new t.jsDate(z),z=Math.floor((z.getTime()-z.getUtcOffset())/S)*S+z.getUtcOffset(),M=Math.ceil((s-z)/S)+1,this.min=z,this.max=z+(M-1)*S,this.max<s&&(this.max+=S,M+=1),this.tickInterval=S,this.numberTicks=M,p=0;p<M;p++)D.value=this.min+p*S,x=new this.tickRenderer(D),this._overrideFormatString&&""!=this._autoFormatString&&(x.formatString=this._autoFormatString),this.showTicks?this.showTickMarks||(x.showMark=!1):(x.showLabel=!1,x.showMark=!1),this._ticks.push(x);k=this.tickInterval}else if(_<=9*n){this._autoFormatString="%v",(R=Math.round(_/n))<1?R=1:R>6&&(R=6);var q=new t.jsDate(z).setDate(1).setHours(0,0,0,0),F=new t.jsDate(s),y=new t.jsDate(s).setDate(1).setHours(0,0,0,0);F.getTime()!==y.getTime()&&(y=y.add(1,"month"));var H=y.diff(q,"month");for(M=Math.ceil(H/R)+1,this.min=q.getTime(),this.max=q.clone().add((M-1)*R,"month").getTime(),this.numberTicks=M,p=0;p<M;p++)D.value=0===p?q.getTime():q.add(R,"month").getTime(),x=new this.tickRenderer(D),this._overrideFormatString&&""!=this._autoFormatString&&(x.formatString=this._autoFormatString),this.showTicks?this.showTickMarks||(x.showMark=!1):(x.showLabel=!1,x.showMark=!1),this._ticks.push(x);k=R*n}else{var R;this._autoFormatString="%v",(R=Math.round(_/a))<1&&(R=1),q=new t.jsDate(z).setMonth(0,1).setHours(0,0,0,0);var O=(y=new t.jsDate(s).add(1,"year").setMonth(0,1).setHours(0,0,0,0)).diff(q,"year");for(M=Math.ceil(O/R)+1,this.min=q.getTime(),this.max=q.clone().add((M-1)*R,"year").getTime(),this.numberTicks=M,p=0;p<M;p++)D.value=0===p?q.getTime():q.add(R,"year").getTime(),x=new this.tickRenderer(D),this._overrideFormatString&&""!=this._autoFormatString&&(x.formatString=this._autoFormatString),this.showTicks?this.showTickMarks||(x.showMark=!1):(x.showLabel=!1,x.showMark=!1),this._ticks.push(x);k=R*a}}else{var A,L;if(u="xaxis"==m||"x2axis"==m?this._plotDimensions.width:this._plotDimensions.height,null!=this.min&&null!=this.max&&null!=this.numberTicks&&(this.tickInterval=null),null!=this.tickInterval&&null!=d&&(this.daTickInterval=d),z==s&&(z-=432e5,s+=432e5),g=s-z,parseInt(Math.max(0,u-100)/100,10),A=null!=this.min?new t.jsDate(this.min).getTime():z-g/2*(this.padMin-1),L=null!=this.max?new t.jsDate(this.max).getTime():s+g/2*(this.padMax-1),this.min=A,this.max=L,g=this.max-this.min,null==this.numberTicks)if(null!=this.daTickInterval){var N=new t.jsDate(this.max).diff(this.min,this.daTickInterval[1],!0);this.numberTicks=Math.ceil(N/this.daTickInterval[0])+1,this.max=new t.jsDate(this.min).add((this.numberTicks-1)*this.daTickInterval[0],this.daTickInterval[1]).getTime()}else this.numberTicks=u>200?parseInt(3+(u-200)/100,10):2;for(k=g/(this.numberTicks-1)/1e3,null==this.daTickInterval&&(this.daTickInterval=[k,"seconds"]),p=0;p<this.numberTicks;p++){var z;l=(z=new t.jsDate(this.min)).add(p*this.daTickInterval[0],this.daTickInterval[1]).getTime(),x=new this.tickRenderer(this.tickOptions),this.showTicks?this.showTickMarks||(x.showMark=!1):(x.showLabel=!1,x.showMark=!1),x.setTick(l,this.name),this._ticks.push(x)}}this.tickInset&&(this.min=this.min-this.tickInset*k,this.max=this.max+this.tickInset*k),null==this._daTickInterval&&(this._daTickInterval=this.daTickInterval)}}(jQuery);