(function($){var options={};function init(plot){var ticks=[];var font;var secondPass=false;var rotateTicks,rotateTicksRads,radsAboveHoriz;plot.hooks.draw.push(function(plot,ctx){if(!secondPass){var opts=plot.getAxes().xaxis.options;if(opts.rotateTicks===undefined){return}rotateTicks=parseInt(opts.rotateTicks,10);if(rotateTicks.toString()!=opts.rotateTicks||rotateTicks==0||rotateTicks>=180){return}rotateTicksRads=rotateTicks*Math.PI/180;if(rotateTicks>90){radsAboveHoriz=Math.PI-rotateTicksRads}else{radsAboveHoriz=Math.PI/2-rotateTicksRads}font=opts.rotateTicksFont;if(!font){font=$(".tickLabel").css("font")}if(!font){font="smaller sans-serif"}var elem,maxLabelWidth=0,maxLabelHeight=0,minX=0,maxX=0;var xaxis=plot.getAxes().xaxis;ticks=plot.getAxes().xaxis.ticks;opts.ticks=[];var x;for(var i=0;i'+ticks[i].label+"");plot.getPlaceholder().append(elem);ticks[i].height=elem.outerHeight(true);ticks[i].width=elem.outerWidth(true);elem.remove();if(ticks[i].height>maxLabelHeight){maxLabelHeight=ticks[i].height}if(ticks[i].width>maxLabelWidth){maxLabelWidth=ticks[i].width}var tick=ticks[i];if(rotateTicks>90){x=Math.round(plot.getPlotOffset().left+xaxis.p2c(tick.v))-Math.ceil(Math.cos(radsAboveHoriz)*tick.height)-Math.ceil(Math.cos(radsAboveHoriz)*tick.width);if(xmaxX){maxX=x}}}if(rotateTicks>90){var acuteRads=rotateTicksRads-Math.PI/2;opts.labelHeight=Math.ceil(Math.sin(acuteRads)*maxLabelWidth)+Math.ceil(Math.sin(acuteRads)*maxLabelHeight)}else{var acuteRads=Math.PI/2-rotateTicksRads;opts.labelHeight=Math.ceil(Math.sin(rotateTicksRads)*maxLabelWidth)+Math.ceil(Math.sin(acuteRads)*maxLabelHeight)}if(minX<0){plot.getAxes().yaxis.options.labelWidth=-1*minX}secondPass=true;plot.setupGrid();plot.draw()}else{if(ticks.length==0){return}var xaxis=plot.getAxes().xaxis;var box=xaxis.box;var tick,label,xoffset,yoffset;for(var i=0;i