phpservermon/static/plugin/jqplot/jqplot.highlighter.min.js

4 lines
7.0 KiB
JavaScript

/* jqplot 1.0.9 | (c) 2009-2016 Chris Leonello | jplot.com
jsDate | (c) 2010-2016 Chris Leonello
*/
!function(t){t.jqplot.eventListenerHooks.push(["jqplotMouseMove",function(t,i,e,o,l){var h=l.plugins.highlighter,n=l.plugins.cursor;if(h.show)if(null==o&&h.isHighlighting){var a=jQuery.Event("jqplotHighlighterUnhighlight");l.target.trigger(a),(p=h.highlightCanvas._ctx).clearRect(0,0,p.canvas.width,p.canvas.height),h.fadeTooltip?h._tooltipElem.fadeOut(h.tooltipFadeSpeed):h._tooltipElem.hide(),h.bringSeriesToFront&&l.restorePreviousSeriesOrder(),h.isHighlighting=!1,h.currentNeighbor=null,p=null}else if(null!=o&&l.series[o.seriesIndex].showHighlight&&!h.isHighlighting){(a=jQuery.Event("jqplotHighlighterHighlight")).which=t.which,a.pageX=t.pageX,a.pageY=t.pageY;var g=[o.seriesIndex,o.pointIndex,o.data,l];l.target.trigger(a,g),h.isHighlighting=!0,h.currentNeighbor=o,h.showMarker&&s(l,o),!l.series[o.seriesIndex].show||!h.showTooltip||n&&n._zoom.started||r(l,l.series[o.seriesIndex],o),h.bringSeriesToFront&&l.moveSeriesToFront(o.seriesIndex)}else if(null!=o&&h.isHighlighting&&h.currentNeighbor!=o&&l.series[o.seriesIndex].showHighlight){var p;(p=h.highlightCanvas._ctx).clearRect(0,0,p.canvas.width,p.canvas.height),h.isHighlighting=!0,h.currentNeighbor=o,h.showMarker&&s(l,o),!l.series[o.seriesIndex].show||!h.showTooltip||n&&n._zoom.started||r(l,l.series[o.seriesIndex],o),h.bringSeriesToFront&&l.moveSeriesToFront(o.seriesIndex)}}]),t.jqplot.Highlighter=function(i){this.show=t.jqplot.config.enablePlugins,this.markerRenderer=new t.jqplot.MarkerRenderer({shadow:!1}),this.showMarker=!0,this.lineWidthAdjust=2.5,this.sizeAdjust=5,this.showTooltip=!0,this.tooltipLocation="nw",this.fadeTooltip=!0,this.tooltipFadeSpeed="fast",this.tooltipOffset=2,this.tooltipAxes="both",this.tooltipSeparator=", ",this.tooltipContentEditor=null,this.useAxesFormatters=!0,this.tooltipFormatString="%.5P",this.formatString=null,this.yvalues=1,this.bringSeriesToFront=!1,this._tooltipElem,this.isHighlighting=!1,this.currentNeighbor=null,t.extend(!0,this,i)};var i=["nw","n","ne","e","se","s","sw","w"],e={nw:0,n:1,ne:2,e:3,se:4,s:5,sw:6,w:7},o=["se","s","sw","w","nw","n","ne","e"];function s(i,e){var o=i.plugins.highlighter,s=i.series[e.seriesIndex],r=s.markerRenderer,l=o.markerRenderer;l.style=r.style,l.lineWidth=r.lineWidth+o.lineWidthAdjust,l.size=r.size+o.sizeAdjust;var h=t.jqplot.getColorComponents(r.color),n=[h[0],h[1],h[2]],a=h[3]>=.6?.6*h[3]:h[3]*(2-h[3]);l.color="rgba("+n[0]+","+n[1]+","+n[2]+","+a+")",l.init(),l.draw(s.gridData[e.pointIndex][0],s.gridData[e.pointIndex][1],o.highlightCanvas._ctx)}function r(s,r,l){var h=s.plugins.highlighter,n=h._tooltipElem,a=r.highlighter||{},g=t.extend(!0,{},h,a);if(g.useAxesFormatters){for(var p=r._xaxis._ticks[0].formatter,d=r._yaxis._ticks[0].formatter,f=r._xaxis._ticks[0].formatString,u=r._yaxis._ticks[0].formatString,c=p(f,l.data[0]),m=[],j=1;j<g.yvalues+1;j++)m.push(d(u,l.data[j]));if("string"==typeof g.formatString)switch(g.tooltipAxes){case"both":case"xy":m.unshift(c),m.unshift(g.formatString),x=t.jqplot.sprintf.apply(t.jqplot.sprintf,m);break;case"yx":m.push(c),m.unshift(g.formatString),x=t.jqplot.sprintf.apply(t.jqplot.sprintf,m);break;case"x":x=t.jqplot.sprintf.apply(t.jqplot.sprintf,[g.formatString,c]);break;case"y":m.unshift(g.formatString),x=t.jqplot.sprintf.apply(t.jqplot.sprintf,m);break;default:m.unshift(c),m.unshift(g.formatString),x=t.jqplot.sprintf.apply(t.jqplot.sprintf,m)}else switch(g.tooltipAxes){case"both":case"xy":for(x=c,j=0;j<m.length;j++)x+=g.tooltipSeparator+m[j];break;case"yx":for(x="",j=0;j<m.length;j++)x+=m[j]+g.tooltipSeparator;x+=c;break;case"x":x=c;break;case"y":x=m.join(g.tooltipSeparator);break;default:for(x=c,j=0;j<m.length;j++)x+=g.tooltipSeparator+m[j]}}else{var x;"string"==typeof g.formatString?x=t.jqplot.sprintf.apply(t.jqplot.sprintf,[g.formatString].concat(l.data)):"both"==g.tooltipAxes||"xy"==g.tooltipAxes?x=t.jqplot.sprintf(g.tooltipFormatString,l.data[0])+g.tooltipSeparator+t.jqplot.sprintf(g.tooltipFormatString,l.data[1]):"yx"==g.tooltipAxes?x=t.jqplot.sprintf(g.tooltipFormatString,l.data[1])+g.tooltipSeparator+t.jqplot.sprintf(g.tooltipFormatString,l.data[0]):"x"==g.tooltipAxes?x=t.jqplot.sprintf(g.tooltipFormatString,l.data[0]):"y"==g.tooltipAxes&&(x=t.jqplot.sprintf(g.tooltipFormatString,l.data[1]))}t.isFunction(g.tooltipContentEditor)&&(x=g.tooltipContentEditor(x,l.seriesIndex,l.pointIndex,s)),n.html(x);var _=l.gridData[0],v=l.gridData[1],w=0,q=.707;1==r.markerRenderer.show&&(w=(r.markerRenderer.size+g.sizeAdjust)/2);var S=i;switch(r.fillToZero&&r.fill&&l.data[1]<0&&(S=o),S[e[g.tooltipLocation]]){case"nw":var b=_+s._gridPadding.left-n.outerWidth(!0)-g.tooltipOffset-q*w,k=v+s._gridPadding.top-g.tooltipOffset-n.outerHeight(!0)-q*w;break;case"n":b=_+s._gridPadding.left-n.outerWidth(!0)/2,k=v+s._gridPadding.top-g.tooltipOffset-n.outerHeight(!0)-w;break;case"ne":b=_+s._gridPadding.left+g.tooltipOffset+q*w,k=v+s._gridPadding.top-g.tooltipOffset-n.outerHeight(!0)-q*w;break;case"e":b=_+s._gridPadding.left+g.tooltipOffset+w,k=v+s._gridPadding.top-n.outerHeight(!0)/2;break;case"se":b=_+s._gridPadding.left+g.tooltipOffset+q*w,k=v+s._gridPadding.top+g.tooltipOffset+q*w;break;case"s":b=_+s._gridPadding.left-n.outerWidth(!0)/2,k=v+s._gridPadding.top+g.tooltipOffset+w;break;case"sw":b=_+s._gridPadding.left-n.outerWidth(!0)-g.tooltipOffset-q*w,k=v+s._gridPadding.top+g.tooltipOffset+q*w;break;case"w":b=_+s._gridPadding.left-n.outerWidth(!0)-g.tooltipOffset-w,k=v+s._gridPadding.top-n.outerHeight(!0)/2;break;default:b=_+s._gridPadding.left-n.outerWidth(!0)-g.tooltipOffset-q*w,k=v+s._gridPadding.top-g.tooltipOffset-n.outerHeight(!0)-q*w}n.css("left",b),n.css("top",k),g.fadeTooltip?n.stop(!0,!0).fadeIn(g.tooltipFadeSpeed):n.show(),n=null}t.jqplot.Highlighter.init=function(i,e,o){var s=o||{};this.plugins.highlighter=new t.jqplot.Highlighter(s.highlighter)},t.jqplot.Highlighter.parseOptions=function(t,i){this.showHighlight=!0},t.jqplot.Highlighter.postPlotDraw=function(){this.plugins.highlighter&&this.plugins.highlighter.highlightCanvas&&(this.plugins.highlighter.highlightCanvas.resetCanvas(),this.plugins.highlighter.highlightCanvas=null),this.plugins.highlighter&&this.plugins.highlighter._tooltipElem&&(this.plugins.highlighter._tooltipElem.emptyForce(),this.plugins.highlighter._tooltipElem=null),this.plugins.highlighter.highlightCanvas=new t.jqplot.GenericCanvas,this.eventCanvas._elem.before(this.plugins.highlighter.highlightCanvas.createElement(this._gridPadding,"jqplot-highlight-canvas",this._plotDimensions,this)),this.plugins.highlighter.highlightCanvas.setContext();var i=document.createElement("div");this.plugins.highlighter._tooltipElem=t(i),i=null,this.plugins.highlighter._tooltipElem.addClass("jqplot-highlighter-tooltip"),this.plugins.highlighter._tooltipElem.css({position:"absolute",display:"none"}),this.eventCanvas._elem.before(this.plugins.highlighter._tooltipElem)},t.jqplot.preInitHooks.push(t.jqplot.Highlighter.init),t.jqplot.preParseSeriesOptionsHooks.push(t.jqplot.Highlighter.parseOptions),t.jqplot.postDrawHooks.push(t.jqplot.Highlighter.postPlotDraw)}(jQuery);