(function(e){e.jqplot.DateAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this);this.date=new e.jsDate};var l=30.4368499*864E5,n=365.242199*864E5,p=["%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"],m=[100,200,500,1E3,2E3,5E3,1E4,15E3,3E4,6E4,12E4,3E5,6E5,9E5,18E5,36E5,72E5,144E5,216E5,288E5,
432E5,864E5,1728E5,2592E5,3456E5,432E6,6048E5,12096E5];e.jqplot.DateAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer;e.jqplot.DateAxisRenderer.prototype.constructor=e.jqplot.DateAxisRenderer;e.jqplot.DateTickFormatter=function(d,j){d||(d="%Y/%m/%d");return e.jsDate.strftime(j,d)};e.jqplot.DateAxisRenderer.prototype.init=function(d){this.tickOptions.formatter=e.jqplot.DateTickFormatter;this.tickInset=0;this.drawBaseline=true;this._daTickInterval=this.daTickInterval=this.baselineColor=this.baselineWidth=
null;e.extend(true,this,d);d=this._dataBounds;for(var j,k,c,g,a,f,h,i=0;i<this._series.length;i++){j={intervals:[],frequencies:{},sortedIntervals:[],min:null,max:null,mean:null};k=0;c=this._series[i];g=c.data;a=c._plotData;f=c._stackData;for(var b=h=0;b<g.length;b++){if(this.name=="xaxis"||this.name=="x2axis"){g[b][0]=(new e.jsDate(g[b][0])).getTime();a[b][0]=(new e.jsDate(g[b][0])).getTime();f[b][0]=(new e.jsDate(g[b][0])).getTime();if(g[b][0]!=null&&g[b][0]<d.min||d.min==null)d.min=g[b][0];if(g[b][0]!=
null&&g[b][0]>d.max||d.max==null)d.max=g[b][0];if(b>0){h=Math.abs(g[b][0]-g[b-1][0]);j.intervals.push(h);if(j.frequencies.hasOwnProperty(h))j.frequencies[h]+=1;else j.frequencies[h]=1}k+=h}else{g[b][1]=(new e.jsDate(g[b][1])).getTime();a[b][1]=(new e.jsDate(g[b][1])).getTime();f[b][1]=(new e.jsDate(g[b][1])).getTime();if(g[b][1]!=null&&g[b][1]<d.min||d.min==null)d.min=g[b][1];if(g[b][1]!=null&&g[b][1]>d.max||d.max==null)d.max=g[b][1];if(b>0){h=Math.abs(g[b][1]-g[b-1][1]);j.intervals.push(h);if(j.frequencies.hasOwnProperty(h))j.frequencies[h]+=
1;else j.frequencies[h]=1}}k+=h}if(c.renderer.bands){if(c.renderer.bands.hiData.length){a=c.renderer.bands.hiData;b=0;for(f=a.length;b<f;b++)if(this.name==="xaxis"||this.name==="x2axis"){a[b][0]=(new e.jsDate(a[b][0])).getTime();if(a[b][0]!=null&&a[b][0]>d.max||d.max==null)d.max=a[b][0]}else{a[b][1]=(new e.jsDate(a[b][1])).getTime();if(a[b][1]!=null&&a[b][1]>d.max||d.max==null)d.max=a[b][1]}}if(c.renderer.bands.lowData.length){a=c.renderer.bands.lowData;b=0;for(f=a.length;b<f;b++)if(this.name==="xaxis"||
this.name==="x2axis"){a[b][0]=(new e.jsDate(a[b][0])).getTime();if(a[b][0]!=null&&a[b][0]<d.min||d.min==null)d.min=a[b][0]}else{a[b][1]=(new e.jsDate(a[b][1])).getTime();if(a[b][1]!=null&&a[b][1]<d.min||d.min==null)d.min=a[b][1]}}}for(var o in j.frequencies)j.sortedIntervals.push({interval:o,frequency:j.frequencies[o]});j.sortedIntervals.sort(function(q,r){return r.frequency-q.frequency});j.min=e.jqplot.arrayMin(j.intervals);j.max=e.jqplot.arrayMax(j.intervals);j.mean=k/g.length;this._intervalStats.push(j);
j=k=c=g=a=f=null}d=null};e.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="";if(this._overrideFormatString&&this.tickOptions&&this.tickOptions.formatString)this.tickOptions.formatString="";this.daTickInterval=this._daTickInterval};e.jqplot.DateAxisRenderer.prototype.createTicks=function(d){var j=this.ticks,k=this.name,c=this._dataBounds,
g=this.name.charAt(0)==="x"?this._plotDimensions.width:this._plotDimensions.height,a,f,h=1;a=this.min!=null?(new e.jsDate(this.min)).getTime():c.min;c=this.max!=null?(new e.jsDate(this.max)).getTime():c.max;if((d=d.plugins.cursor)&&d._zoom&&d._zoom.zooming)this.max=this.min=null;d=c-a;if(this.tickOptions==null||!this.tickOptions.formatString)this._overrideFormatString=true;if(j.length){for(c=0;c<j.length;c++){f=j[c];a=new this.tickRenderer(this.tickOptions);if(f.constructor==Array){a.value=(new e.jsDate(f[0])).getTime();
a.label=f[1]}else a.value=(new e.jsDate(f)).getTime();if(this.showTicks){if(!this.showTickMarks)a.showMark=false}else{a.showLabel=false;a.showMark=false}a.setTick(a.value,this.name);this._ticks.push(a)}this.numberTicks=j.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(this.min==null&&this.max==null){h=e.extend(true,{},this.tickOptions,{name:this.name,value:null});var i;if(!this.tickInterval&&
!this.numberTicks){i=Math.max(g,31);g=115;if(this.tickRenderer===e.jqplot.CanvasAxisTickRenderer&&this.tickOptions.angle)g=115-40*Math.abs(Math.sin(this.tickOptions.angle/180*Math.PI));i=Math.ceil((i-30)/g+1);i=(c-a)/(i-1)}else if(this.tickInterval)i=this.tickInterval;else if(this.numberTicks){i=this.numberTicks;i=(c-a)/(i-1)}if(i<=16416E5){var b;g=Number.MAX_VALUE;k=0;for(d=m.length;k<d;k++){j=Math.abs(i-m[k]);if(j<g){g=j;f=m[k];b=p[k]}}b=[f,b];f=b[0];this._autoFormatString=b[1];a=Math.floor(a/f)*
f;a=new e.jsDate(a);a=a.getTime()+a.getUtcOffset();i=Math.ceil((c-a)/f)+1;this.min=a;this.max=a+(i-1)*f;if(this.max<c){this.max+=f;i+=1}this.tickInterval=f;this.numberTicks=i;for(c=0;c<i;c++){h.value=this.min+c*f;a=new this.tickRenderer(h);if(this._overrideFormatString&&this._autoFormatString!="")a.formatString=this._autoFormatString;if(this.showTicks){if(!this.showTickMarks)a.showMark=false}else{a.showLabel=false;a.showMark=false}this._ticks.push(a)}h=this.tickInterval}else if(i<=9*l){this._autoFormatString=
"%v";f=Math.round(i/l);if(f<1)f=1;else if(f>6)f=6;b=(new e.jsDate(a)).setDate(1).setHours(0,0,0,0);a=new e.jsDate(c);c=(new e.jsDate(c)).setDate(1).setHours(0,0,0,0);if(a.getTime()!==c.getTime())c=c.add(1,"month");c=c.diff(b,"month");i=Math.ceil(c/f)+1;this.min=b.getTime();this.max=b.clone().add((i-1)*f,"month").getTime();this.numberTicks=i;for(c=0;c<i;c++){h.value=c===0?b.getTime():b.add(f,"month").getTime();a=new this.tickRenderer(h);if(this._overrideFormatString&&this._autoFormatString!="")a.formatString=
this._autoFormatString;if(this.showTicks){if(!this.showTickMarks)a.showMark=false}else{a.showLabel=false;a.showMark=false}this._ticks.push(a)}h=f*l}else{this._autoFormatString="%v";f=Math.round(i/n);if(f<1)f=1;b=(new e.jsDate(a)).setMonth(0,1).setHours(0,0,0,0);c=(new e.jsDate(c)).add(1,"year").setMonth(0,1).setHours(0,0,0,0);c=c.diff(b,"year");i=Math.ceil(c/f)+1;this.min=b.getTime();this.max=b.clone().add((i-1)*f,"year").getTime();this.numberTicks=i;for(c=0;c<i;c++){h.value=c===0?b.getTime():b.add(f,
"year").getTime();a=new this.tickRenderer(h);if(this._overrideFormatString&&this._autoFormatString!="")a.formatString=this._autoFormatString;if(this.showTicks){if(!this.showTickMarks)a.showMark=false}else{a.showLabel=false;a.showMark=false}this._ticks.push(a)}h=f*n}}else{g=k=="xaxis"||k=="x2axis"?this._plotDimensions.width:this._plotDimensions.height;if(this.min!=null&&this.max!=null&&this.numberTicks!=null)this.tickInterval=null;if(this.tickInterval!=null)if(Number(this.tickInterval))this.daTickInterval=
[Number(this.tickInterval),"seconds"];else if(typeof this.tickInterval=="string"){h=this.tickInterval.split(" ");if(h.length==1)this.daTickInterval=[1,h[0]];else if(h.length==2)this.daTickInterval=[h[0],h[1]]}if(a==c){a-=432E5;c+=432E5}d=c-a;parseInt(Math.max(0,g-100)/100,10);a=this.min!=null?(new e.jsDate(this.min)).getTime():a-d/2*(this.padMin-1);c=this.max!=null?(new e.jsDate(this.max)).getTime():c+d/2*(this.padMax-1);this.min=a;this.max=c;d=this.max-this.min;if(this.numberTicks==null)if(this.daTickInterval!=
null){c=(new e.jsDate(this.max)).diff(this.min,this.daTickInterval[1],true);this.numberTicks=Math.ceil(c/this.daTickInterval[0])+1;this.max=(new e.jsDate(this.min)).add((this.numberTicks-1)*this.daTickInterval[0],this.daTickInterval[1]).getTime()}else this.numberTicks=g>200?parseInt(3+(g-200)/100,10):2;h=d/(this.numberTicks-1)/1E3;if(this.daTickInterval==null)this.daTickInterval=[h,"seconds"];for(c=0;c<this.numberTicks;c++){a=new e.jsDate(this.min);f=a.add(c*this.daTickInterval[0],this.daTickInterval[1]).getTime();
a=new this.tickRenderer(this.tickOptions);if(this.showTicks){if(!this.showTickMarks)a.showMark=false}else{a.showLabel=false;a.showMark=false}a.setTick(f,this.name);this._ticks.push(a)}}if(this.tickInset){this.min-=this.tickInset*h;this.max+=this.tickInset*h}if(this._daTickInterval==null)this._daTickInterval=this.daTickInterval}})(jQuery);
