(function(j){j.jqplot.Cursor=function(r){this.style="crosshair";this.previousCursor="auto";this.show=j.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.zoom=false;this.zoomProxy=false;this.zoomTarget=false;this.looseZoom=true;this.clickReset=false;this.dblClickReset=true;this.showVerticalLine=false;this.showHorizontalLine=false;this.constrainZoomTo="none";this.shapeRenderer=new j.jqplot.ShapeRenderer();this._zoom={start:[],end:[],started:false,zooming:false,isZoomed:false,axes:{start:{},end:{}},gridpos:{},datapos:{}};this._tooltipElem;this.zoomCanvas;this.cursorCanvas;this.intersectionThreshold=2;this.showCursorLegend=false;this.cursorLegendFormatString=j.jqplot.Cursor.cursorLegendFormatString;this._oldHandlers={onselectstart:null,ondrag:null,onmousedown:null};this.constrainOutsideZoom=true;this.showTooltipOutsideZoom=false;this.onGrid=false;this._customCursorLegend;this.showCustomCursorLegend=false;this.customCursorLegendFollowMouse=false;this.customCursorLegendFormatString=j.jqplot.Cursor.customCursorLegendFormatString;this.customCursorLegendLocation="se";this.customCursorLegendOffset="6";j.extend(true,this,r)};j.jqplot.Cursor.cursorLegendFormatString="%s x:%s, y:%s";j.jqplot.Cursor.customCursorLegendFormatString="%s:%s %d";j.jqplot.Cursor.init=function(u,t,s){var r=s||{};this.plugins.cursor=new j.jqplot.Cursor(r.cursor);var v=this.plugins.cursor;if(v.show){j.jqplot.eventListenerHooks.push(["jqplotMouseEnter",b]);j.jqplot.eventListenerHooks.push(["jqplotMouseLeave",f]);j.jqplot.eventListenerHooks.push(["jqplotMouseMove",i]);if(v.showCursorLegend){s.legend=s.legend||{};s.legend.renderer=j.jqplot.CursorLegendRenderer;s.legend.formatString=this.plugins.cursor.cursorLegendFormatString;s.legend.show=true}if(v.showCustomCursorLegend){s.legend=s.legend||{};s.legend.renderer=j.jqplot.CursorLegendRenderer;s.legend.formatString=this.plugins.cursor.customCursorLegendFormatString;s.legend.show=true}if(v.zoom){j.jqplot.eventListenerHooks.push(["jqplotMouseDown",a]);if(v.clickReset){j.jqplot.eventListenerHooks.push(["jqplotClick",k])}if(v.dblClickReset){j.jqplot.eventListenerHooks.push(["jqplotDblClick",c])}}this.resetZoom=function(){var y=this.axes;if(!v.zoomProxy){for(var x in y){y[x].reset();y[x]._ticks=[];if(v._zoom.axes[x]!==undefined){y[x]._autoFormatString=v._zoom.axes[x].tickFormatString}}this.redraw()}else{var w=this.plugins.cursor.zoomCanvas._ctx;w.clearRect(0,0,w.canvas.width,w.canvas.height);w=null}this.plugins.cursor._zoom.isZoomed=false;this.target.trigger("jqplotResetZoom",[this,this.plugins.cursor])};if(v.showTooltipDataPosition){v.showTooltipUnitPosition=false;v.showTooltipGridPosition=false;if(r.cursor.tooltipFormatString==undefined){v.tooltipFormatString=j.jqplot.Cursor.cursorLegendFormatString}}}};j.jqplot.Cursor.postDraw=function(){var y=this.plugins.cursor;if(y.zoomCanvas){y.zoomCanvas.resetCanvas();y.zoomCanvas=null}if(y.cursorCanvas){y.cursorCanvas.resetCanvas();y.cursorCanvas=null}if(y._tooltipElem){y._tooltipElem.emptyForce();y._tooltipElem=null}if(y.zoom){y.zoomCanvas=new j.jqplot.GenericCanvas();this.eventCanvas._elem.before(y.zoomCanvas.createElement(this._gridPadding,"jqplot-zoom-canvas",this._plotDimensions,this));y.zoomCanvas.setContext()}var w=document.createElement("div");y._tooltipElem=j(w);w=null;y._tooltipElem.addClass("jqplot-cursor-tooltip");y._tooltipElem.css({position:"absolute",display:"none"});w=j(".jqplot-custom-cursor-legend");y._customCursorLegend=j(w);w=null;y._customCursorLegend.removeAttr("style").css({position:"absolute",display:"none"});if(y.zoomCanvas){y.zoomCanvas._elem.before(y._tooltipElem)}else{this.eventCanvas._elem.before(y._tooltipElem)}if(y.showVerticalLine||y.showHorizontalLine){y.cursorCanvas=new j.jqplot.GenericCanvas();this.eventCanvas._elem.before(y.cursorCanvas.createElement(this._gridPadding,"jqplot-cursor-canvas",this._plotDimensions,this));y.cursorCanvas.setContext()}if(y.showTooltipUnitPosition){if(y.tooltipAxisGroups.length===0){var u=this.series;var v;var r=[];for(var t=0;t6&&Math.abs(H.y-J._zoom.start[1])>6)||(J.constrainZoomTo=="x"&&Math.abs(H.x-J._zoom.start[0])>6)||(J.constrainZoomTo=="y"&&Math.abs(H.y-J._zoom.start[1])>6)){if(!D.plugins.cursor.zoomProxy){for(var z in u){if(J._zoom.axes[z]==undefined){J._zoom.axes[z]={};J._zoom.axes[z].numberTicks=G[z].numberTicks;J._zoom.axes[z].tickInterval=G[z].tickInterval;J._zoom.axes[z].daTickInterval=G[z].daTickInterval;J._zoom.axes[z].min=G[z].min;J._zoom.axes[z].max=G[z].max;J._zoom.axes[z].tickFormatString=(G[z].tickOptions!=null)?G[z].tickOptions.formatString:""}if((J.constrainZoomTo=="none")||(J.constrainZoomTo=="x"&&z.charAt(0)=="x")||(J.constrainZoomTo=="y"&&z.charAt(0)=="y")){A=u[z];if(A!=null){if(A>x[z]){w=x[z];y=A}else{E=x[z]-A;w=A;y=x[z]}r=G[z];I=null;if(r.alignTicks){if(r.name==="x2axis"&&D.axes.xaxis.show){I=D.axes.xaxis.numberTicks}else{if(r.name.charAt(0)==="y"&&r.name!=="yaxis"&&r.name!=="yMidAxis"&&D.axes.yaxis.show){I=D.axes.yaxis.numberTicks}}}if(this.looseZoom&&(G[z].renderer.constructor===j.jqplot.LinearAxisRenderer||G[z].renderer.constructor===j.jqplot.LogAxisRenderer)){K=j.jqplot.LinearTickGenerator(w,y,r._scalefact,I);if(G[z].tickInset&&K[0]G[z].max-G[z].tickInset*G[z].tickInterval){K[1]-=K[4];K[2]-=1}if(G[z].renderer.constructor===j.jqplot.LogAxisRenderer&&K[0]"}if(K.useAxesFormatters){for(var E=0;E"}x+=j.jqplot.sprintf(K.tooltipFormatString,u,A,y);O=true}}}}K._tooltipElem.html(x)}function g(K,G){var C=["星期天","星期一","星期二","星期三","星期四","星期五","星期六"];var M=G.plugins.cursor;var E=M.cursorCanvas._ctx;E.clearRect(0,0,E.canvas.width,E.canvas.height);if(M.showVerticalLine){M.shapeRenderer.draw(E,[[K.x,0],[K.x,E.canvas.height]])}if(M.showHorizontalLine){M.shapeRenderer.draw(E,[[0,K.y],[E.canvas.width,K.y]])}var O=d(G,K.x,K.y);if(M.showCursorLegend){var t=j(G.targetId+" td.jqplot-cursor-legend-label");for(var I=0;I0;s--){t=w[s-1];if(r[t].show){v[t]=r[t].series_p2u(x[t.charAt(0)])}}return{offsets:u,gridPos:x,dataPos:v}}function h(A){var y=A.data.plot;var z=y.plugins.cursor;if(z.show&&z.zoom&&z._zoom.started&&!z.zoomTarget){A.preventDefault();var C=z.zoomCanvas._ctx;var w=o(A);var x=w.gridPos;var u=w.dataPos;z._zoom.gridpos=x;z._zoom.datapos=u;z._zoom.zooming=true;var v=x.x;var t=x.y;var B=C.canvas.height;var r=C.canvas.width;if(z.showTooltip&&!z.onGrid&&z.showTooltipOutsideZoom){e(x,u,y);if(z.followMouse){n(x,y)}}if(z.constrainZoomTo=="x"){z._zoom.end=[v,B]}else{if(z.constrainZoomTo=="y"){z._zoom.end=[r,t]}else{z._zoom.end=[v,t]}}var s=window.getSelection;if(document.selection&&document.selection.empty){document.selection.empty()}else{if(s&&!s().isCollapsed){s().collapse()}}l.call(z);C=null}}function a(x,t,s,y,u){var w=u.plugins.cursor;if(u.plugins.mobile){j(document).one("vmouseup.jqplot_cursor",{plot:u},p)}else{j(document).one("mouseup.jqplot_cursor",{plot:u},p)}var v=u.axes;if(document.onselectstart!=undefined){w._oldHandlers.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!=undefined){w._oldHandlers.ondrag=document.ondrag;document.ondrag=function(){return false}}if(document.onmousedown!=undefined){w._oldHandlers.onmousedown=document.onmousedown;document.onmousedown=function(){return false}}if(w.zoom){if(!w.zoomProxy){var z=w.zoomCanvas._ctx;z.clearRect(0,0,z.canvas.width,z.canvas.height);z=null}if(w.constrainZoomTo=="x"){w._zoom.start=[t.x,0]}else{if(w.constrainZoomTo=="y"){w._zoom.start=[0,t.y]}else{w._zoom.start=[t.x,t.y]}}w._zoom.started=true;for(var r in s){w._zoom.axes.start[r]=s[r]}if(u.plugins.mobile){j(document).bind("vmousemove.jqplotCursor",{plot:u},h)}else{j(document).bind("mousemove.jqplotCursor",{plot:u},h)}}}function p(z){var w=z.data.plot;var y=w.plugins.cursor;if(y.zoom&&y._zoom.zooming&&!y.zoomTarget){var v=y._zoom.gridpos.x;var s=y._zoom.gridpos.y;var u=y._zoom.datapos;var A=y.zoomCanvas._ctx.canvas.height;var r=y.zoomCanvas._ctx.canvas.width;var x=w.axes;if(y.constrainOutsideZoom&&!y.onGrid){if(v<0){v=0}else{if(v>r){v=r}}if(s<0){s=0}else{if(s>A){s=A}}for(var t in u){if(u[t]){if(t.charAt(0)=="x"){u[t]=x[t].series_p2u(v)}else{u[t]=x[t].series_p2u(s)}}}}if(y.constrainZoomTo=="x"){s=A}else{if(y.constrainZoomTo=="y"){v=r}}y._zoom.end=[v,s];y._zoom.gridpos={x:v,y:s};y.doZoom(y._zoom.gridpos,u,w,y)}y._zoom.started=false;y._zoom.zooming=false;j(document).unbind("mousemove.jqplotCursor",h);if(document.onselectstart!=undefined&&y._oldHandlers.onselectstart!=null){document.onselectstart=y._oldHandlers.onselectstart;y._oldHandlers.onselectstart=null}if(document.ondrag!=undefined&&y._oldHandlers.ondrag!=null){document.ondrag=y._oldHandlers.ondrag;y._oldHandlers.ondrag=null}if(document.onmousedown!=undefined&&y._oldHandlers.onmousedown!=null){document.onmousedown=y._oldHandlers.onmousedown;y._oldHandlers.onmousedown=null}}function l(){var z=this._zoom.start;var v=this._zoom.end;var u=this.zoomCanvas._ctx;var s,x,y,r;if(v[0]>z[0]){s=z[0];r=v[0]-z[0]}else{s=v[0];r=z[0]-v[0]}if(v[1]>z[1]){x=z[1];y=v[1]-z[1]}else{x=v[1];y=z[1]-v[1]}u.fillStyle="rgba(0,0,0,0.2)";u.strokeStyle="#999999";u.lineWidth=1;u.clearRect(0,0,u.canvas.width,u.canvas.height);u.fillRect(0,0,u.canvas.width,u.canvas.height);u.clearRect(s,x,r,y);u.strokeRect(s,x,r,y);u=null}j.jqplot.CursorLegendRenderer=function(r){j.jqplot.TableLegendRenderer.call(this,r);this.formatString="%s"};j.jqplot.CursorLegendRenderer.prototype=new j.jqplot.TableLegendRenderer();j.jqplot.CursorLegendRenderer.prototype.constructor=j.jqplot.CursorLegendRenderer;j.jqplot.CursorLegendRenderer.prototype.draw=function(v,B){var C=B.plugins.cursor;var E=C.showCustomCursorLegend;if(this._elem){this._elem.emptyForce();this._elem=null}if(this.show){var A=this._series,G;var r=(E)?"jqplot-custom-cursor-legend":"jqplot-cursor-legend";var u=(E)?document.createElement("div"):document.createElement("table");if(E){j("
").appendTo(u)}this._elem=j(u);u=null;this._elem.addClass("jqplot-legend "+r);this._elem.css("position","absolute");var t=false;for(var z=0;z").appendTo(this._elem);P.data("seriesIndex",O);j("
").appendTo(P);var H=j("
").appendTo(P);H.data("seriesIndex",O);if(this.escapeHtml){H.text(N)}else{H.html(N)}P=null;H=null}else{var K=(s)?this.rowSpacing:"0";var L=j('').appendTo(this._elem);L.data("seriesIndex",O);j('
').appendTo(L);var I=j('');I.appendTo(L);I.data("seriesIndex",O);if(this.escapeHtml){I.text(N)}else{I.html(N)}L=null;I=null}}return this._elem}})(jQuery);