bremen_short_url/BackEnd/assets/vendor/flot/jquery.flot.crosshair.min.js

1 line
1.4 KiB
JavaScript

jQuery.plot.plugins.push({init:function(t){var a={x:-1,y:-1,locked:!1};function i(o){a.locked||-1!=a.x&&(a.x=-1,t.triggerRedrawOverlay())}function r(o){if(!a.locked)if(t.getSelection&&t.getSelection())a.x=-1;else{var e=t.offset();a.x=Math.max(0,Math.min(o.pageX-e.left,t.width())),a.y=Math.max(0,Math.min(o.pageY-e.top,t.height())),t.triggerRedrawOverlay()}}t.setCrosshair=function(o){if(o){var e=t.p2c(o);a.x=Math.max(0,Math.min(e.left,t.width())),a.y=Math.max(0,Math.min(e.top,t.height()))}else a.x=-1;t.triggerRedrawOverlay()},t.clearCrosshair=t.setCrosshair,t.lockCrosshair=function(o){o&&t.setCrosshair(o),a.locked=!0},t.unlockCrosshair=function(){a.locked=!1},t.hooks.bindEvents.push(function(o,e){o.getOptions().crosshair.mode&&(e.mouseout(i),e.mousemove(r))}),t.hooks.drawOverlay.push(function(o,e){var t=o.getOptions().crosshair;if(t.mode){var i=o.getPlotOffset();if(e.save(),e.translate(i.left,i.top),-1!=a.x){var r=o.getOptions().crosshair.lineWidth%2?.5:0;if(e.strokeStyle=t.color,e.lineWidth=t.lineWidth,e.lineJoin="round",e.beginPath(),-1!=t.mode.indexOf("x")){var n=Math.floor(a.x)+r;e.moveTo(n,0),e.lineTo(n,o.height())}if(-1!=t.mode.indexOf("y")){var s=Math.floor(a.y)+r;e.moveTo(0,s),e.lineTo(o.width(),s)}e.stroke()}e.restore()}}),t.hooks.shutdown.push(function(o,e){e.unbind("mouseout",i),e.unbind("mousemove",r)})},options:{crosshair:{mode:null,color:"rgba(170, 0, 0, 0.80)",lineWidth:1}},name:"crosshair",version:"1.0"});