(function(h){function n(a,e,b){var c=b.plugins.cursor,d="",f=false;if(c.showTooltipGridPosition){d=a.x+", "+a.y;f=true}if(c.showTooltipUnitPosition)for(var g,i=0;i<c.tooltipAxisGroups.length;i++){g=c.tooltipAxisGroups[i];if(f)d+="<br />";if(c.useAxesFormatters){var k=b.axes[g[0]]._ticks[0].formatter,l=b.axes[g[1]]._ticks[0].formatter,m=b.axes[g[0]]._ticks[0].formatString,j=b.axes[g[1]]._ticks[0].formatString;d+=k(m,e[g[0]])+", "+l(j,e[g[1]])}else d+=h.jqplot.sprintf(c.tooltipFormatString,e[g[0]],
e[g[1]]);f=true}if(c.showTooltipDataPosition){e=b.series;a=p(b,a.x,a.y);f=false;for(i=0;i<e.length;i++)if(e[i].show){l=e[i].index;b=e[i].label.toString();l=h.inArray(l,a.indices);j=k=undefined;if(l!=-1){g=a.data[l].data;if(c.useAxesFormatters){k=e[i]._xaxis._ticks[0].formatter;l=e[i]._yaxis._ticks[0].formatter;m=e[i]._xaxis._ticks[0].formatString;j=e[i]._yaxis._ticks[0].formatString;k=k(m,g[0]);j=l(j,g[1])}else{k=g[0];j=g[1]}if(f)d+="<br />";d+=h.jqplot.sprintf(c.tooltipFormatString,b,k,j);f=true}}}c._tooltipElem.html(d)}
function q(a,e){var b=e.plugins.cursor,c=b.cursorCanvas._ctx;c.clearRect(0,0,c.canvas.width,c.canvas.height);b.showVerticalLine&&b.shapeRenderer.draw(c,[[a.x,0],[a.x,c.canvas.height]]);b.showHorizontalLine&&b.shapeRenderer.draw(c,[[0,a.y],[c.canvas.width,a.y]]);c=p(e,a.x,a.y);if(b.showCursorLegend)for(var d=h(e.targetId+" td.jqplot-cursor-legend-label"),f=0;f<d.length;f++){var g=h(d[f]).data("seriesIndex"),i=e.series[g],k=i.label.toString(),l=h.inArray(g,c.indices),m=g=undefined;if(l!=-1){l=c.data[l].data;
if(b.useAxesFormatters){g=i._xaxis._ticks[0].formatter;m=i._yaxis._ticks[0].formatter;var j=i._yaxis._ticks[0].formatString;g=g(i._xaxis._ticks[0].formatString,l[0]);m=m(j,l[1])}else{g=l[0];m=l[1]}}e.legend.escapeHtml?h(d[f]).text(h.jqplot.sprintf(b.cursorLegendFormatString,k,g,m)):h(d[f]).html(h.jqplot.sprintf(b.cursorLegendFormatString,k,g,m))}}function p(a,e){var b={indices:[],data:[]},c,d,f,g,i,k=a.plugins.cursor;for(d=0;d<a.series.length;d++){c=a.series[d];if(c.show){i=k.intersectionThreshold;
if(c.showMarker)i+=c.markerRenderer.size/2;for(f=0;f<c.gridData.length;f++){g=c.gridData[f];if(k.showVerticalLine)if(Math.abs(e-g[0])<=i){b.indices.push(d);b.data.push({seriesIndex:d,pointIndex:f,gridData:g,data:c.data[f]})}}}}return b}function o(a,e){var b=e.plugins.cursor,c=b._tooltipElem;switch(b.tooltipLocation){case "nw":var d=a.x+e._gridPadding.left-c.outerWidth(true)-b.tooltipOffset;b=a.y+e._gridPadding.top-b.tooltipOffset-c.outerHeight(true);break;case "n":d=a.x+e._gridPadding.left-c.outerWidth(true)/
2;b=a.y+e._gridPadding.top-b.tooltipOffset-c.outerHeight(true);break;case "ne":d=a.x+e._gridPadding.left+b.tooltipOffset;b=a.y+e._gridPadding.top-b.tooltipOffset-c.outerHeight(true);break;case "e":d=a.x+e._gridPadding.left+b.tooltipOffset;b=a.y+e._gridPadding.top-c.outerHeight(true)/2;break;case "se":d=a.x+e._gridPadding.left+b.tooltipOffset;b=a.y+e._gridPadding.top+b.tooltipOffset;break;case "s":d=a.x+e._gridPadding.left-c.outerWidth(true)/2;b=a.y+e._gridPadding.top+b.tooltipOffset;break;case "sw":d=
a.x+e._gridPadding.left-c.outerWidth(true)-b.tooltipOffset;b=a.y+e._gridPadding.top+b.tooltipOffset;break;case "w":d=a.x+e._gridPadding.left-c.outerWidth(true)-b.tooltipOffset;b=a.y+e._gridPadding.top-c.outerHeight(true)/2;break;default:d=a.x+e._gridPadding.left+b.tooltipOffset;b=a.y+e._gridPadding.top+b.tooltipOffset}c.css("left",d);c.css("top",b)}function s(a,e,b,c,d){a.preventDefault();a.stopImmediatePropagation();a=d.plugins.cursor;a.clickReset&&a.resetZoom(d,a);d=window.getSelection;if(document.selection&&
document.selection.empty)document.selection.empty();else d&&!d().isCollapsed&&d().collapse();return false}function t(a,e,b,c,d){a.preventDefault();a.stopImmediatePropagation();a=d.plugins.cursor;a.dblClickReset&&a.resetZoom(d,a);d=window.getSelection;if(document.selection&&document.selection.empty)document.selection.empty();else d&&!d().isCollapsed&&d().collapse();return false}function u(a,e,b,c,d){c=d.plugins.cursor;c.onGrid=false;if(c.show){h(a.target).css("cursor",c.previousCursor);c.showTooltip&&
!(c._zoom.zooming&&c.showTooltipOutsideZoom&&!c.constrainOutsideZoom)&&c._tooltipElem.hide();if(c.zoom){c._zoom.gridpos=e;c._zoom.datapos=b}if(c.showVerticalLine||c.showHorizontalLine){a=c.cursorCanvas._ctx;a.clearRect(0,0,a.canvas.width,a.canvas.height)}if(c.showCursorLegend){a=h(d.targetId+" td.jqplot-cursor-legend-label");for(e=0;e<a.length;e++){b=h(a[e]).data("seriesIndex");b=d.series[b].label.toString();d.legend.escapeHtml?h(a[e]).text(h.jqplot.sprintf(c.cursorLegendFormatString,b,undefined,
undefined)):h(a[e]).html(h.jqplot.sprintf(c.cursorLegendFormatString,b,undefined,undefined))}}}}function v(a,e,b,c,d){c=d.plugins.cursor;c.onGrid=true;if(c.show){c.previousCursor=a.target.style.cursor;a.target.style.cursor=c.style;if(c.showTooltip){n(e,b,d);if(c.followMouse)o(e,d);else{var f=d._gridPadding,g=d.plugins.cursor;a=g._tooltipElem;switch(g.tooltipLocation){case "nw":b=f.left+g.tooltipOffset;f=f.top+g.tooltipOffset;a.css("left",b);a.css("top",f);break;case "n":b=(f.left+(d._plotDimensions.width-
f.right))/2-a.outerWidth(true)/2;f=f.top+g.tooltipOffset;a.css("left",b);a.css("top",f);break;case "ne":b=f.right+g.tooltipOffset;f=f.top+g.tooltipOffset;a.css({right:b,top:f});break;case "e":b=f.right+g.tooltipOffset;f=(f.top+(d._plotDimensions.height-f.bottom))/2-a.outerHeight(true)/2;a.css({right:b,top:f});break;case "se":b=f.right+g.tooltipOffset;f=f.bottom+g.tooltipOffset;a.css({right:b,bottom:f});break;case "s":b=(f.left+(d._plotDimensions.width-f.right))/2-a.outerWidth(true)/2;f=f.bottom+g.tooltipOffset;
a.css({left:b,bottom:f});break;case "sw":b=f.left+g.tooltipOffset;f=f.bottom+g.tooltipOffset;a.css({left:b,bottom:f});break;case "w":b=f.left+g.tooltipOffset;f=(f.top+(d._plotDimensions.height-f.bottom))/2-a.outerHeight(true)/2;a.css({left:b,top:f});break;default:b=f.right-g.tooltipOffset;f=f.bottom+g.tooltipOffset;a.css({right:b,bottom:f})}}c._tooltipElem.show()}if(c.showVerticalLine||c.showHorizontalLine)q(e,d)}}function w(a,e,b,c,d){a=d.plugins.cursor;if(a.show){if(a.showTooltip){n(e,b,d);a.followMouse&&
o(e,d)}if(a.showVerticalLine||a.showHorizontalLine)q(e,d)}}function r(a){var e=a.data.plot,b=e.plugins.cursor;if(b.show&&b.zoom&&b._zoom.started&&!b.zoomTarget){var c=b.zoomCanvas._ctx,d=a.data.plot,f=d.eventCanvas._elem.offset();a={x:a.pageX-f.left,y:a.pageY-f.top};var g={xaxis:null,yaxis:null,x2axis:null,y2axis:null,y3axis:null,y4axis:null,y5axis:null,y6axis:null,y7axis:null,y8axis:null,y9axis:null,yMidAxis:null},i=["xaxis","yaxis","x2axis","y2axis","y3axis","y4axis","y5axis","y6axis","y7axis",
"y8axis","y9axis","yMidAxis"];d=d.axes;var k,l;for(k=11;k>0;k--){l=i[k-1];if(d[l].show)g[l]=d[l].series_p2u(a[l.charAt(0)])}a={offsets:f,gridPos:a,dataPos:g};f=a.gridPos;a=a.dataPos;b._zoom.gridpos=f;b._zoom.datapos=a;b._zoom.zooming=true;g=f.x;i=f.y;d=c.canvas.height;c=c.canvas.width;if(b.showTooltip&&!b.onGrid&&b.showTooltipOutsideZoom){n(f,a,e);b.followMouse&&o(f,e)}b._zoom.end=b.constrainZoomTo=="x"?[g,d]:b.constrainZoomTo=="y"?[c,i]:[g,i];e=window.getSelection;if(document.selection&&document.selection.empty)document.selection.empty();
else e&&!e().isCollapsed&&e().collapse();x.call(b)}}function y(a,e,b,c,d){a=d.plugins.cursor;h(document).one("mouseup.jqplot_cursor",{plot:d},z);if(document.onselectstart!=undefined){a._oldHandlers.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!=undefined){a._oldHandlers.ondrag=document.ondrag;document.ondrag=function(){return false}}if(document.onmousedown!=undefined){a._oldHandlers.onmousedown=document.onmousedown;document.onmousedown=function(){return false}}if(a.zoom){if(!a.zoomProxy){c=
a.zoomCanvas._ctx;c.clearRect(0,0,c.canvas.width,c.canvas.height);c=null}a._zoom.start=a.constrainZoomTo=="x"?[e.x,0]:a.constrainZoomTo=="y"?[0,e.y]:[e.x,e.y];a._zoom.started=true;for(var f in b)a._zoom.axes.start[f]=b[f];h(document).bind("mousemove.jqplotCursor",{plot:d},r)}}function z(a){a=a.data.plot;var e=a.plugins.cursor;if(e.zoom&&e._zoom.zooming&&!e.zoomTarget){var b=e._zoom.gridpos.x,c=e._zoom.gridpos.y,d=e._zoom.datapos,f=e.zoomCanvas._ctx.canvas.height,g=e.zoomCanvas._ctx.canvas.width,i=
a.axes;if(e.constrainOutsideZoom&&!e.onGrid){if(b<0)b=0;else if(b>g)b=g;if(c<0)c=0;else if(c>f)c=f;for(var k in d)if(d[k])d[k]=k.charAt(0)=="x"?i[k].series_p2u(b):i[k].series_p2u(c)}if(e.constrainZoomTo=="x")c=f;else if(e.constrainZoomTo=="y")b=g;e._zoom.end=[b,c];e._zoom.gridpos={x:b,y:c};e.doZoom(e._zoom.gridpos,d,a,e)}e._zoom.started=false;e._zoom.zooming=false;h(document).unbind("mousemove.jqplotCursor",r);if(document.onselectstart!=undefined&&e._oldHandlers.onselectstart!=null){document.onselectstart=
e._oldHandlers.onselectstart;e._oldHandlers.onselectstart=null}if(document.ondrag!=undefined&&e._oldHandlers.ondrag!=null){document.ondrag=e._oldHandlers.ondrag;e._oldHandlers.ondrag=null}if(document.onmousedown!=undefined&&e._oldHandlers.onmousedown!=null){document.onmousedown=e._oldHandlers.onmousedown;e._oldHandlers.onmousedown=null}}function x(){var a=this._zoom.start,e=this._zoom.end,b=this.zoomCanvas._ctx,c,d,f;if(e[0]>a[0]){c=a[0];f=e[0]-a[0]}else{c=e[0];f=a[0]-e[0]}if(e[1]>a[1]){d=a[1];a=
e[1]-a[1]}else{d=e[1];a=a[1]-e[1]}b.fillStyle="rgba(0,0,0,0.2)";b.strokeStyle="#999999";b.lineWidth=1;b.clearRect(0,0,b.canvas.width,b.canvas.height);b.fillRect(0,0,b.canvas.width,b.canvas.height);b.clearRect(c,d,f,a);b.strokeRect(c,d,f,a)}h.jqplot.Cursor=function(a){this.style="crosshair";this.previousCursor="auto";this.show=h.jqplot.config.enablePlugins;this.showTooltip=true;this.followMouse=false;this.tooltipLocation="se";this.tooltipOffset=6;this.showTooltipGridPosition=false;this.showTooltipUnitPosition=
true;this.showTooltipDataPosition=false;this.tooltipFormatString="%.4P, %.4P";this.useAxesFormatters=true;this.tooltipAxisGroups=[];this.zoomTarget=this.zoomProxy=this.zoom=false;this.looseZoom=true;this.clickReset=false;this.dblClickReset=true;this.showHorizontalLine=this.showVerticalLine=false;this.constrainZoomTo="none";this.shapeRenderer=new h.jqplot.ShapeRenderer;this._zoom={start:[],end:[],started:false,zooming:false,isZoomed:false,axes:{start:{},end:{}},gridpos:{},datapos:{}};this.intersectionThreshold=
2;this.showCursorLegend=false;this.cursorLegendFormatString=h.jqplot.Cursor.cursorLegendFormatString;this._oldHandlers={onselectstart:null,ondrag:null,onmousedown:null};this.constrainOutsideZoom=true;this.onGrid=this.showTooltipOutsideZoom=false;h.extend(true,this,a)};h.jqplot.Cursor.cursorLegendFormatString="%s x:%s, y:%s";h.jqplot.Cursor.init=function(a,e,b){a=b||{};this.plugins.cursor=new h.jqplot.Cursor(a.cursor);var c=this.plugins.cursor;if(c.show){h.jqplot.eventListenerHooks.push(["jqplotMouseEnter",
v]);h.jqplot.eventListenerHooks.push(["jqplotMouseLeave",u]);h.jqplot.eventListenerHooks.push(["jqplotMouseMove",w]);if(c.showCursorLegend){b.legend=b.legend||{};b.legend.renderer=h.jqplot.CursorLegendRenderer;b.legend.formatString=this.plugins.cursor.cursorLegendFormatString;b.legend.show=true}if(c.zoom){h.jqplot.eventListenerHooks.push(["jqplotMouseDown",y]);c.clickReset&&h.jqplot.eventListenerHooks.push(["jqplotClick",s]);c.dblClickReset&&h.jqplot.eventListenerHooks.push(["jqplotDblClick",t])}this.resetZoom=
function(){var d=this.axes;if(c.zoomProxy){d=this.plugins.cursor.zoomCanvas._ctx;d.clearRect(0,0,d.canvas.width,d.canvas.height)}else{for(var f in d){d[f].reset();d[f]._ticks=[];if(c._zoom.axes[f]!==undefined)d[f]._autoFormatString=c._zoom.axes[f].tickFormatString}this.redraw()}this.plugins.cursor._zoom.isZoomed=false;this.target.trigger("jqplotResetZoom",[this,this.plugins.cursor])};if(c.showTooltipDataPosition){c.showTooltipUnitPosition=false;c.showTooltipGridPosition=false;if(a.cursor.tooltipFormatString==
undefined)c.tooltipFormatString=h.jqplot.Cursor.cursorLegendFormatString}}};h.jqplot.Cursor.postDraw=function(){var a=this.plugins.cursor;if(a.zoomCanvas){a.zoomCanvas.resetCanvas();a.zoomCanvas=null}if(a.cursorCanvas){a.cursorCanvas.resetCanvas();a.cursorCanvas=null}if(a._tooltipElem){a._tooltipElem.emptyForce();a._tooltipElem=null}if(a.zoom){a.zoomCanvas=new h.jqplot.GenericCanvas;this.eventCanvas._elem.before(a.zoomCanvas.createElement(this._gridPadding,"jqplot-zoom-canvas",this._plotDimensions,
this));a.zoomCanvas.setContext()}var e=document.createElement("div");a._tooltipElem=h(e);a._tooltipElem.addClass("jqplot-cursor-tooltip");a._tooltipElem.css({position:"absolute",display:"none"});a.zoomCanvas?a.zoomCanvas._elem.before(a._tooltipElem):this.eventCanvas._elem.before(a._tooltipElem);if(a.showVerticalLine||a.showHorizontalLine){a.cursorCanvas=new h.jqplot.GenericCanvas;this.eventCanvas._elem.before(a.cursorCanvas.createElement(this._gridPadding,"jqplot-cursor-canvas",this._plotDimensions,
this));a.cursorCanvas.setContext()}if(a.showTooltipUnitPosition)if(a.tooltipAxisGroups.length===0){e=this.series;for(var b,c=[],d=0;d<e.length;d++){b=e[d];b=b.xaxis+","+b.yaxis;h.inArray(b,c)==-1&&c.push(b)}for(d=0;d<c.length;d++)a.tooltipAxisGroups.push(c[d].split(","))}};h.jqplot.Cursor.zoomProxy=function(a,e){var b=a.plugins.cursor,c=e.plugins.cursor;b.zoomTarget=true;b.zoom=true;b.style="auto";b.dblClickReset=false;c.zoom=true;c.zoomProxy=true;e.target.bind("jqplotZoom",function(d,f,g,i,k){b.doZoom(f,
g,a,k)});e.target.bind("jqplotResetZoom",function(){a.resetZoom()})};h.jqplot.Cursor.prototype.resetZoom=function(a,e){var b=a.axes,c=e._zoom.axes;if(!a.plugins.cursor.zoomProxy&&e._zoom.isZoomed){for(var d in b){b[d].reset();b[d]._ticks=[];b[d]._autoFormatString=c[d].tickFormatString}a.redraw();e._zoom.isZoomed=false}else{b=e.zoomCanvas._ctx;b.clearRect(0,0,b.canvas.width,b.canvas.height)}a.target.trigger("jqplotResetZoom",[a,e])};h.jqplot.Cursor.resetZoom=function(a){a.resetZoom()};h.jqplot.Cursor.prototype.doZoom=
function(a,e,b,c){var d=b.axes,f=c._zoom.axes.start,g,i,k,l,m=b.plugins.cursor.zoomCanvas._ctx;if(c.constrainZoomTo=="none"&&Math.abs(a.x-c._zoom.start[0])>6&&Math.abs(a.y-c._zoom.start[1])>6||c.constrainZoomTo=="x"&&Math.abs(a.x-c._zoom.start[0])>6||c.constrainZoomTo=="y"&&Math.abs(a.y-c._zoom.start[1])>6){if(!b.plugins.cursor.zoomProxy){for(var j in e){if(c._zoom.axes[j]==undefined){c._zoom.axes[j]={};c._zoom.axes[j].numberTicks=d[j].numberTicks;c._zoom.axes[j].tickInterval=d[j].tickInterval;c._zoom.axes[j].daTickInterval=
d[j].daTickInterval;c._zoom.axes[j].min=d[j].min;c._zoom.axes[j].max=d[j].max;c._zoom.axes[j].tickFormatString=d[j].tickOptions!=null?d[j].tickOptions.formatString:""}if(c.constrainZoomTo=="none"||c.constrainZoomTo=="x"&&j.charAt(0)=="x"||c.constrainZoomTo=="y"&&j.charAt(0)=="y"){g=e[j];if(g!=null){if(g>f[j]){i=f[j];g=g}else{i=g;g=f[j]}k=d[j];l=null;if(k.alignTicks)if(k.name==="x2axis"&&b.axes.xaxis.show)l=b.axes.xaxis.numberTicks;else if(k.name.charAt(0)==="y"&&k.name!=="yaxis"&&k.name!=="yMidAxis"&&
b.axes.yaxis.show)l=b.axes.yaxis.numberTicks;if(this.looseZoom&&(d[j].renderer.constructor===h.jqplot.LinearAxisRenderer||d[j].renderer.constructor===h.jqplot.LogAxisRenderer)){i=h.jqplot.LinearTickGenerator(i,g,k._scalefact,l);if(d[j].tickInset&&i[0]<d[j].min+d[j].tickInset*d[j].tickInterval){i[0]+=i[4];i[2]-=1}if(d[j].tickInset&&i[1]>d[j].max-d[j].tickInset*d[j].tickInterval){i[1]-=i[4];i[2]-=1}if(d[j].renderer.constructor===h.jqplot.LogAxisRenderer&&i[0]<d[j].min){i[0]+=i[4];i[2]-=1}d[j].min=i[0];
d[j].max=i[1];d[j]._autoFormatString=i[3];d[j].numberTicks=i[2];d[j].tickInterval=i[4];d[j].daTickInterval=[i[4]/1E3,"seconds"]}else{d[j].min=i;d[j].max=g;d[j].tickInterval=null;d[j].numberTicks=null;d[j].daTickInterval=null}d[j]._ticks=[]}}}m.clearRect(0,0,m.canvas.width,m.canvas.height);b.redraw();c._zoom.isZoomed=true}b.target.trigger("jqplotZoom",[a,e,b,c])}};h.jqplot.preInitHooks.push(h.jqplot.Cursor.init);h.jqplot.postDrawHooks.push(h.jqplot.Cursor.postDraw);h.jqplot.CursorLegendRenderer=function(a){h.jqplot.TableLegendRenderer.call(this,
a);this.formatString="%s"};h.jqplot.CursorLegendRenderer.prototype=new h.jqplot.TableLegendRenderer;h.jqplot.CursorLegendRenderer.prototype.constructor=h.jqplot.CursorLegendRenderer;h.jqplot.CursorLegendRenderer.prototype.draw=function(){function a(i,k,l,m){var j=l?this.rowSpacing:"0";l=h('<tr class="jqplot-legend jqplot-cursor-legend"></tr>').appendTo(this._elem);l.data("seriesIndex",m);h('<td class="jqplot-legend jqplot-cursor-legend-swatch" style="padding-top:'+j+';"><div style="border:1px solid #cccccc;padding:0.2em;"><div class="jqplot-cursor-legend-swatch" style="background-color:'+
k+';"></div></div></td>').appendTo(l);k=h('<td class="jqplot-legend jqplot-cursor-legend-label" style="vertical-align:middle;padding-top:'+j+';"></td>');k.appendTo(l);k.data("seriesIndex",m);this.escapeHtml?k.text(i):k.html(i)}if(this._elem){this._elem.emptyForce();this._elem=null}if(this.show){var e=this._series,b;b=document.createElement("div");this._elem=h(b);b=null;this._elem.addClass("jqplot-legend jqplot-cursor-legend");this._elem.css("position","absolute");for(var c=false,d=0;d<e.length;d++){b=
e[d];if(b.show&&b.showLabel){var f=h.jqplot.sprintf(this.formatString,b.label.toString());if(f){var g=b.color;if(b._stack&&!b.fill)g="";a.call(this,f,g,c,d);c=true}for(f=0;f<h.jqplot.addLegendRowHooks.length;f++)if(g=h.jqplot.addLegendRowHooks[f].call(this,b)){a.call(this,g.label,g.color,c);c=true}}}e=b=null;delete e;delete b}return this._elem}})(jQuery);
