Files
purple-explorer/public/vendor/jqplot/plugins/jqplot.barRenderer.min.js
T
2020-11-23 20:15:40 -07:00

1 line
12 KiB
JavaScript

!function(i){function t(i,e,s,h,r){var a=i,l=i-1,n="x"===r?0:1;return a>0?s*h.series[l]._plotData[e][n]<0?t(l,e,s,h,r):h.series[l].gridData[e][n]:0===n?h.series[a]._xaxis.series_u2p(0):h.series[a]._yaxis.series_u2p(0)}function e(t,e,s){for(var h=0;h<this.series.length;h++)this.series[h].renderer.constructor==i.jqplot.BarRenderer&&this.series[h].highlightMouseOver&&(this.series[h].highlightMouseDown=!1)}function s(){this.plugins.barRenderer&&this.plugins.barRenderer.highlightCanvas&&(this.plugins.barRenderer.highlightCanvas.resetCanvas(),this.plugins.barRenderer.highlightCanvas=null),this.plugins.barRenderer={highlightedSeriesIndex:null},this.plugins.barRenderer.highlightCanvas=new i.jqplot.GenericCanvas,this.eventCanvas._elem.before(this.plugins.barRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-barRenderer-highlight-canvas",this._plotDimensions,this)),this.plugins.barRenderer.highlightCanvas.setContext(),this.eventCanvas._elem.bind("mouseleave",{plot:this},function(i){r(i.data.plot)})}function h(i,t,e,s){var h=i.series[t],r=i.plugins.barRenderer.highlightCanvas;r._ctx.clearRect(0,0,r._ctx.canvas.width,r._ctx.canvas.height),h._highlightedPoint=e,i.plugins.barRenderer.highlightedSeriesIndex=t;var a={fillStyle:h.highlightColors[e]};h.renderer.shapeRenderer.draw(r._ctx,s,a),r=null}function r(i){var t=i.plugins.barRenderer.highlightCanvas;t._ctx.clearRect(0,0,t._ctx.canvas.width,t._ctx.canvas.height);for(var e=0;e<i.series.length;e++)i.series[e]._highlightedPoint=null;i.plugins.barRenderer.highlightedSeriesIndex=null,i.target.trigger("jqplotDataUnhighlight"),t=null}function a(i,t,e,s,a){if(s){var l=[s.seriesIndex,s.pointIndex,s.data],n=jQuery.Event("jqplotDataMouseOver");if(n.pageX=i.pageX,n.pageY=i.pageY,a.target.trigger(n,l),a.series[l[0]].show&&a.series[l[0]].highlightMouseOver&&(l[0]!=a.plugins.barRenderer.highlightedSeriesIndex||l[1]!=a.series[l[0]]._highlightedPoint)){var o=jQuery.Event("jqplotDataHighlight");o.which=i.which,o.pageX=i.pageX,o.pageY=i.pageY,a.target.trigger(o,l),h(a,s.seriesIndex,s.pointIndex,s.points)}}else null==s&&r(a)}function l(i,t,e,s,a){if(s){var l=[s.seriesIndex,s.pointIndex,s.data];if(a.series[l[0]].highlightMouseDown&&(l[0]!=a.plugins.barRenderer.highlightedSeriesIndex||l[1]!=a.series[l[0]]._highlightedPoint)){var n=jQuery.Event("jqplotDataHighlight");n.which=i.which,n.pageX=i.pageX,n.pageY=i.pageY,a.target.trigger(n,l),h(a,s.seriesIndex,s.pointIndex,s.points)}}else null==s&&r(a)}function n(i,t,e,s,h){var a=h.plugins.barRenderer.highlightedSeriesIndex;null!=a&&h.series[a].highlightMouseDown&&r(h)}function o(i,t,e,s,h){if(s){var r=[s.seriesIndex,s.pointIndex,s.data],a=jQuery.Event("jqplotDataClick");a.which=i.which,a.pageX=i.pageX,a.pageY=i.pageY,h.target.trigger(a,r)}}function d(i,t,e,s,h){if(s){var a=[s.seriesIndex,s.pointIndex,s.data],l=h.plugins.barRenderer.highlightedSeriesIndex;null!=l&&h.series[l].highlightMouseDown&&r(h);var n=jQuery.Event("jqplotDataRightClick");n.which=i.which,n.pageX=i.pageX,n.pageY=i.pageY,h.target.trigger(n,a)}}i.jqplot.BarRenderer=function(){i.jqplot.LineRenderer.call(this)},i.jqplot.BarRenderer.prototype=new i.jqplot.LineRenderer,i.jqplot.BarRenderer.prototype.constructor=i.jqplot.BarRenderer,i.jqplot.BarRenderer.prototype.init=function(t,h){this.barPadding=8,this.barMargin=10,this.barDirection="vertical",this.barWidth=null,this.shadowOffset=2,this.shadowDepth=5,this.shadowAlpha=.08,this.waterfall=!1,this.groups=1,this.varyBarColor=!1,this.highlightMouseOver=!0,this.highlightMouseDown=!1,this.highlightColors=[],this.transposedData=!0,this.renderer.animation={show:!1,direction:"down",speed:3e3,_supported:!0},this._type="bar",t.highlightMouseDown&&null==t.highlightMouseOver&&(t.highlightMouseOver=!1),i.extend(!0,this,t),i.extend(!0,this.renderer,t),this.fill=!0,"horizontal"===this.barDirection&&this.rendererOptions.animation&&null==this.rendererOptions.animation.direction&&(this.renderer.animation.direction="left"),this.waterfall&&(this.fillToZero=!1,this.disableStack=!0),"vertical"==this.barDirection?(this._primaryAxis="_xaxis",this._stackAxis="y",this.fillAxis="y"):(this._primaryAxis="_yaxis",this._stackAxis="x",this.fillAxis="x"),this._highlightedPoint=null,this._plotSeriesInfo=null,this._dataColors=[],this._barPoints=[];var r={lineJoin:"miter",lineCap:"round",fill:!0,isarc:!1,strokeStyle:this.color,fillStyle:this.color,closePath:this.fill};this.renderer.shapeRenderer.init(r);var g={lineJoin:"miter",lineCap:"round",fill:!0,isarc:!1,angle:this.shadowAngle,offset:this.shadowOffset,alpha:this.shadowAlpha,depth:this.shadowDepth,closePath:this.fill};this.renderer.shadowRenderer.init(g),h.postInitHooks.addOnce(e),h.postDrawHooks.addOnce(s),h.eventListenerHooks.addOnce("jqplotMouseMove",a),h.eventListenerHooks.addOnce("jqplotMouseDown",l),h.eventListenerHooks.addOnce("jqplotMouseUp",n),h.eventListenerHooks.addOnce("jqplotClick",o),h.eventListenerHooks.addOnce("jqplotRightClick",d)},i.jqplot.preSeriesInitHooks.push(function(t,e,s,h){if("horizontal"==this.rendererOptions.barDirection&&(this._stackAxis="x",this._primaryAxis="_yaxis"),1==this.rendererOptions.waterfall){this._data=i.extend(!0,[],this.data);for(var r=0,a=this.rendererOptions.barDirection&&"vertical"!==this.rendererOptions.barDirection&&!1!==this.transposedData?0:1,l=0;l<this.data.length;l++)r+=this.data[l][a],l>0&&(this.data[l][a]+=this.data[l-1][a]);this.data[this.data.length]=1==a?[this.data.length+1,r]:[r,this.data.length+1],this._data[this._data.length]=1==a?[this._data.length+1,r]:[r,this._data.length+1]}if(this.rendererOptions.groups>1){this.breakOnNull=!0;var n=this.data.length,o=parseInt(n/this.rendererOptions.groups,10),d=0;for(l=o;l<n;l+=o)this.data.splice(l+d,0,[null,null]),this._plotData.splice(l+d,0,[null,null]),this._stackData.splice(l+d,0,[null,null]),d++;for(l=0;l<this.data.length;l++)"_xaxis"==this._primaryAxis?(this.data[l][0]=l+1,this._plotData[l][0]=l+1,this._stackData[l][0]=l+1):(this.data[l][1]=l+1,this._plotData[l][1]=l+1,this._stackData[l][1]=l+1)}}),i.jqplot.BarRenderer.prototype.calcSeriesNumbers=function(){for(var t,e,s=0,h=0,r=this[this._primaryAxis],a=0;a<r._series.length;a++)(t=r._series[a])===this&&(e=a),t.renderer.constructor==i.jqplot.BarRenderer&&(s+=t.data.length,h+=1);return[s,h,e]},i.jqplot.BarRenderer.prototype.setBarWidth=function(){var i,t,e=this[this._primaryAxis],s=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);i=s[0],t=s[1];var h=(e.numberTicks-1)/2;return"xaxis"==e.name||"x2axis"==e.name?this._stack?this.barWidth=(e._offsets.max-e._offsets.min)/i*t-this.barMargin:this.barWidth=((e._offsets.max-e._offsets.min)/h-this.barPadding*(t-1)-2*this.barMargin)/t:this._stack?this.barWidth=(e._offsets.min-e._offsets.max)/i*t-this.barMargin:this.barWidth=((e._offsets.min-e._offsets.max)/h-this.barPadding*(t-1)-2*this.barMargin)/t,[i,t]},i.jqplot.BarRenderer.prototype.draw=function(e,s,h,r){var a=i.extend({},h),l=null!=a.shadow?a.shadow:this.shadow,n=null!=a.showLine?a.showLine:this.showLine;null!=a.fill?a.fill:this.fill,this.xaxis,this.yaxis,this._xaxis.series_u2p,this._yaxis.series_u2p;this._dataColors=[],this._barPoints=[],null!=this.barWidth&&null!=this.rendererOptions.barWidth||this.renderer.setBarWidth.call(this);(D=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this))[0];var o=D[1],d=D[2],g=[];if(this._stack?this._barNudge=0:this._barNudge=(-Math.abs(o/2-.5)+d)*(this.barWidth+this.barPadding),n){var p=new i.jqplot.ColorGenerator(this.negativeSeriesColors),u=new i.jqplot.ColorGenerator(this.seriesColors),_=p.get(this.index);this.useNegativeColors||(_=a.fillStyle);var c,f,x,b=a.fillStyle;if("vertical"==this.barDirection){for(var v=0;v<s.length;v++)if(this._stack||null!=this.data[v][1]){if(g=[],c=s[v][0]+this._barNudge,x=this._stack&&this._prevGridData.length?t(this.index,v,this._plotData[v][1],r,"y"):this.fillToZero?this._yaxis.series_u2p(0):this.waterfall&&v>0&&v<this.gridData.length-1?this.gridData[v-1][1]:this.waterfall&&0==v&&v<this.gridData.length-1?this._yaxis.min<=0&&this._yaxis.max>=0?this._yaxis.series_u2p(0):this._yaxis.min>0?e.canvas.height:0:this.waterfall&&v==this.gridData.length-1?this._yaxis.min<=0&&this._yaxis.max>=0?this._yaxis.series_u2p(0):this._yaxis.min>0?e.canvas.height:0:e.canvas.height,this.fillToZero&&this._plotData[v][1]<0||this.waterfall&&this._data[v][1]<0?this.varyBarColor&&!this._stack?this.useNegativeColors?a.fillStyle=p.next():a.fillStyle=u.next():a.fillStyle=_:this.varyBarColor&&!this._stack?a.fillStyle=u.next():a.fillStyle=b,!this.fillToZero||this._plotData[v][1]>=0?(g.push([c-this.barWidth/2,x]),g.push([c-this.barWidth/2,s[v][1]]),g.push([c+this.barWidth/2,s[v][1]]),g.push([c+this.barWidth/2,x])):(g.push([c-this.barWidth/2,s[v][1]]),g.push([c-this.barWidth/2,x]),g.push([c+this.barWidth/2,x]),g.push([c+this.barWidth/2,s[v][1]])),this._barPoints.push(g),l&&!this._stack)delete(y=i.extend(!0,{},a)).fillStyle,this.renderer.shadowRenderer.draw(e,g,y);var w=a.fillStyle||this.color;this._dataColors.push(w),this.renderer.shapeRenderer.draw(e,g,a)}}else if("horizontal"==this.barDirection)for(v=0;v<s.length;v++)if(this._stack||null!=this.data[v][0]){var y;if(g=[],c=s[v][1]-this._barNudge,f=this._stack&&this._prevGridData.length?t(this.index,v,this._plotData[v][0],r,"x"):this.fillToZero?this._xaxis.series_u2p(0):this.waterfall&&v>0&&v<this.gridData.length-1?this.gridData[v-1][0]:this.waterfall&&0==v&&v<this.gridData.length-1?this._xaxis.min<=0&&this._xaxis.max>=0?this._xaxis.series_u2p(0):(this._xaxis.min,0):this.waterfall&&v==this.gridData.length-1?this._xaxis.min<=0&&this._xaxis.max>=0?this._xaxis.series_u2p(0):this._xaxis.min>0?0:e.canvas.width:0,this.fillToZero&&this._plotData[v][0]<0||this.waterfall&&this._data[v][0]<0?this.varyBarColor&&!this._stack?this.useNegativeColors?a.fillStyle=p.next():a.fillStyle=u.next():a.fillStyle=_:this.varyBarColor&&!this._stack?a.fillStyle=u.next():a.fillStyle=b,!this.fillToZero||this._plotData[v][0]>=0?(g.push([f,c+this.barWidth/2]),g.push([f,c-this.barWidth/2]),g.push([s[v][0],c-this.barWidth/2]),g.push([s[v][0],c+this.barWidth/2])):(g.push([s[v][0],c+this.barWidth/2]),g.push([s[v][0],c-this.barWidth/2]),g.push([f,c-this.barWidth/2]),g.push([f,c+this.barWidth/2])),this._barPoints.push(g),l&&!this._stack)delete(y=i.extend(!0,{},a)).fillStyle,this.renderer.shadowRenderer.draw(e,g,y);w=a.fillStyle||this.color;this._dataColors.push(w),this.renderer.shapeRenderer.draw(e,g,a)}}if(0==this.highlightColors.length)this.highlightColors=i.jqplot.computeHighlightColors(this._dataColors);else if("string"==typeof this.highlightColors){var D=this.highlightColors;this.highlightColors=[];for(v=0;v<this._dataColors.length;v++)this.highlightColors.push(D)}},i.jqplot.BarRenderer.prototype.drawShadow=function(i,e,s,h){var r,a,l,n=null!=s?s:{},o=(null!=n.shadow?n.shadow:this.shadow,null!=n.showLine?n.showLine:this.showLine);null!=n.fill?n.fill:this.fill,this.xaxis,this.yaxis,this._xaxis.series_u2p,this._yaxis.series_u2p;if(this._stack&&this.shadow){null==this.barWidth&&this.renderer.setBarWidth.call(this);var d=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);if(d[0],a=d[1],l=d[2],this._stack?this._barNudge=0:this._barNudge=(-Math.abs(a/2-.5)+l)*(this.barWidth+this.barPadding),o)if("vertical"==this.barDirection){for(var g=0;g<e.length;g++)if(null!=this.data[g][1]){r=[];var p,u=e[g][0]+this._barNudge;p=this._stack&&this._prevGridData.length?t(this.index,g,this._plotData[g][1],h,"y"):this.fillToZero?this._yaxis.series_u2p(0):i.canvas.height,r.push([u-this.barWidth/2,p]),r.push([u-this.barWidth/2,e[g][1]]),r.push([u+this.barWidth/2,e[g][1]]),r.push([u+this.barWidth/2,p]),this.renderer.shadowRenderer.draw(i,r,n)}}else if("horizontal"==this.barDirection)for(g=0;g<e.length;g++)if(null!=this.data[g][0]){r=[];var _;u=e[g][1]-this._barNudge;_=this._stack&&this._prevGridData.length?t(this.index,g,this._plotData[g][0],h,"x"):this.fillToZero?this._xaxis.series_u2p(0):0,r.push([_,u+this.barWidth/2]),r.push([e[g][0],u+this.barWidth/2]),r.push([e[g][0],u-this.barWidth/2]),r.push([_,u-this.barWidth/2]),this.renderer.shadowRenderer.draw(i,r,n)}}}}(jQuery);