-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgauge.min.js
3 lines (3 loc) · 32.1 KB
/
gauge.min.js
1
2
3
!function(e){"use strict";function t(e){if(Array.isArray(e)){for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}return Array.from(e)}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){if(t||(t="undefined"==typeof window?global:window),"undefined"!=typeof t[e])return t[e];for(var i=["webkit","moz","ms","o"],r=0,o=i.length,n=e.charAt(0).toUpperCase()+e.substr(1);r<o;r++){var a=t[i[r]+n];if("undefined"!=typeof a)return a}return null}function a(e,t,i,r,o,n,l){if("function"!=typeof r)throw new TypeError("Invalid animation rule:",r);var s=e-i,d=s/o;d>1&&(d=1),t&&t(1===d?d:r(d)),s<o?l.frame=te(function(e){return a(e,t,i,r,o,n,l)}):n&&n()}function l(){Array.prototype.constructor.apply(this,arguments)}function s(e,t,i,r,o,n){e.beginPath(),e.moveTo(t+n,i),e.lineTo(t+r-n,i),e.quadraticCurveTo(t+r,i,t+r,i+n),e.lineTo(t+r,i+o-n),e.quadraticCurveTo(t+r,i+o,t+r-n,i+o),e.lineTo(t+n,i+o),e.quadraticCurveTo(t,i+o,t,i+o-n),e.lineTo(t,i+n),e.quadraticCurveTo(t,i,t+n,i),e.closePath()}function d(e,t){var i=t.valueDec,r=t.valueInt,o=0,n=void 0,a=void 0,l=void 0;if(e=parseFloat(e),l=e<0,e=Math.abs(e),i>0){for(a=e.toFixed(i).toString().split("."),n=r-a[0].length;o<n;++o)a[0]="0"+a[0];a=(l?"-":"")+a[0]+"."+a[1]}else{for(a=Math.round(e).toString(),n=r-a.length;o<n;++o)a="0"+a;a=(l?"-":"")+a}return a}function c(e,t){var i=void 0,r=!1;return i=0===t.majorTicksDec?Math.round(e).toString():e.toFixed(t.majorTicksDec),t.majorTicksInt>1?(r=~i.indexOf("."),~i.indexOf("-")?"-"+[t.majorTicksInt+t.majorTicksDec+2+(r?1:0)-i.length].join("0")+i.replace("-",""):[t.majorTicksInt+t.majorTicksDec+1+(r?1:0)-i.length].join("0")+i):i}function h(e){return e*Math.PI/180}function u(e,t){return{x:-e*Math.sin(t),y:e*Math.cos(t)}}function f(e,t,i,r){var o=arguments.length<=4||void 0===arguments[4]||arguments[4],n=arguments.length<=5||void 0===arguments[5]?0:arguments[5],a=e.createLinearGradient(o?0:n,o?n:0,o?0:r,o?r:0);return a.addColorStop(0,t),a.addColorStop(1,i),a}function v(e,t){t.needleShadow&&(e.shadowOffsetX=2,e.shadowOffsetY=2,e.shadowBlur=10,e.shadowColor=t.colorNeedleShadowDown)}function m(e,t,i,r,o,n){if(t.valueBox){var a=t.valueText||d(i,t);e.shadowOffsetX=null,e.shadowOffsetY=null,e.shadowBlur=null,e.shadowColor="",e.strokeStyle=null,e.lineWidth=0,e.save(),e.font=t.fontValueSize*(n/200)+"px "+t.fontValue,e.save(),e.beginPath();var l=.12*n,c=e.measureText(t.valueText?a:"-"+d(0,t)).width,h=-c/2-.025*n,u=o-l-.04*n,f=c+.05*n,v=l+.07*n,m=n*t.valueBoxBorderRadius/100;m?s(e,h,u,f,v,m):e.rect(h,u,f,v);var g=o-.12*n-.025*n+(.12*n+.045*n)/2;if(t.valueBoxStroke){var b=e.createRadialGradient(r,g,n/10,r,g,n/5);b.addColorStop(0,t.colorValueBoxRect),b.addColorStop(1,t.colorValueBoxRectEnd),e.strokeStyle=b,e.lineWidth=n*t.valueBoxStroke/100,e.stroke()}t.colorValueBoxShadow&&(e.shadowBlur=.012*n,e.shadowColor=t.colorValueBoxShadow),t.colorValueBoxBackground&&(e.fillStyle=t.colorValueBoxBackground,e.fill()),e.closePath(),e.restore(),t.valueTextShadow&&(e.shadowOffsetX=.004*n,e.shadowOffsetY=.004*n,e.shadowBlur=.012*n,e.shadowColor=t.colorValueTextShadow),e.fillStyle=t.colorValueText,e.textAlign="center",e.fillText(a,-r,o),e.restore()}}function g(e,t,i,r){t.beginPath(),t.arc(0,0,se(e),0,2*ue,!0),t.fillStyle=he.linearGradient(t,i,r,e),t.fill(),t.closePath()}function b(e,t){return e.maxRadius||(e.maxRadius=e.max-t.borderShadowWidth-t.borderOuterWidth-t.borderMiddleWidth-t.borderInnerWidth),e.maxRadius}function p(e,t){var i=t.borderShadowWidth,r=e.max-t.borderShadowWidth,o=r-t.borderOuterWidth,n=o-t.borderMiddleWidth,a=b(e,t),l=void 0;e.save(),t.borderOuterWidth&&g(r,e,t.colorBorderOuter,t.colorBorderOuterEnd),t.borderMiddleWidth&&g(o,e,t.colorBorderMiddle,t.colorBorderMiddleEnd),t.borderInnerWidth&&g(n,e,t.colorBorderInner,t.colorBorderInnerEnd),i&&(e.shadowBlur=i,e.shadowColor=t.colorBorderShadow),e.beginPath(),e.arc(0,0,se(a),0,2*ue,!0),t.colorPlateEnd?(l=e.createRadialGradient(0,0,a/2,0,0,a),l.addColorStop(0,t.colorPlate),l.addColorStop(1,t.colorPlateEnd)):l=t.colorPlate,e.fillStyle=l,e.fill(),e.closePath(),e.restore()}function w(e,t){e.save();for(var i=se(y(e,t)),r=se(i-.15*e.max),o=0,n=t.highlights.length;o<n;o++){var a=t.highlights[o],l=(t.maxValue-t.minValue)/t.ticksAngle,s=he.radians(t.startAngle+(a.from-t.minValue)/l),d=he.radians(t.startAngle+(a.to-t.minValue)/l),c=he.radialPoint(r,s),h=he.radialPoint(i,s),u=he.radialPoint(i,d),f=he.radialPoint(r,d);e.beginPath(),e.rotate(fe),e.arc(0,0,i,s,d,!1),e.restore(),e.save(),e.moveTo(c.x,c.y),e.lineTo(h.x,h.y),e.lineTo(u.x,u.y),e.lineTo(f.x,f.y),e.lineTo(c.x,c.y),e.closePath(),e.fillStyle=a.color,e.fill(),e.beginPath(),e.rotate(fe),e.arc(0,0,r,s-.2,d+.2,!1),e.restore(),e.closePath(),e.fillStyle=t.colorPlate,e.fill(),e.save()}}function x(e,t){var i=y(e,t);e.lineWidth=ne.pixelRatio,e.strokeStyle=t.colorMinorTicks,e.save();for(var r=t.minorTicks*(t.majorTicks.length-1),o=0;o<r;++o){var n=t.startAngle+o*(t.ticksAngle/r);e.rotate(he.radians(n)),e.beginPath(),e.moveTo(0,i),e.lineTo(0,i-.075*e.max),S(e)}}function y(e,t){return b(e,t)-.05*e.max}function T(e,t){var i=se(y(e,t)),r=void 0,o=void 0,n=t.majorTicks.length,a=ne.pixelRatio;for(e.lineWidth=2*a,e.save(),0===n&&(t.majorTicks.push(he.formatMajorTickNumber(t.minValue,t)),t.majorTicks.push(he.formatMajorTickNumber(t.maxValue,t)),n=2),o=t.colorMajorTicks instanceof Array?t.colorMajorTicks:Array(n).fill(t.colorMajorTicks),r=0;r<n;++r)e.strokeStyle=o[r],e.rotate(he.radians(k(t,r,n))),e.beginPath(),e.moveTo(0,i),e.lineTo(0,i-.15*e.max),S(e);t.strokeTicks&&(e.strokeStyle=o[0],e.rotate(fe),e.beginPath(),e.arc(0,0,i,he.radians(t.startAngle),he.radians(t.startAngle+t.ticksAngle),!1),S(e))}function k(e,t,i){return e.startAngle+t*(e.ticksAngle/(i-1))}function S(e){e.stroke(),e.restore(),e.closePath(),e.save()}function O(e,t){var i=b(e,t)-.35*e.max,r={},o=0,n=t.majorTicks.length,a="needle"!==t.animationTarget,l=t.colorNumbers instanceof Array?t.colorNumbers:Array(n).fill(t.colorNumbers),s=a?-(t.value-t.minValue)/(t.maxValue-t.minValue)*t.ticksAngle:0;for(a&&(e.save(),e.rotate(-he.radians(s)));o<n;++o){var d=s+k(t,o,n),c=he.radialPoint(i,he.radians(d));360===d&&(d=0),r[d]||(r[d]=!0,e.font=t.fontNumbersSize*(e.max/200)+"px "+t.fontNumbers,e.fillStyle=l[o],e.lineWidth=0,e.textAlign="center",e.fillText(t.majorTicks[o],c.x,c.y+3))}a&&e.restore()}function P(e,t){t.title&&(e.save(),e.font=t.fontTitleSize*(e.max/200)+"px "+t.fontTitle,e.fillStyle=t.colorTitle,e.textAlign="center",e.fillText(t.title,0,-e.max/4.25,.8*e.max),e.restore())}function W(e,t){t.units&&(e.save(),e.font=t.fontUnitsSize*(e.max/200)+"px "+t.fontUnits,e.fillStyle=t.colorUnits,e.textAlign="center",e.fillText(t.units,0,e.max/3.25,.8*e.max),e.restore())}function B(e,t){if(t.needle){var i=t.value,r=b(e,t),o=se(r/100*t.needleCircleSize),n=se(r/100*t.needleCircleSize*.75),a=se(r/100*t.needleEnd),l=se(t.needleStart?r/100*t.needleStart:0),s=se(.2*r),d=r/100*t.needleWidth,c=r/100*t.needleWidth/2,h=ne.pixelRatio,u="needle"!==t.animationTarget;e.save(),he.drawNeedleShadow(e,t),e.rotate(he.radians(u?t.startAngle:t.startAngle+(i-t.minValue)/(t.maxValue-t.minValue)*t.ticksAngle)),e.fillStyle=he.linearGradient(e,t.colorNeedle,t.colorNeedleEnd,a-s),"arrow"===t.needleType?(e.beginPath(),e.moveTo(-c,-s),e.lineTo(-d,0),e.lineTo(-1*h,a),e.lineTo(h,a),e.lineTo(d,0),e.lineTo(c,-s),e.closePath(),e.fill(),e.beginPath(),e.lineTo(-.5*h,a),e.lineTo(-1*h,a),e.lineTo(-d,0),e.lineTo(-c,-s),e.lineTo(c/2*h-2*h,-s),e.closePath(),e.fillStyle=t.colorNeedleShadowUp,e.fill()):(e.beginPath(),e.moveTo(-c,a),e.lineTo(-c,l),e.lineTo(c,l),e.lineTo(c,a),e.closePath(),e.fill()),t.needleCircleSize&&(he.drawNeedleShadow(e,t),t.needleCircleOuter&&(e.beginPath(),e.arc(0,0,o,0,2*ue,!0),e.fillStyle=he.linearGradient(e,t.colorNeedleCircleOuter,t.colorNeedleCircleOuterEnd,o),e.fill(),e.closePath()),t.needleCircleInner&&(e.beginPath(),e.arc(0,0,n,0,2*ue,!0),e.fillStyle=he.linearGradient(e,t.colorNeedleCircleInner,t.colorNeedleCircleInnerEnd,n),e.fill(),e.closePath()),e.restore())}}function C(e,t,i){he.drawValueBox(e,t,i,0,e.max-.33*e.max,e.max)}function M(e,t,i,r,o,n,a,l){e.beginPath(),e.fillStyle=l?he.linearGradient(e,a,l,o>n?o:n,n>o,o>n?i:r):a,t>0?he.roundRect(e,i,r,o,n,t):e.rect(i,r,o,n),e.fill(),e.closePath()}function V(e,t,i,r,o,n){var a=ne.pixelRatio,l=n>=o,s=l?.85*o:n,d=l?n:o;i=l?le(i+(o-s)/2):i;var c=!!t.title,h=!!t.units,u=!!t.valueBox,f=void 0,v=void 0,m=void 0;l?(v=le(.05*d),f=le(.075*d),m=le(.075*d),c&&(d-=f,r+=f),h&&(d-=v),u&&(d-=m)):(v=f=le(.15*s),c&&(s-=f,r+=f),h&&(s-=v));var g=2*t.barStrokeWidth,b=t.barBeginCircle?le(s*t.barBeginCircle/200-g/2):0,p=le(s*t.barWidth/100-g),w=le(d*t.barLength/100-g),x=le((d-w)/2),y=le(i+(l?s/2:x+b)),T=le(r+(l?d-x-b+g/2:s/2)),k=!l||t.hasLeft&&t.hasRight?0:(t.hasRight?-1:1)*t.ticksWidth/100*s,S=l||t.hasLeft&&t.hasRight?0:(t.hasRight?-1:1)*t.ticksWidth/100*s;return e.barDimensions={isVertical:l,width:s,length:d,barWidth:p,barLength:w,strokeWidth:g,barMargin:x,radius:b,pixelRatio:a,barOffset:null,titleMargin:c?f:0,unitsMargin:h?v:0,get ticksLength(){return this.barLength-this.barOffset-this.strokeWidth},X:i+k,Y:r+S,x0:y+k,y0:T+S,baseX:i,baseY:r,ticksPadding:t.ticksPadding/100},e.barDimensions}function A(e,t,i,r,o,n,a){var l=V(e,t,r,o,n,a),s=l.isVertical,d=l.width,c=l.barWidth,h=l.barLength,u=l.strokeWidth,f=l.barMargin,v=l.radius,m=l.x0,g=l.y0,b=l.X,p=l.Y,w=h;if(e.save(),e.beginPath(),t.barBeginCircle){var x=he.radians(s?270:0),y=Math.asin(c/2/v),T=Math.cos(y),k=Math.sin(y),S=m+(s?v*k:v*T-u/2),O=s?g-v*T:g+v*k,P=se(s?O-g:S-m);e.barDimensions.barOffset=le(P+v);var W=s?le(m-v*k):S,B=s?O:le(g-v*k);"progress"===i&&(h=e.barDimensions.barOffset+(h-e.barDimensions.barOffset)*(t.value-t.minValue)/(t.maxValue-t.minValue));var C=le(S+h-e.barDimensions.barOffset+u/2),M=le(O-h+e.barDimensions.barOffset-u/2);e.arc(m,g,v,x+y,x-y),s?(e.moveTo(S,B),e.lineTo(S,M),e.lineTo(W,M),e.lineTo(W,B)):(e.moveTo(S,B),e.lineTo(C,B),e.lineTo(C,O),e.lineTo(S,O))}else{var A=le(s?b+(d-c)/2:b+f),N=le(s?p+h+f:p+(d-c)/2);"progress"===i&&(h*=(t.value-t.minValue)/(t.maxValue-t.minValue)),s?e.rect(A,N,c,-h):e.rect(A,N,h,c)}"progress"!==i&&t.barStrokeWidth&&(e.lineWidth=u,e.strokeStyle=t.colorBarStroke,e.stroke()),"progress"!==i&&t.colorBar?(e.fillStyle=t.colorBarEnd?he.linearGradient(e,t.colorBar,t.colorBarEnd,h,s,s?p:b):t.colorBar,e.fill()):"progress"===i&&t.colorBarProgress&&(e.fillStyle=t.colorBarProgressEnd?he.linearGradient(e,t.colorBarProgress,t.colorBarProgressEnd,w,s,s?p:b):t.colorBarProgress,e.fill()),e.closePath(),t.barBeginCircle&&(e.barDimensions.radius+=u),e.barDimensions.barWidth+=u,e.barDimensions.barLength+=u}function N(e,t,i,r,o,n){A(e,t,"",i,r,o,n)}function j(e,t){return t.needleSide!==e||t.tickSide!==e||t.numberSide!==e}function E(e,t,i,r,o,n){t.barProgress&&A(e,t,"progress",i,r,o,n)}function R(e,t){var i=e.barDimensions,r=i.isVertical,o=i.width,n=i.length,a=i.barWidth,l=i.barOffset,s=i.barMargin,d=i.X,c=i.Y,h=i.ticksLength,u=i.ticksPadding;if(t.highlights){var f="right"!==t.tickSide,v="left"!==t.tickSide,m=0,g=t.highlights.length,b=(o-a)/2,p=t.maxValue-t.minValue,w=le(r?d+b:d+s+l),x=t.ticksWidth/100*o,y=r?c+n-s-l:c+b,T=le((t.ticksWidth/100+u)*o),k=le(a+u*o);for(e.save();m<g;m++){var S=t.highlights[m],O=h*se(S.from)/p,P=h*se((S.to-S.from)/p);e.beginPath(),e.fillStyle=S.color,r?(f&&e.rect(w-T,y-O,x,-P),v&&e.rect(w+k,y-O,x,-P)):(f&&e.rect(w+O,y-T,P,x),v&&e.rect(w+O,y+k,P,x)),e.fill(),e.closePath()}}}function D(e,t,i,r,o){e.beginPath(),e.moveTo(t,i),e.lineTo(r,o),e.stroke(),e.closePath(),e.save()}function I(e,t,i,r,o,n,a,l){var s=e.barDimensions,d=s.isVertical,c=s.length,h=s.barWidth,u=s.barOffset,f=s.barMargin,v=s.pixelRatio,m=s.width,g=s.X,b=s.Y,p=s.ticksLength,w=s.ticksPadding,x=(m-h)/2,y=void 0,T=void 0,k=0,S=l*m,O=x-w*m,P=x+h+S+w*m,W=p/(i-r),B=t instanceof Array?t:Array(i).fill(t);for(e.lineWidth=a*v,e.save();k<i;k++)e.strokeStyle=B[k],d?(T=b+c-f-u-k*W,o&&(y=g+O,D(e,y,T,le(y-S),T)),n&&(y=g+P,D(e,y,T,le(y-S),T))):(y=g+f+u+k*W,o&&(T=b+O,D(e,y,T,y,le(T-S))),n&&(T=b+P,D(e,y,le(T),y,T-S)))}function z(e){return e.majorTicks.length||(e.majorTicks.push(he.formatMajorTickNumber(e.minValue,e)),e.majorTicks.push(he.formatMajorTickNumber(e.maxValue,e))),["right"!==e.tickSide,"left"!==e.tickSide]}function L(e,t){var i=z(t),r=K(i,2),o=r[0],n=r[1],a=2,l=t.colorMajorTicks instanceof Array?t.colorMajorTicks:Array(t.colorMajorTicks.length).fill(t.colorMajorTicks);if(I(e,t.colorMajorTicks,t.majorTicks.length,1,o,n,a,t.ticksWidth/100),t.strokeTicks){var s=e.barDimensions,d=s.isVertical,c=s.length,h=s.width,u=s.barWidth,f=s.barMargin,v=s.barOffset,m=s.X,g=s.Y,b=s.ticksLength,p=s.pixelRatio,w=s.ticksPadding,x=(h-u)/2+u+w*h,y=(h-u)/2-w*h,T=void 0,k=void 0,S=void 0,O=void 0;e.strokeStyle=l[0],a*=p,d?(k=g+c-f-v+a/2,O=k-b-a,o&&(S=T=le(m+y),_(e,T,k,S,O)),n&&(S=T=le(m+x),_(e,T,k,S,O))):(T=m+f+v-a/2,S=T+b+a,o&&(O=k=le(g+y),_(e,T,k,S,O)),n&&(O=k=le(g+x),_(e,T,k,S,O)))}}function _(e,t,i,r,o){e.beginPath(),e.moveTo(t,i),e.lineTo(r,o),e.stroke(),e.closePath()}function G(e,t){var i=z(t),r=K(i,2),o=r[0],n=r[1];I(e,t.colorMinorTicks,t.minorTicks*(t.majorTicks.length-1),0,o,n,1,t.ticksWidthMinor/100)}function X(e,t){var i=e.barDimensions,r=i.isVertical,o=i.length,n=i.width,a=i.barWidth,l=i.barMargin,s=i.barOffset,d=i.X,c=i.Y,h=i.ticksLength,u=i.ticksPadding,f=t.majorTicks.length,v="right"!==t.numberSide,m="left"!==t.numberSide,g=t.fontNumbersSize*n/200,b=0,p=(t.ticksWidth/100+2*u)*n,w=(n-a)/2-p,x=(n-a)/2+a+p,y=void 0,T=void 0,k=void 0,S=void 0,O=void 0,P=t.colorNumbers instanceof Array?t.colorNumbers:Array(f).fill(t.colorNumbers);for(e.font=g+"px "+t.fontNumbers,e.lineWidth=0,e.textAlign="center";b<f;b++)e.fillStyle=P[b],O=t.majorTicks[b],S=b*h/(f-1),r?(T=c+o-l-s-S+g/3,v&&(e.textAlign="right",e.fillText(O,d+w,T)),m&&(e.textAlign="left",e.fillText(O,d+x,T))):(k=e.measureText(O).width,y=d+l+s+S,v&&e.fillText(O,y,c+w),m&&e.fillText(O,y,c+x+g))}function Y(e,t){if(t.title){var i=e.barDimensions,r=i.isVertical,o=i.width,n=i.length,a=i.baseX,l=i.baseY,s=i.titleMargin,d=t.fontTitleSize*o/200,c=le(a+(r?o:n)/2),h=le(l+s/2-(r?d:d/2)-.025*(r?n:o));e.save(),e.textAlign="center",e.fillStyle=t.colorTitle,e.font=d+"px "+t.fontTitle,e.lineWidth=0,e.fillText(t.title,c,h,r?o:n)}}function U(e,t){if(t.units){var i=e.barDimensions,r=i.isVertical,o=i.width,n=i.length,a=i.baseX,l=i.baseY,s=i.unitsMargin,d=t.fontUnitsSize*o/200,c=le(a+(r?o:n)/2),h=le(l+(r?n:o)+s/2-d/2);e.save(),e.textAlign="center",e.fillStyle=t.colorTitle,e.font=d+"px "+t.fontUnits,e.lineWidth=0,e.fillText(t.units,c,h,r?o:n)}}function F(e,t){if(t.needle){var i=e.barDimensions,r=i.isVertical,o=i.width,n=i.length,a=i.barWidth,l=i.barOffset,s=i.barMargin,d=i.ticksLength,c=i.X,h=i.Y,u=i.ticksPadding,f="right"!==t.needleSide,v="left"!==t.needleSide,m=d*(t.value-t.minValue)/(t.maxValue-t.minValue),g=(t.ticksWidth/100+u)*o,b=a/2+g,p=b*(t.needleEnd/100),w=void 0,x=void 0,y=void 0,T=void 0,k="arrow"===t.needleType.toLowerCase()?J:H,S=(o-a)/2,O=b*(t.needleStart/100),P=S-g-O,W=S+a+g+O;e.save(),he.drawNeedleShadow(e,t),r?(y=le(h+n-s-l-m),f&&(w=le(c+P),x=w+p,k(e,t,w,y,x,y,p)),v&&(w=le(c+W),x=w-p,k(e,t,w,y,x,y,p,!0))):(w=le(c+s+l+m),f&&(y=le(h+P),T=y+p,k(e,t,w,y,w,T,p)),v&&(y=le(h+W),T=y-p,k(e,t,w,y,w,T,p,!0))),e.restore()}}function q(e,t,i,r){return t.colorNeedleEnd?he.linearGradient(e,r?t.colorNeedleEnd:t.colorNeedle,r?t.colorNeedle:t.colorNeedleEnd,i,!e.barDimensions.isVertical):t.colorNeedle}function H(e,t,i,r,o,n,a,l){e.lineWidth=t.needleWidth,e.strokeStyle=q(e,t,a,l),e.beginPath(),e.moveTo(i,r),e.lineTo(o,n),e.stroke(),e.closePath()}function J(e,t,i,r,o,n,a,l){var s=le(.4*a),d=a-s,c=i===o,h=t.needleWidth/2;e.fillStyle=q(e,t,a,l),e.beginPath(),c?(r>n&&(d*=-1),e.moveTo(i-h,r),e.lineTo(i+h,r),e.lineTo(i+h,r+d),e.lineTo(i,n),e.lineTo(i-h,r+d),e.lineTo(i-h,r)):(i>o&&(d*=-1),e.moveTo(i,r-h),e.lineTo(i,r+h),e.lineTo(i+d,r+h),e.lineTo(o,r),e.lineTo(i+d,r-h),e.lineTo(i,r-h)),e.fill(),e.closePath()}function Z(e,t,i,r,o,n,a){e.barDimensions.isVertical&&he.drawValueBox(e,t,i,r+n/2,o+a-40*(n/300),n)}function $(e,t,i,r,o,n){e.save();var a=t.borderRadius,l=o-t.borderShadowWidth,s=l-2*t.borderOuterWidth,d=s-2*t.borderMiddleWidth,c=d-2*t.borderInnerWidth,h=n-2*t.borderShadowWidth,u=h-2*t.borderOuterWidth,f=u-2*t.borderMiddleWidth,v=f-2*t.borderInnerWidth,m=i-(s-l)/2,g=m-(d-s)/2,b=g-(c-d)/2,p=r-(u-h)/2,w=p-(f-u)/2,x=w-(v-f)/2;return t.borderOuterWidth&&M(e,a,i,r,l,h,t.colorBorderOuter,t.colorBorderOuterEnd),t.borderMiddleWidth&&M(e,--a,m,p,s,u,t.colorBorderMiddle,t.colorBorderMiddleEnd),t.borderInnerWidth&&M(e,--a,g,w,d,f,t.colorBorderInner,t.colorBorderInnerEnd),t.borderShadowWidth&&(e.shadowBlur=t.borderShadowWidth,e.shadowColor=t.colorBorderShadow),M(e,a,b,x,c,v,t.colorPlate,t.colorPlateEnd),e.restore(),[b,x,c,v]}var K=function(){function e(e,t){var i=[],r=!0,o=!1,n=void 0;try{for(var a,l=e[Symbol.iterator]();!(r=(a=l.next()).done)&&(i.push(a.value),!t||i.length!==t);r=!0);}catch(e){o=!0,n=e}finally{try{!r&&l.return&&l.return()}finally{if(o)throw n}}return i}return function(t,i){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),Q=function e(t,i,r){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,i);if(void 0===o){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,i,r)}if("value"in o)return o.value;var a=o.get;if(void 0!==a)return a.call(r)},ee=function(){function e(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,i,r){return i&&e(t.prototype,i),r&&e(t,r),t}}();Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var i=Object(e),r=1;r<arguments.length;r++){var o=arguments[r];if(void 0!==o&&null!==o)for(var n=Object.keys(Object(o)),a=0,l=n.length;a<l;a++){var s=n[a],d=Object.getOwnPropertyDescriptor(o,s);void 0!==d&&d.enumerable&&(i[s]=o[s])}}return i}}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){var i;if(null==this)throw new TypeError('"this" is null or not defined');var r=Object(this),o=r.length>>>0;if(0===o)return-1;var n=+t||0;if(Math.abs(n)===1/0&&(n=0),n>=o)return-1;for(i=Math.max(n>=0?n:o-Math.abs(n),0);i<o;){if(i in r&&r[i]===e)return i;i++}return-1});var te=n("requestAnimationFrame")||function(e){return setTimeout(function(){return e((new Date).getTime())},1e3/60)},ie={linear:function(e){return e},quad:function(e){return Math.pow(e,2)},dequad:function(e){return 1-ie.quad(1-e)},quint:function(e){return Math.pow(e,5)},dequint:function(e){return 1-Math.pow(1-e,5)},cycle:function(e){return 1-Math.sin(Math.acos(e))},decycle:function(e){return Math.sin(Math.acos(1-e))},bounce:function(e){return 1-ie.debounce(1-e)},debounce:function(e){for(var t=0,i=1;1;t+=i,i/=2)if(e>=(7-4*t)/11)return-Math.pow((11-6*t-11*e)/4,2)+Math.pow(i,2)},elastic:function(e){return 1-ie.delastic(1-e)},delastic:function(e){var t=1.5;return Math.pow(2,10*(e-1))*Math.cos(20*Math.PI*t/3*e)}},re=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?"linear":arguments[0],i=arguments.length<=1||void 0===arguments[1]?250:arguments[1],r=arguments.length<=2||void 0===arguments[2]?function(){}:arguments[2],n=arguments.length<=3||void 0===arguments[3]?function(){}:arguments[3];if(o(this,t),this.duration=i,this.rule=e,this.draw=r,this.end=n,"function"!=typeof this.draw)throw new TypeError("Invalid animation draw callback:",r);if("function"!=typeof this.end)throw new TypeError("Invalid animation end callback:",n)}return ee(t,[{key:"animate",value:function(t,i){var r=this,o=e.performance&&e.performance.now?e.performance.now():n("animationStartTime")||Date.now();t=t||this.draw,i=i||this.end,this.frame=te(function(e){return a(e,t,o,ie[r.rule]||r.rule,r.duration,i,r)})}},{key:"destroy",value:function(){if(this.frame){var e=n("cancelAnimationFrame")||function(e){};e(this.frame),this.frame=null}this.draw=null,this.end=null}}]),t}();re.rules=ie;var oe=function(){function t(i,r,n){o(this,t),this.options=i,this.element=r.toLowerCase(),this.type=t.toDashed(n),this.Type=e[n],this.mutationsObserved=!1,this.isObservable=!!e.MutationObserver,t.domReady(this.traverse.bind(this))}return ee(t,[{key:"isValidNode",value:function(e){return!(!e.tagName||e.tagName.toLowerCase()!==this.element||e.getAttribute("data-type")!==this.type)}},{key:"traverse",value:function(){for(var t=document.getElementsByTagName(this.element),i=0,r=t.length;i<r;i++)this.process(t[i]);this.isObservable&&!this.mutationsObserved&&(new e.MutationObserver(this.observe.bind(this)).observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),this.mutationsObserved=!0)}},{key:"observe",value:function(e){for(var t=this,i=0,r=e.length,o=function(){var r=e[i];if("attributes"===r.type&&"data-type"===r.attributeName&&t.isValidNode(r.target)&&r.oldValue!==t.type)setTimeout(function(){return t.process(r.target)});else if(r.addedNodes&&r.addedNodes.length)for(var o=0,n=r.addedNodes.length;o<n;o++)t.process(r.addedNodes[o])};i<r;i++)o()}},{key:"process",value:function(i){var r=this;if(!this.isValidNode(i))return null;var o=void 0,n=JSON.parse(JSON.stringify(this.options)),a=null;for(o in n)if(n.hasOwnProperty(o)){var l=t.toAttributeName(o),s=t.parse(i.getAttribute(l));null!==s&&void 0!==s&&(n[o]=s)}return n.renderTo=i,a=new this.Type(n),a.draw&&a.draw(),this.isObservable?(a.observer=new e.MutationObserver(function(e){e.forEach(function(e){if("attributes"===e.type){var t=e.attributeName.toLowerCase(),o=i.getAttribute(t).toLowerCase();if("data-type"===t&&o&&o!==r.type)a.observer.disconnect(),delete a.observer,a.destroy&&a.destroy();else if("data-"===t.substr(0,5)){var n=t.substr(5).split("-").map(function(e,t){return t?e.charAt(0).toUpperCase()+e.substr(1):e}).join(""),l={};l[n]=i.getAttribute(e.attributeName),a.update&&a.update(l)}}})}),a.observer.observe(i,{attributes:!0}),a):a}}],[{key:"parse",value:function(e){if("true"===e)return!0;if("false"===e)return!1;if("undefined"!==e){if("null"===e)return null;if(/^[-+#.\w\d\s]+(?:,[-+#.\w\d\s]*)+$/.test(e))return e.split(",");try{return JSON.parse(e)}catch(e){}return e}}},{key:"toDashed",value:function(e){for(var t=e.split(/(?=[A-Z])/),i=1,r=t.length,o=t[0].toLowerCase();i<r;i++)o+="-"+t[i].toLowerCase();return o}},{key:"toAttributeName",value:function(e){return"data-"+t.toDashed(e)}},{key:"domReady",value:function(t){return/comp|inter|loaded/.test((e.document||{}).readyState+"")?t():void(e.addEventListener?e.addEventListener("DOMContentLoaded",t,!1):e.attachEvent&&e.attachEvent("onload",t))}}]),t}(),ne=function(){function t(e,i,r){o(this,t),t.collection.push(this),this.width=i||0,this.height=r||0,this.element=e,this.init()}return ee(t,[{key:"init",value:function(){var e=t.pixelRatio;this.element.width=this.width*e,this.element.height=this.height*e,this.element.style.width=this.width+"px",this.element.style.height=this.height+"px",this.elementClone=this.element.cloneNode(!0),this.context=this.element.getContext("2d"),this.contextClone=this.elementClone.getContext("2d"),this.drawWidth=this.element.width,this.drawHeight=this.element.height,this.drawX=this.drawWidth/2,this.drawY=this.drawHeight/2,this.minSide=this.drawX<this.drawY?this.drawX:this.drawY,this.elementClone.initialized=!1,this.contextClone.translate(this.drawX,this.drawY),this.contextClone.save(),this.context.translate(this.drawX,this.drawY),this.context.save(),this.context.max=this.contextClone.max=this.minSide,this.context.maxRadius=this.contextClone.maxRadius=null}},{key:"destroy",value:function(){var e=t.collection.indexOf(this);~e&&t.collection.splice(e,1),this.context.clearRect(-this.drawX,-this.drawY,this.drawWidth,this.drawHeight),this.context.max=null,delete this.context.max,this.context.maxRadius=null,delete this.context.maxRadius,this.context=null,this.contextClone=null,this.elementClone=null,this.element=null,this.onRedraw=null}},{key:"commit",value:function(){var e=t.pixelRatio;return 1!==e&&(this.contextClone.scale(e,e),this.contextClone.save()),this}},{key:"redraw",value:function(){return this.init(),this.onRedraw&&this.onRedraw(),this}}],[{key:"redraw",value:function(){for(var e=0,i=t.collection.length;e<i;e++)t.collection[e].redraw()}},{key:"pixelRatio",get:function(){return e.devicePixelRatio||1}}]),t}();ne.collection=[],e.matchMedia&&e.matchMedia("screen and (min-resolution: 2dppx)").addListener(ne.redraw);var ae={renderTo:null,width:0,height:0,minValue:0,maxValue:100,value:0,units:!1,majorTicks:[0,20,40,60,80,100],minorTicks:10,strokeTicks:!0,animatedValue:!1,animateOnInit:!1,title:!1,borders:!0,valueInt:3,valueDec:2,majorTicksInt:1,majorTicksDec:0,animation:!0,animationDuration:500,animationRule:"cycle",colorPlate:"#fff",colorPlateEnd:"",colorMajorTicks:"#444",colorMinorTicks:"#666",colorTitle:"#888",colorUnits:"#888",colorNumbers:"#444",colorNeedle:"rgba(240,128,128,1)",colorNeedleEnd:"rgba(255,160,122,.9)",colorValueText:"#444",colorValueTextShadow:"rgba(0,0,0,0.3)",colorBorderShadow:"rgba(0,0,0,0.5)",colorBorderOuter:"#ddd",colorBorderOuterEnd:"#aaa",colorBorderMiddle:"#eee",colorBorderMiddleEnd:"#f0f0f0",colorBorderInner:"#fafafa",colorBorderInnerEnd:"#ccc",colorValueBoxRect:"#888",colorValueBoxRectEnd:"#666",colorValueBoxBackground:"#babab2",colorValueBoxShadow:"rgba(0,0,0,1)",colorNeedleShadowUp:"rgba(2,255,255,0.2)",colorNeedleShadowDown:"rgba(188,143,143,0.45)",fontNumbers:"Arial",fontTitle:"Arial",fontUnits:"Arial",fontValue:"Arial",fontNumbersSize:20,fontTitleSize:24,fontUnitsSize:22,fontValueSize:40,needle:!0,needleShadow:!0,needleType:"arrow",needleStart:5,needleEnd:85,needleWidth:4,borderOuterWidth:3,borderMiddleWidth:3,borderInnerWidth:3,borderShadowWidth:3,valueBox:!0,valueBoxStroke:5,valueText:"",valueTextShadow:!0,valueBoxBorderRadius:2.5,highlights:[{from:20,to:60,color:"#eee"},{from:60,to:80,color:"#ccc"},{from:80,to:100,color:"#999"}]};l.prototype=Object.create(Array.prototype),l.prototype.constructor=l,l.prototype.get=function(e){if("string"==typeof e)for(var t=0,i=this.length;t<i;t++){var r=this[t].options.renderTo.tagName?this[t].options.renderTo:document.getElementById(this[t].options.renderTo||"");if(r.getAttribute("id")===e)return this[t]}else if("number"==typeof e)return this[e];return null};var le=Math.round,se=Math.abs,de=new l,ce=function(){function t(i){o(this,t);var r=this.constructor.name;if("BaseGauge"===r)throw new TypeError("Attempt to instantiate abstract class!");if(de.push(this),this.type=e[r],this.initialized=!1,i.minValue=parseFloat(i.minValue),i.maxValue=parseFloat(i.maxValue),i.value=parseFloat(i.value)||0,i.borders||(i.borderInnerWidth=i.borderMiddleWidth=i.borderOuterWidth=0),!i.renderTo)throw TypeError("Canvas element was not specified when creating the Gauge object!");var n=i.renderTo.tagName?i.renderTo:document.getElementById(i.renderTo);if(!(n instanceof HTMLCanvasElement))throw TypeError("Given gauge canvas element is invalid!");i.width=parseFloat(i.width)||0,i.height=parseFloat(i.height)||0,i.width&&i.height||(i.width||(i.width=n.parentNode?n.parentNode.offsetWidth:n.offsetWidth),i.height||(i.height=n.parentNode?n.parentNode.offsetHeight:n.offsetHeight)),this.options=i||{},this.options.animateOnInit&&(this._value=this.options.value,this.options.value=this.options.minValue),this.canvas=new ne(n,i.width,i.height),this.canvas.onRedraw=this.draw.bind(this),this.animation=new re(i.animationRule,i.animationDuration)}return ee(t,[{key:"update",value:function(e){return Object.assign(this.options,e||{}),this.canvas.width=this.options.width,this.canvas.height=this.options.height,this.animation.rule=this.options.animationRule,this.animation.duration=this.options.animationDuration,this.canvas.redraw(),this}},{key:"destroy",value:function(){var e=de.indexOf(this);~e&&de.splice(e,1),this.canvas.destroy(),this.canvas=null,this.animation.destroy(),this.animation=null}},{key:"draw",value:function(){this.options.animateOnInit&&!this.initialized&&(this.value=this._value,this.initialized=!0)}},{key:"value",set:function(e){var t=this,i=this.options.value;e!==this.options.value&&(this.options.animation?(this._value=e,this.animation.animate(function(r){t.options.value=i+(e-i)*r,t.draw()},function(){t.options.value=e,delete t._value,t.draw()})):(this.options.value=e,this.draw()))},get:function(){return"undefined"==typeof this._value?this.options.value:this._value}}],[{key:"initialize",value:function(e,t){new oe(t,"canvas",e)}}]),t}();"undefined"!=typeof e&&(e.BaseGauge=ce,(e.document||e).gauges=de);var he={roundRect:s,padValue:d,formatMajorTickNumber:c,radians:h,radialPoint:u,linearGradient:f,drawNeedleShadow:v,drawValueBox:m},ue=Math.PI,fe=ue/2,ve=Object.assign({},ae,{ticksAngle:270,startAngle:45,colorNeedleCircleOuter:"#f0f0f0",colorNeedleCircleOuterEnd:"#ccc",colorNeedleCircleInner:"#e8e8e8",colorNeedleCircleInnerEnd:"#f5f5f5",needleCircleSize:10,needleCircleInner:!0,needleCircleOuter:!0,animationTarget:"needle"}),me=function(e){function t(e){return o(this,t),e=Object.assign({},ve,e||{}),isNaN(e.startAngle)&&(e.startAngle=45),isNaN(e.ticksAngle)&&(e.ticksAngle=270),e.ticksAngle>360&&(e.ticksAngle=360),e.ticksAngle<0&&(e.ticksAngle=0),e.startAngle<0&&(e.startAngle=0),e.startAngle>360&&(e.startAngle=360),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return r(t,e),ee(t,[{key:"draw",value:function(){var e=this.canvas,i=-e.drawX,r=-e.drawY,o=e.drawWidth,n=e.drawHeight,a=this.options;if("needle"===a.animationTarget){if(!e.elementClone.initialized){var l=e.contextClone;l.clearRect(i,r,o,n),l.save(),p(l,a),w(l,a),x(l,a),T(l,a),O(l,a),P(l,a),W(l,a),e.elementClone.initialized=!0}this.canvas.commit(),e.context.clearRect(i,r,o,n),e.context.save(),e.context.drawImage(e.elementClone,i,r,o,n),e.context.save(),C(e.context,a,a.animatedValue?this.options.value:this.value),B(e.context,a)}else{var s=-he.radians((a.value-a.minValue)/(a.maxValue-a.minValue)*a.ticksAngle);if(e.context.clearRect(i,r,o,n),e.context.save(),p(e.context,a),e.context.rotate(s),w(e.context,a),x(e.context,a),T(e.context,a),O(e.context,a),e.context.rotate(-s),e.context.save(),!e.elementClone.initialized){var d=e.contextClone;d.clearRect(i,r,o,n),d.save(),P(d,a),W(d,a),B(d,a),e.elementClone.initialized=!0}e.context.drawImage(e.elementClone,i,r,o,n)}return C(e.context,a,a.animatedValue?this.options.value:this.value),Q(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"draw",this).call(this),this}}]),t}(ce);"undefined"!=typeof e&&(e.RadialGauge=me),ce.initialize("RadialGauge",ve);var ge=Object.assign({},ae,{borderRadius:0,barBeginCircle:30,barWidth:20,barStrokeWidth:0,barProgress:!0,colorBarStroke:"#222",colorBar:"#ccc",colorBarEnd:"",colorBarProgress:"#888",colorBarProgressEnd:"",needleWidth:6,tickSide:"both",needleSide:"both",numberSide:"both",ticksWidth:10,ticksWidthMinor:5,ticksPadding:5,barLength:85,fontTitleSize:26}),be=function(e){function n(e){return o(this,n),e=Object.assign({},ge,e||{}),e.barStrokeWidth>=e.barWidth&&(e.barStrokeWidth=le(e.barWidth/2)),e.hasLeft=j("right",e),e.hasRight=j("left",e),i(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e))}return r(n,e),ee(n,[{key:"draw",value:function(){var e=this.canvas,i=-e.drawX,r=-e.drawY,o=e.drawWidth,a=e.drawHeight,l=this.options;if(!e.elementClone.initialized){var s=e.contextClone;s.clearRect(i,r,o,a),
s.save(),this.drawBox=$(s,l,i,r,o,a),N.apply(void 0,[s,l].concat(t(this.drawBox))),e.context.barDimensions=s.barDimensions,R(s,l),G(s,l),L(s,l),X(s,l),Y(s,l),U(s,l),e.elementClone.initialized=!0}return this.canvas.commit(),e.context.clearRect(i,r,o,a),e.context.save(),e.context.drawImage(e.elementClone,i,r,o,a),e.context.save(),E.apply(void 0,[e.context,l].concat(t(this.drawBox))),F(e.context,l),Z.apply(void 0,[e.context,l,l.animatedValue?this.options.value:this.value].concat(t(this.drawBox))),Q(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"draw",this).call(this),this}}]),n}(ce);"undefined"!=typeof e&&(e.LinearGauge=be),ce.initialize("LinearGauge",ge),"undefined"!=typeof module&&Object.assign(e,{Collection:l,GenericOptions:ae,Animation:re,BaseGauge:ce,drawings:he,SmartCanvas:ne,vendorize:n})}("undefined"!=typeof module?module.exports:window);
//# sourceMappingURL=gauge.min.js.map