OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/assets/javascripts/jquery.jqplot/plugins/jqplot.cursor.min.js

14 lines
14 KiB

/**
* Copyright (c) 2009 Chris Leonello
* jqPlot is currently available for use in all personal or commercial projects
* under both the MIT and GPL version 2.0 licenses. This means that you can
* choose the license that best suits your project and use it accordingly.
*
* Although not required, the author would appreciate an email letting him
* know of any substantial use of jqPlot. You can reach the author at:
* chris dot leonello at gmail dot com or see http://www.jqplot.com/info.php .
*
* If you are feeling kind and generous, consider supporting the project by
* making a donation at: http://www.jqplot.com/donate.php .
*/
(function(i){i.jqplot.Cursor=function(o){this.style="crosshair";this.previousCursor="auto";this.show=i.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.clickReset=false;this.dblClickReset=true;this.showVerticalLine=false;this.showHorizontalLine=false;this.constrainZoomTo="none";this.shapeRenderer=new i.jqplot.ShapeRenderer();this._zoom={start:[],end:[],started:false,zooming:false,isZoomed:false,axes:{start:{},end:{}}};this._tooltipElem;this.zoomCanvas;this.cursorCanvas;this.intersectionThreshold=2;this.showCursorLegend=false;this.cursorLegendFormatString=i.jqplot.Cursor.cursorLegendFormatString;i.extend(true,this,o)};i.jqplot.Cursor.cursorLegendFormatString="%s x:%s, y:%s";i.jqplot.Cursor.init=function(t,r,q){var o=q||{};this.plugins.cursor=new i.jqplot.Cursor(o.cursor);var u=this.plugins.cursor;if(u.show){i.jqplot.eventListenerHooks.push(["jqplotMouseEnter",b]);i.jqplot.eventListenerHooks.push(["jqplotMouseLeave",f]);i.jqplot.eventListenerHooks.push(["jqplotMouseMove",h]);if(u.showCursorLegend){q.legend=q.legend||{};q.legend.renderer=i.jqplot.CursorLegendRenderer;q.legend.formatString=this.plugins.cursor.cursorLegendFormatString;q.legend.show=true}if(u.zoom){i.jqplot.eventListenerHooks.push(["jqplotMouseDown",a]);i.jqplot.eventListenerHooks.push(["jqplotMouseUp",n]);if(u.clickReset){i.jqplot.eventListenerHooks.push(["jqplotClick",j])}if(u.dblClickReset){i.jqplot.eventListenerHooks.push(["jqplotDblClick",c])}}this.resetZoom=function(){var x=this.axes;if(!u.zoomProxy){for(var w in x){x[w].reset()}this.redraw()}else{var v=this.plugins.cursor.zoomCanvas._ctx;v.clearRect(0,0,v.canvas.width,v.canvas.height)}this.plugins.cursor._zoom.isZoomed=false;this.target.trigger("jqplotResetZoom",[this,this.plugins.cursor])};if(u.showTooltipDataPosition){u.showTooltipUnitPosition=false;u.showTooltipGridPosition=false;if(o.cursor.tooltipFormatString==undefined){u.tooltipFormatString=i.jqplot.Cursor.cursorLegendFormatString}}}};i.jqplot.Cursor.postDraw=function(){var w=this.plugins.cursor;w.zoomCanvas=new i.jqplot.GenericCanvas();this.eventCanvas._elem.before(w.zoomCanvas.createElement(this._gridPadding,"jqplot-zoom-canvas",this._plotDimensions));var v=w.zoomCanvas.setContext();w._tooltipElem=i('<div class="jqplot-cursor-tooltip" style="position:absolute;display:none"></div>');w.zoomCanvas._elem.before(w._tooltipElem);if(w.showVerticalLine||w.showHorizontalLine){w.cursorCanvas=new i.jqplot.GenericCanvas();this.eventCanvas._elem.before(w.cursorCanvas.createElement(this._gridPadding,"jqplot-cursor-canvas",this._plotDimensions));var v=w.cursorCanvas.setContext()}if(w.showTooltipUnitPosition){if(w.tooltipAxisGroups.length===0){var r=this.series;var t;var o=[];for(var q=0;q<r.length;q++){t=r[q];var u=t.xaxis+","+t.yaxis;if(i.inArray(u,o)==-1){o.push(u)}}for(var q=0;q<o.length;q++){w.tooltipAxisGroups.push(o[q].split(","))}}}};i.jqplot.Cursor.zoomProxy=function(v,q){var o=v.plugins.cursor;var u=q.plugins.cursor;o.zoomTarget=true;o.zoom=true;o.style="auto";o.dblClickReset=false;u.zoom=true;u.zoomProxy=true;q.target.bind("jqplotZoom",t);q.target.bind("jqplotResetZoom",r);function t(x,w,z,y,A){o.doZoom(w,z,v,A)}function r(w,x,y){v.resetZoom()}};i.jqplot.Cursor.prototype.resetZoom=function(u,v){var t=u.axes;var r=v._zoom.axes;if(!u.plugins.cursor.zoomProxy&&v._zoom.isZoomed){for(var q in t){t[q]._ticks=[];t[q].min=r[q].min;t[q].max=r[q].max;t[q].numberTicks=r[q].numberTicks;t[q].tickInterval=r[q].tickInterval;t[q].daTickInterval=r[q].daTickInterval}u.redraw();v._zoom.isZoomed=false}else{var o=v.zoomCanvas._ctx;o.clearRect(0,0,o.canvas.width,o.canvas.height)}u.target.trigger("jqplotResetZoom",[u,v])};i.jqplot.Cursor.resetZoom=function(o){o.resetZoom()};i.jqplot.Cursor.prototype.doZoom=function(w,t,x,B){var z=B;var y=x.axes;v