nonlinear-canvas-gauges
Version:
Modification of canvas-gauges. Rendering nonlinear scale.
2 lines • 43.7 kB
JavaScript
!function(o){"use strict";function c(e,t,i){null===e&&(e=Function.prototype);var r=Object.getOwnPropertyDescriptor(e,t);if(void 0===r){var o=Object.getPrototypeOf(e);return null===o?void 0:c(o,t,i)}if("value"in r)return r.value;var n=r.get;return void 0!==n?n.call(i):void 0}var V=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(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}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},e=function(e,t,i){return t&&r(e.prototype,t),i&&r(e,i),e};function r(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)}}function s(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 n(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 t(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 a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){if(void 0!==(t=t||("undefined"==typeof window?global:window))[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(void 0!==a)return a}return null}Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(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(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||Object.defineProperty(Array.prototype,"indexOf",{value: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),o<=n)return-1;for(i=Math.max(0<=n?n:o-Math.abs(n),0);i<o;){if(i in r&&r[i]===e)return i;i++}return-1}}),Array.prototype.fill||Object.defineProperty(Array.prototype,"fill",{value:function(e,t,i){if(null===this)throw new TypeError("this is null or not defined");for(var r=Object(this),o=r.length>>>0,n=t>>0,a=n<0?Math.max(o+n,0):Math.min(n,o),l=void 0===i?o:i>>0,s=l<0?Math.max(o+l,0):Math.min(l,o);a<s;)r[a]=e,a++;return r}}),"undefined"==typeof window&&(window="undefined"==typeof global?{}:global);var i=(e(d,[{key:"emit",value:function(e){if(this._events[e]){for(var t=0,i=this._events[e].length,r=arguments.length,o=Array(1<r?r-1:0),n=1;n<r;n++)o[n-1]=arguments[n];for(;t<i;t++)this._events[e][t]&&this._events[e][t].apply(this,o)}}},{key:"once",value:function(i){for(var e=arguments.length,r=Array(1<e?e-1:0),t=1;t<e;t++)r[t-1]=arguments[t];for(var o=0,n=r.length,a=this,l=function(){var t=r[o];r[o]=function e(){a.off(i,e),t.apply(a,arguments)}};o<n;o++)l();this.on.apply(this,[i].concat(r))}},{key:"on",value:function(e){this._events[e]||(this._events[e]=[]);for(var t=0,i=arguments.length<=1?0:arguments.length-1;t<i;t++)this._events[e].push(arguments.length<=t+1?void 0:arguments[t+1])}},{key:"off",value:function(e){if(this._events[e])for(var t=0,i=arguments.length<=1?0:arguments.length-1;t<i;t++)for(var r=arguments.length<=t+1?void 0:arguments[t+1],o=void 0;~(o=this._events[e].indexOf(r));)this._events[e].splice(o,1)}},{key:"removeAllListeners",value:function(e){delete this._events[e]}},{key:"listeners",get:function(){return this._events}}]),d);function d(){a(this,d),this._events={},this.addListener=this.on,this.removeListener=this.off}var h=l("requestAnimationFrame")||function(e){return setTimeout(function(){return e((new Date).getTime())},1e3/60)},u={linear:function(e){return e},quad:function(e){return Math.pow(e,2)},dequad:function(e){return 1-u.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-u.debounce(1-e)},debounce:function(e){for(var t=0,i=1;;t+=i,i/=2)if((7-4*t)/11<=e)return-Math.pow((11-6*t-11*e)/4,2)+Math.pow(i,2)},elastic:function(e){return 1-u.delastic(1-e)},delastic:function(e){return Math.pow(2,10*(e-1))*Math.cos(20*Math.PI*1.5/3*e)}};var f=(e(m,[{key:"animate",value:function(t,i){var r=this;this.frame&&this.cancel();var o=window.performance&&window.performance.now?window.performance.now():l("animationStartTime")||Date.now();t=t||this.draw,i=i||this.end,this.draw=t,this.end=i,this.frame=h(function(e){return function t(e,i,r,o,n,a,l){if("function"!=typeof o)throw new TypeError("Invalid animation rule:",o);var s=e-r,d=s/n,c=0;1<d&&(d=1),1!==d&&(c=o(d),isFinite(c)&&!isNaN(c)&&(d=c)),i&&i(d),s<n?l.frame=h(function(e){return t(e,i,r,o,n,a,l)}):(a&&a(),l.inProgress=!1)}(e,t,o,u[r.rule]||r.rule,r.duration,i,r)})}},{key:"cancel",value:function(){this.frame&&((l("cancelAnimationFrame")||function(e){})(this.frame),this.frame=null)}},{key:"destroy",value:function(){this.cancel(),this.draw=null,this.end=null}}]),m);function m(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"linear",t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:250,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(){},r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:function(){};if(a(this,m),this.duration=t,this.rule=e,this.draw=i,this.end=r,"function"!=typeof this.draw)throw new TypeError("Invalid animation draw callback:",i);if("function"!=typeof this.end)throw new TypeError("Invalid animation end callback:",r)}f.rules=u;var v=(e(g,[{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 e=document.getElementsByTagName(this.element),t=0,i=e.length;t<i;t++)this.process(e[t]);this.isObservable&&!this.mutationsObserved&&(new 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=0,i=e.length;t<i;t++){var r=e[t];if("attributes"===r.type&&"data-type"===r.attributeName&&this.isValidNode(r.target)&&r.oldValue!==this.type)setTimeout(this.process.bind(this,r.target));else if(r.addedNodes&&r.addedNodes.length)for(var o=0,n=r.addedNodes.length;o<n;o++)setTimeout(this.process.bind(this,r.addedNodes[o]))}}},{key:"process",value:function(n){var a=this;if(!this.isValidNode(n))return null;var e=void 0,t=JSON.parse(JSON.stringify(this.options)),l=null;for(e in t)if(t.hasOwnProperty(e)){var i=g.toAttributeName(e),r=g.parse(n.getAttribute(i));null!=r&&(t[e]=r)}return t.renderTo=n,(l=new this.Type(t)).draw&&l.draw(),this.isObservable&&(l.observer=new MutationObserver(function(e){e.forEach(function(e){if("attributes"===e.type){var t=e.attributeName.toLowerCase(),i=n.getAttribute(t).toLowerCase();if("data-type"===t&&i&&i!==a.type)l.observer.disconnect(),delete l.observer,l.destroy&&l.destroy();else if("data-"===t.substr(0,5)){var r=t.substr(5).split("-").map(function(e,t){return t?e.charAt(0).toUpperCase()+e.substr(1):e}).join(""),o={};o[r]=g.parse(n.getAttribute(e.attributeName)),"value"===r?l&&(l.value=o[r]):l.update&&l.update(o)}}})}),l.observer.observe(n,{attributes:!0})),l}}],[{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:"toCamelCase",value:function(e,t){for(var i=!(1<arguments.length&&void 0!==t)||t,r=e.split(/-/),o=0,n=r.length,a="";o<n;o++)a+=o||i?r[o][0].toUpperCase()+r[o].substr(1).toLowerCase():r[o].toLowerCase();return a}},{key:"toAttributeName",value:function(e){return"data-"+g.toDashed(e)}},{key:"domReady",value:function(e){if(/comp|inter|loaded/.test((window.document||{}).readyState+""))return e();window.addEventListener?window.addEventListener("DOMContentLoaded",e,!1):window.attachEvent&&window.attachEvent("onload",e)}}]),g);function g(e,t,i){a(this,g),this.options=e,this.element=t.toLowerCase(),this.type=g.toDashed(i),this.Type=o[i],this.mutationsObserved=!1,this.isObservable=!!window.MutationObserver,window.GAUGES_NO_AUTO_INIT||g.domReady(this.traverse.bind(this))}var C=(e(b,[{key:"init",value:function(){var e=b.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=b.collection.indexOf(this);~e&&b.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=b.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,t=b.collection.length;e<t;e++)b.collection[e].redraw()}},{key:"pixelRatio",get:function(){return window.devicePixelRatio||1}}]),b);function b(e,t,i){a(this,b),b.collection.push(this),this.width=t||0,this.height=i||0,this.element=e,this.init()}C.collection=[],window.matchMedia&&window.matchMedia("screen and (min-resolution: 2dppx)").addListener(C.redraw);var p={renderTo:null,width:0,height:0,minValue:0,maxValue:100,value:0,units:!1,exactTicks:!1,majorTicks:[0,20,40,60,80,100],minorTicks:10,strokeTicks:!0,animatedValue:!1,animateOnInit:!1,title:!1,borders:!0,numbersMargin:1,listeners:null,valueInt:3,valueDec:2,majorTicksInt:1,majorTicksDec:0,animation:!0,animationDuration:500,animationRule:"cycle",colorPlate:"#fff",colorPlateEnd:"",colorMajorTicks:"#444",colorMinorTicks:"#666",colorStrokeTicks:"",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)",colorBarStroke:"#222",colorBar:"#ccc",colorBarProgress:"#888",colorBarShadow:"#000",fontNumbers:"Arial",fontTitle:"Arial",fontUnits:"Arial",fontValue:"Arial",fontNumbersSize:20,fontTitleSize:24,fontUnitsSize:22,fontValueSize:26,fontNumbersStyle:"normal",fontTitleStyle:"normal",fontUnitsStyle:"normal",fontValueStyle:"normal",fontNumbersWeight:"normal",fontTitleWeight:"normal",fontUnitsWeight:"normal",fontValueWeight:"normal",needle:!0,needleShadow:!0,needleType:"arrow",needleStart:5,needleEnd:85,needleWidth:4,borderOuterWidth:3,borderMiddleWidth:3,borderInnerWidth:3,borderShadowWidth:3,valueBox:!0,valueBoxStroke:5,valueBoxWidth:0,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"}],highlightsWidth:15,barWidth:20,barStrokeWidth:0,barProgress:!0,barShadow:0};function w(){Array.prototype.constructor.apply(this,arguments)}((w.prototype=Object.create(Array.prototype)).constructor=w).prototype.get=function(e){if("string"==typeof e)for(var t=0,i=this.length;t<i;t++){if((this[t].options.renderTo.tagName?this[t].options.renderTo:document.getElementById(this[t].options.renderTo||"")).getAttribute("id")===e)return this[t]}else if("number"==typeof e)return this[e];return null};var k="2.1.5",N=Math.round,E=Math.abs,y=new w;y.version=k;var T=(t(x,i),e(x,[{key:"update",value:function(e){return Object.assign(this.options,this.type.configure(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=y.indexOf(this);~e&&y.splice(e,1),this.canvas.destroy(),this.canvas=null,this.animation.destroy(),this.animation=null,this.emit("destroy")}},{key:"draw",value:function(){return this.options.animateOnInit&&!this.initialized&&(this.value=this._value,this.initialized=!0,this.emit("init")),this.emit("render"),this}},{key:"value",set:function(i){var r=this;i=x.ensureValue(i,this.options.minValue);var o=this.options.value;if(i!==o)if(this.options.animation){if(this.animation.frame&&(this.options.value=this._value,this._value===i))return this.animation.cancel(),void delete this._value;void 0===this._value&&(this._value=i),this.emit("animationStart"),this.animation.animate(function(e){var t=o+(i-o)*e;r.options.animatedValue&&r.emit("value",t,r.value),r.options.value=t,r.draw(),r.emit("animate",e,r.options.value)},function(){void 0!==r._value&&(r.emit("value",r._value,r.value),r.options.value=r._value,delete r._value),r.draw(),r.emit("animationEnd")})}else this.emit("value",i,this.value),this.options.value=i,this.draw()},get:function(){return void 0===this._value?this.options.value:this._value}}],[{key:"configure",value:function(e){return e}},{key:"initialize",value:function(e,t){return new v(t,"canvas",e)}},{key:"fromElement",value:function(e){var t=v.toCamelCase(e.getAttribute("data-type")),i=e.attributes,r=0,o=i.length,n={};if(t){for(/Gauge$/.test(t)||(t+="Gauge");r<o;r++)n[v.toCamelCase(i[r].name.replace(/^data-/,""),!1)]=v.parse(i[r].value);new v(n,e.tagName,t).process(e)}}},{key:"ensureValue",value:function(e,t){var i=1<arguments.length&&void 0!==t?t:0;return e=parseFloat(e),!isNaN(e)&&isFinite(e)||(e=parseFloat(i)||0),e}},{key:"mod",value:function(e,t){return(e%t+t)%t}},{key:"version",get:function(){return k}}]),x);function x(e){a(this,x);var i=n(this,(x.__proto__||Object.getPrototypeOf(x)).call(this)),t=i.constructor.name;if("BaseGauge"===t)throw new TypeError("Attempt to instantiate abstract class!");if(y.push(i),e.listeners&&Object.keys(e.listeners).forEach(function(t){(e.listeners[t]instanceof Array?e.listeners[t]:[e.listeners[t]]).forEach(function(e){i.on(t,e)})}),i.version=k,i.type=o[t]||x,i.initialized=!1,e.minValue=parseFloat(e.minValue),e.maxValue=parseFloat(e.maxValue),e.value=parseFloat(e.value)||0,e.borders||(e.borderInnerWidth=e.borderMiddleWidth=e.borderOuterWidth=0),!e.renderTo)throw TypeError("Canvas element was not specified when creating the Gauge object!");var r=e.renderTo.tagName?e.renderTo:document.getElementById(e.renderTo);if(!(r instanceof HTMLCanvasElement))throw TypeError("Given gauge canvas element is invalid!");return e.width=parseFloat(e.width)||0,e.height=parseFloat(e.height)||0,e.width&&e.height||(e.width||(e.width=r.parentNode?r.parentNode.offsetWidth:r.offsetWidth),e.height||(e.height=r.parentNode?r.parentNode.offsetHeight:r.offsetHeight)),i.options=e||{},i.options.animateOnInit&&(i._value=i.options.value,i.options.value=i.options.minValue),i.canvas=new C(r,e.width,e.height),i.canvas.onRedraw=i.draw.bind(i),i.animation=new f(e.animationRule,e.animationDuration),i}function W(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 O(e,t){var i,r=t.valueDec,o=t.valueInt,n=0,a=void 0,l=void 0;if(i=(e=parseFloat(e))<0,e=Math.abs(e),0<r){for(a=o-(l=e.toFixed(r).toString().split("."))[0].length;n<a;++n)l[0]="0"+l[0];l=(i?"-":"")+l[0]+"."+l[1]}else{for(a=o-(l=Math.round(e).toString()).length;n<a;++n)l="0"+l;l=(i?"-":"")+l}return l}function P(e,t,i){return e["font"+t+"Style"]+" "+e["font"+t+"Weight"]+" "+e["font"+t+"Size"]*i+"px "+e["font"+t]}function A(e){e.shadowOffsetX=null,e.shadowOffsetY=null,e.shadowBlur=null,e.shadowColor="",e.strokeStyle=null,e.lineWidth=0,e.save()}function M(e,t,i,r){t.valueTextShadow&&(e.shadowOffsetX=i,e.shadowOffsetY=i,e.shadowBlur=r,e.shadowColor=t.colorValueTextShadow)}void 0!==o&&(o.BaseGauge=T,o.gauges=(window.document||{}).gauges=y);var _={roundRect:W,padValue:O,formatMajorTickNumber:function(e,t){var i=void 0,r=!1;return i=0===t.majorTicksDec?Math.round(e).toString():e.toFixed(t.majorTicksDec),1<t.majorTicksInt?(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},radians:function(e){return e*Math.PI/180},radialPoint:function(e,t){return{x:-e*Math.sin(t),y:e*Math.cos(t)}},linearGradient:function(e,t,i,r){var o=!(4<arguments.length&&void 0!==arguments[4])||arguments[4],n=5<arguments.length&&void 0!==arguments[5]?arguments[5]:0,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},drawNeedleShadow:function(e,t){t.needleShadow&&(e.shadowOffsetX=2,e.shadowOffsetY=2,e.shadowBlur=10,e.shadowColor=t.colorNeedleShadowDown)},drawValueBox:function(e,t,i,r,o,n){if(t.valueBox){A(e);var a=t.valueDec?1+t.valueDec:0,l="9".repeat(Math.max.apply(null,[String(parseInt(i)).length+a].concat(t.majorTicks.map(function(e){return String(parseInt(e,10)).length+a})))),s=t.valueText||O(i,t),d=n/200,c=n/100,h=.4*c,u=1.2*c;e.font=P(t,"Value",d),M(e,t,h,u);var f=e.measureText(t.valueText?s:"-"+O(Number(l),t)).width;A(e);var m=parseFloat(t.fontValueSize)*d+h+u,v=c*parseFloat(t.valueBoxStroke),g=2*n-2*v,b=f+10*c,p=1.1*m+h+u,w=c*t.valueBoxBorderRadius,k=(parseFloat(t.valueBoxWidth)||0)/100*g;b<k&&(b=k),g<b&&(b=g);var y=r-b/2,T=o-p/2,x=o-5.75*c;if(e.beginPath(),w?W(e,y,T,b,p,w):e.rect(y,T,b,p),v){var S=e.createRadialGradient(r,x,10*c,r,x,20*c);S.addColorStop(0,t.colorValueBoxRect),S.addColorStop(1,t.colorValueBoxRectEnd),e.strokeStyle=S,e.lineWidth=v,e.stroke()}t.colorValueBoxShadow&&(e.shadowBlur=1.2*c,e.shadowColor=t.colorValueBoxShadow),t.colorValueBoxBackground&&(e.fillStyle=t.colorValueBoxBackground,e.fill()),e.closePath(),e.restore(),M(e,t,h,u),e.fillStyle=t.colorValueText,e.textAlign="center",e.textBaseline="alphabetic",e.fillText(s,y+b/2,o+p/2-m/3),e.restore()}},verifyError:function(e){if(!(e instanceof DOMException&&2152923147===e.result))throw e},prepareTicks:function(e){return e.majorTicks instanceof Array||(e.majorTicks=e.majorTicks?[e.majorTicks]:[]),e.majorTicks.length||(e.majorTicks.push(_.formatMajorTickNumber(e.minValue,e)),e.majorTicks.push(_.formatMajorTickNumber(e.maxValue,e))),["right"!==e.tickSide,"left"!==e.tickSide]},drawShadow:function(e,t){if(2<arguments.length&&void 0!==arguments[2]&&arguments[2])return e.restore(),!0;e.save();var i=t.borderShadowWidth;return i&&(e.shadowBlur=i,e.shadowColor=t.colorBorderShadow),!0},font:P,normalizedValue:function(e){var t=e.value,i=e.minValue,r=e.maxValue,o=.01*(r-i);return{normal:t<i?i:r<t?r:t,indented:t<i?i-o:r<t?r+o:t}}},S=Math.PI,j=S/2,B=Object.assign({},p,{majorTicksLengthAdd:0,minorTicksLengthAdd:0,ticksAngle:270,startAngle:45,angles:[45,90,135,180,225,270],textTitleAlign:"center",xPositionTitle:1e6,yPositionTitle:-4.25,textUnitsAlign:"center",xPositionUnits:1e6,yPositionUnits:3.25,colorNeedleCircleOuter:"#f0f0f0",colorNeedleCircleOuterEnd:"#ccc",colorNeedleCircleInner:"#e8e8e8",colorNeedleCircleInnerEnd:"#f5f5f5",needleCircleSize:10,needleCircleInner:!0,needleCircleOuter:!0,needleStart:20,animationTarget:"needle",useMinPath:!1,customAngles:!1,barWidth:0});function R(e,t,i,r,o){i.beginPath(),i.arc(0,0,E(e),0,2*S,!0),i.lineWidth=t,i.strokeStyle=o?_.linearGradient(i,r,o,e):r,i.stroke(),i.closePath()}function I(e,t){var i=C.pixelRatio;return e.maxRadius||(e.maxRadius=e.max-t.borderShadowWidth-t.borderOuterWidth*i-t.borderMiddleWidth*i-t.borderInnerWidth*i+(t.borderOuterWidth?.5:0)+(t.borderMiddleWidth?.5:0)+(t.borderInnerWidth?.5:0)),e.maxRadius}function D(e,t){var i=C.pixelRatio,r=t.borderShadowWidth*i,o=e.max-r-t.borderOuterWidth*i/2,n=o-t.borderOuterWidth*i/2-t.borderMiddleWidth*i/2+.5,a=n-t.borderMiddleWidth*i/2-t.borderInnerWidth*i/2+.5,l=I(e,t),s=void 0,d=!1;e.save(),t.borderOuterWidth&&(d=_.drawShadow(e,t,d),R(o,t.borderOuterWidth*i,e,t.colorBorderOuter,t.colorBorderOuterEnd)),t.borderMiddleWidth&&(d=_.drawShadow(e,t,d),R(n,t.borderMiddleWidth*i,e,t.colorBorderMiddle,t.colorBorderMiddleEnd)),t.borderInnerWidth&&(d=_.drawShadow(e,t,d),R(a,t.borderInnerWidth*i,e,t.colorBorderInner,t.colorBorderInnerEnd)),_.drawShadow(e,t,d),e.beginPath(),e.arc(0,0,E(l),0,2*S,!0),t.colorPlateEnd?((s=e.createRadialGradient(0,0,l/2,0,0,l)).addColorStop(0,t.colorPlate),s.addColorStop(1,t.colorPlateEnd)):s=t.colorPlate,e.fillStyle=s,e.fill(),e.closePath(),e.restore()}function L(e,t){var i=e.max*(parseFloat(t.highlightsWidth)||0)/100;if(i){var r=E(G(e,t)-i/2),o=0,n=t.highlights.length,a=(t.maxValue-t.minValue)/t.ticksAngle;for(e.save();o<n;o++){var l=t.highlights[o];e.beginPath(),e.rotate(j),e.arc(0,0,r,_.radians(t.startAngle+(l.from-t.minValue)/a),_.radians(t.startAngle+(l.to-t.minValue)/a),!1),e.strokeStyle=l.color,e.lineWidth=i,e.stroke(),e.closePath(),e.restore(),e.save()}}}function z(e,t){var i,r=G(e,t),o=void 0,n=void 0,a=void 0,l=0,s=1,d=0,c=0,h=Math.abs(t.minorTicks)||0,u=t.ticksAngle/(t.maxValue-t.minValue);if(e.lineWidth=C.pixelRatio,e.strokeStyle=t.colorMinorTicks||t.colorStrokeTicks,e.save(),i=t.minorTicksLengthAdd,t.exactTicks?(n=t.maxValue-t.minValue,o=h?n/h:0,c=(T.mod(t.majorTicks[0],h)||0)*u):o=h*(t.majorTicks.length-1),t.customAngles)for(;d<o;)for(;s<t.angles.length;++s){var f=(t.angles[s]-t.angles[s-1])/h;for(l=0;l<h;++l,++d)a=t.angles[s-1]+l*f,t.angles.includes(a)||a<=t.ticksAngle+t.startAngle&&(e.rotate(_.radians(a)),e.beginPath(),e.moveTo(0,r),e.lineTo(0,r-.075*e.max+i),X(e))}else for(;l<o;++l)(a=t.startAngle+c+l*(t.ticksAngle/o))<=t.ticksAngle+t.startAngle&&(e.rotate(_.radians(a)),e.beginPath(),e.moveTo(0,r),e.lineTo(0,r-.075*e.max+i),X(e))}function G(e,t){var i=e.max/100;return I(e,t)-5*i-(t.barWidth?2*(parseFloat(t.barStrokeWidth)||0)+((parseFloat(t.barWidth)||0)+5)*i:0)}function U(e,t){_.prepareTicks(t);var i,r,o=E(G(e,t)),n=void 0,a=void 0,l=t.majorTicks.length,s=C.pixelRatio;if(e.lineWidth=2*s,e.save(),i=t.colorMajorTicks instanceof Array?t.colorMajorTicks:new Array(l).fill(t.colorStrokeTicks||t.colorMajorTicks),r=t.majorTicksLengthAdd,n=0,t.customAngles)for(;n<l;++n)a=t.angles[n],e.strokeStyle=i[n],e.rotate(_.radians(a)),e.beginPath(),e.moveTo(0,o),e.lineTo(0,o-.15*e.max+r),X(e);else for(;n<l;++n)e.strokeStyle=i[n],e.rotate(_.radians(F(t,t.exactTicks?t.majorTicks[n]:n,l))),e.beginPath(),e.moveTo(0,o),e.lineTo(0,o-.15*e.max+r),X(e);t.strokeTicks&&(e.strokeStyle=t.colorStrokeTicks||i[0],e.rotate(j),e.beginPath(),e.arc(0,0,o,_.radians(t.startAngle),_.radians(t.startAngle+t.ticksAngle),!1),X(e))}function F(e,t,i){if(e.exactTicks){var r=e.ticksAngle/(e.maxValue-e.minValue);return e.startAngle+r*(t-e.minValue)}return e.startAngle+t*(e.ticksAngle/(i-1))}function X(e){e.stroke(),e.restore(),e.closePath(),e.save()}function Y(e,t){var i=G(e,t)-.15*e.max,r={},o=0,n=t.majorTicks.length,a="needle"!==t.animationTarget,l=t.colorNumbers instanceof Array?t.colorNumbers:new Array(n).fill(t.colorNumbers),s=a?-(t.value-t.minValue)/(t.maxValue-t.minValue)*t.ticksAngle:0;if(a&&(e.save(),e.rotate(-_.radians(s))),e.font=_.font(t,"Numbers",e.max/200),e.lineWidth=0,e.textAlign="center",e.textBaseline="middle",t.customAngles)for(;o<n;++o){var d=s+t.angles[o],c=e.measureText(t.majorTicks[o]).width,h=t.fontNumbersSize,u=Math.sqrt(c*c+h*h)/2,f=_.radialPoint(i-u-t.numbersMargin/100*e.max,_.radians(d));360===d&&(d=0),r[d]||(r[d]=!0,e.fillStyle=l[o],e.fillText(t.majorTicks[o],f.x,f.y))}else for(;o<n;++o){d=s+F(t,t.exactTicks?t.majorTicks[o]:o,n),c=e.measureText(t.majorTicks[o]).width,h=t.fontNumbersSize,u=Math.sqrt(c*c+h*h)/2,f=_.radialPoint(i-u-t.numbersMargin/100*e.max,_.radians(d));360===d&&(d=0),r[d]||(r[d]=!0,e.fillStyle=l[o],e.fillText(t.majorTicks[o],f.x,f.y))}a&&e.restore()}function q(e,t){if(t.title){var i=t.textTitleAlign,r=t.xPositionTitle,o=t.yPositionTitle;e.save(),e.font=_.font(t,"Title",e.max/200),e.fillStyle=t.colorTitle,e.textAlign=i,e.fillText(t.title,e.max/r,e.max/o,.8*e.max),e.restore()}}function H(e,t){if(t.units){var i=t.textUnitsAlign,r=t.xPositionUnits,o=t.yPositionUnits;e.save(),e.font=_.font(t,"Units",e.max/200),e.fillStyle=t.colorUnits,e.textAlign=i,e.fillText(t.units,e.max/r,e.max/o,.8*e.max),e.restore()}}function J(e,t){if(t.needle){var i=t.ticksAngle<360?_.normalizedValue(t).indented:t.value,r=void 0,o=0,n=I(e,t),a=E(n/100*t.needleCircleSize),l=E(n/100*t.needleCircleSize*.75),s=E(n/100*t.needleEnd),d=E(t.needleStart?n/100*t.needleStart:0),c=n/100*t.needleWidth,h=n/100*t.needleWidth/2,u=C.pixelRatio,f="needle"!==t.animationTarget,m=t.majorTicks.length;if(e.save(),_.drawNeedleShadow(e,t),t.customAngles){for(;o<m;++o){var v=(t.angles[o+1]-t.angles[o])/(t.majorTicks[o+1]-t.majorTicks[o]);if(i>t.majorTicks[o]&&i<t.majorTicks[o+1]){r=t.angles[o]+v*(i-t.majorTicks[o]);break}if(i==t.majorTicks[o]){r=t.angles[o];break}if(t.value>t.majorTicks[m-1]){r=t.angles[m-1]+5;break}if(t.value<t.majorTicks[0]){r=t.angles[0]-5;break}r=t.startAngle}e.rotate(_.radians(f?t.startAngle:r))}else e.rotate(_.radians(f?t.startAngle:t.startAngle+(i-t.minValue)/(t.maxValue-t.minValue)*t.ticksAngle));e.fillStyle=_.linearGradient(e,t.colorNeedle,t.colorNeedleEnd,s-d),"arrow"===t.needleType?(e.beginPath(),e.moveTo(-h,-d),e.lineTo(-c,0),e.lineTo(-1*u,s),e.lineTo(u,s),e.lineTo(c,0),e.lineTo(h,-d),e.closePath(),e.fill(),e.beginPath(),e.lineTo(-.5*u,s),e.lineTo(-1*u,s),e.lineTo(-c,0),e.lineTo(-h,-d),e.lineTo(h/2*u-2*u,-d),e.closePath(),e.fillStyle=t.colorNeedleShadowUp):(e.beginPath(),e.moveTo(-h,s),e.lineTo(-h,d),e.lineTo(h,d),e.lineTo(h,s),e.closePath()),e.fill(),t.needleCircleSize&&(e.restore(),_.drawNeedleShadow(e,t),t.needleCircleOuter&&(e.beginPath(),e.arc(0,0,a,0,2*S,!0),e.fillStyle=_.linearGradient(e,t.colorNeedleCircleOuter,t.colorNeedleCircleOuterEnd,a),e.fill(),e.closePath()),t.needleCircleInner&&(e.beginPath(),e.arc(0,0,l,0,2*S,!0),e.fillStyle=_.linearGradient(e,t.colorNeedleCircleInner,t.colorNeedleCircleInnerEnd,l),e.fill(),e.closePath()),e.restore())}}function $(e,t,i){_.drawValueBox(e,t,i,0,e.max-.33*e.max,e.max)}function Z(e,t){var i=e.max/100,r=I(e,t)-5*i,o=parseFloat(t.barStrokeWidth)||0,n=(parseFloat(t.barWidth)||0)*i,a=r-2*o-n,l=(r-a)/2,s=a+l,d=o/s,c=t.startAngle,h=t.startAngle+t.ticksAngle;e.save(),e.rotate(j),o&&(e.beginPath(),e.arc(0,0,s,_.radians(c)-d,_.radians(h)+d,!1),e.strokeStyle=t.colorBarStroke,e.lineWidth=2*l,e.stroke(),e.closePath()),n&&(e.beginPath(),e.arc(0,0,s,_.radians(c),_.radians(h),!1),e.strokeStyle=t.colorBar,e.lineWidth=n,e.stroke(),e.closePath(),t.barShadow&&(e.beginPath(),e.arc(0,0,r,_.radians(c),_.radians(h),!1),e.clip(),e.beginPath(),e.strokeStyle=t.colorBar,e.lineWidth=1,e.shadowBlur=t.barShadow,e.shadowColor=t.colorBarShadow,e.shadowOffsetX=0,e.shadowOffsetY=0,e.arc(0,0,r,_.radians(t.startAngle),_.radians(t.startAngle+t.ticksAngle),!1),e.stroke(),e.closePath(),e.restore(),e.rotate(j)),t.barProgress&&(e.beginPath(),e.arc(0,0,s,_.radians(c),_.radians(c+(_.normalizedValue(t).normal-t.minValue)/(t.maxValue-t.minValue)*t.ticksAngle),!1),e.strokeStyle=t.colorBarProgress,e.lineWidth=n,e.stroke(),e.closePath())),e.restore()}function K(e){return e.options.animatedValue?e.options.value:e.value}var Q=(t(ee,T),e(ee,[{key:"draw",value:function(){try{var e=this.canvas,t=[-e.drawX,-e.drawY,e.drawWidth,e.drawHeight],i=t[0],r=t[1],o=t[2],n=t[3],a=this.options;if("needle"===a.animationTarget){if(!e.elementClone.initialized){var l=e.contextClone;l.clearRect(i,r,o,n),l.save(),this.emit("beforePlate"),D(l,a),this.emit("beforeHighlights"),L(l,a),this.emit("beforeMinorTicks"),z(l,a),this.emit("beforeMajorTicks"),U(l,a),this.emit("beforeNumbers"),Y(l,a),this.emit("beforeTitle"),q(l,a),this.emit("beforeUnits"),H(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(),this.emit("beforeProgressBar"),Z(e.context,a),this.emit("beforeValueBox"),$(e.context,a,K(this)),this.emit("beforeNeedle"),J(e.context,a)}else{var s=-_.radians((a.value-a.minValue)/(a.maxValue-a.minValue)*a.ticksAngle);if(e.context.clearRect(i,r,o,n),e.context.save(),this.emit("beforePlate"),D(e.context,a),e.context.rotate(s),this.emit("beforeHighlights"),L(e.context,a),this.emit("beforeMinorTicks"),z(e.context,a),this.emit("beforeMajorTicks"),U(e.context,a),this.emit("beforeNumbers"),Y(e.context,a),this.emit("beforeProgressBar"),Z(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(),this.emit("beforeTitle"),q(d,a),this.emit("beforeUnits"),H(d,a),this.emit("beforeNeedle"),J(d,a),e.elementClone.initialized=!0}e.context.drawImage(e.elementClone,i,r,o,n)}this.emit("beforeValueBox"),$(e.context,a,K(this)),c(ee.prototype.__proto__||Object.getPrototypeOf(ee.prototype),"draw",this).call(this)}catch(e){_.verifyError(e)}return this}},{key:"value",set:function(e){e=T.ensureValue(e,this.options.minValue),this.options.animation&&360===this.options.ticksAngle&&this.options.useMinPath&&(this._value=e,e=this.options.value+((e-this.options.value)%360+540)%360-180),function e(t,i,r,o){var n=Object.getOwnPropertyDescriptor(t,i);if(void 0===n){var a=Object.getPrototypeOf(t);null!==a&&e(a,i,r,o)}else if("value"in n&&n.writable)n.value=r;else{var l=n.set;void 0!==l&&l.call(o,r)}return r}(ee.prototype.__proto__||Object.getPrototypeOf(ee.prototype),"value",e,this)},get:function(){return c(ee.prototype.__proto__||Object.getPrototypeOf(ee.prototype),"value",this)}}],[{key:"configure",value:function(e){return 50<e.barWidth&&(e.barWidth=50),isNaN(e.startAngle)&&(e.startAngle=45),isNaN(e.ticksAngle)&&(e.ticksAngle=270),360<e.ticksAngle&&(e.ticksAngle=360),e.ticksAngle<0&&(e.ticksAngle=0),e.startAngle<0&&(e.startAngle=0),360<e.startAngle&&(e.startAngle=360),e}}]),ee);function ee(e){return a(this,ee),e=Object.assign({},B,e||{}),n(this,(ee.__proto__||Object.getPrototypeOf(ee)).call(this,ee.configure(e)))}void 0!==o&&(o.RadialGauge=Q),T.initialize("RadialGauge",B);var te=Object.assign({},p,{borderRadius:0,barBeginCircle:30,colorBarEnd:"",colorBarProgressEnd:"",needleWidth:6,tickSide:"both",needleSide:"both",numberSide:"both",ticksWidth:10,ticksWidthMinor:5,ticksPadding:5,barLength:85,fontTitleSize:26,highlightsWidth:10});function ie(e,t,i,r,o,n,a,l,s){e.beginPath(),e.lineWidth=t,e.strokeStyle=s?_.linearGradient(e,l,s,a,!0,o):l,0<i?_.roundRect(e,r,o,n,a,i):e.rect(r,o,n,a),e.stroke(),e.closePath()}function re(e,t,i,r,o,n){var a=C.pixelRatio;e.save();var l=t.borderRadius*a,s=o-t.borderShadowWidth-t.borderOuterWidth*a,d=s-t.borderOuterWidth*a-t.borderMiddleWidth*a,c=d-t.borderMiddleWidth*a-t.borderInnerWidth*a,h=c-t.borderInnerWidth*a,u=n-t.borderShadowWidth-t.borderOuterWidth*a,f=u-t.borderOuterWidth*a-t.borderMiddleWidth*a,m=f-t.borderMiddleWidth*a-t.borderInnerWidth*a,v=m-t.borderInnerWidth*a,g=i-(d-s)/2,b=g-(c-d)/2,p=b-(h-c)/2,w=r-(f-u)/2,k=w-(m-f)/2,y=k-(v-m)/2,T=0,x=!1;return t.borderOuterWidth&&(x=_.drawShadow(e,t,x),ie(e,t.borderOuterWidth*a,l,i+t.borderOuterWidth*a/2-T,r+t.borderOuterWidth*a/2-T,s,u,t.colorBorderOuter,t.colorBorderOuterEnd),T+=.5*a),t.borderMiddleWidth&&(x=_.drawShadow(e,t,x),ie(e,t.borderMiddleWidth*a,l-=1+2*T,g+t.borderMiddleWidth*a/2-T,w+t.borderMiddleWidth*a/2-T,d+2*T,f+2*T,t.colorBorderMiddle,t.colorBorderMiddleEnd),T+=.5*a),t.borderInnerWidth&&(x=_.drawShadow(e,t,x),ie(e,t.borderInnerWidth*a,l-=1+2*T,b+t.borderInnerWidth*a/2-T,k+t.borderInnerWidth*a/2-T,c+2*T,m+2*T,t.colorBorderInner,t.colorBorderInnerEnd),T+=.5*a),_.drawShadow(e,t,x),function(e,t,i,r,o,n,a,l){e.beginPath(),e.fillStyle=l?_.linearGradient(e,a,l,n<o?o:n,o<n,n<o?i:r):a,0<t?_.roundRect(e,i,r,o,n,t):e.rect(i,r,o,n),e.fill(),e.closePath()}(e,l,p,y,h+2*T,v+2*T,t.colorPlate,t.colorPlateEnd),e.restore(),[p,y,h,v]}function oe(e,t,i,r,o,n,a){var l=function(e,t,i,r,o,n){var a=C.pixelRatio,l=o<=n,s=l?.85*o:n,d=l?n:o;i=l?N(i+(o-s)/2):i;var c=!!t.title,h=!!t.units,u=!!t.valueBox,f=void 0,m=void 0,v=void 0;l?(m=N(.05*d),f=N(.075*d),v=N(.11*d),c&&(d-=f,r+=f),h&&(d-=m),u&&(d-=v)):(m=f=N(.15*s),c&&(s-=f,r+=f),h&&(s-=m));var g=2*t.barStrokeWidth,b=t.barBeginCircle?N(s*t.barBeginCircle/200-g/2):0,p=N(s*t.barWidth/100-g),w=N(d*t.barLength/100-g),k=N((d-w)/2),y=N(i+(l?s/2:k+b)),T=N(r+(l?d-k-b+g/2:s/2)),x=!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:k,radius:b,pixelRatio:a,barOffset:null,titleMargin:c?f:0,unitsMargin:h?m:0,get ticksLength(){return this.barLength-this.barOffset-this.strokeWidth},X:i+x,Y:r+S,x0:y+x,y0:T+S,baseX:i,baseY:r,ticksPadding:t.ticksPadding/100},e.barDimensions}(e,t,r,o,n,a),s=l.isVertical,d=l.width,c=l.barWidth,h=l.barLength,u=l.strokeWidth,f=l.barMargin,m=l.radius,v=l.x0,g=l.y0,b=l.X,p=l.Y,w=h;if(e.save(),e.beginPath(),t.barBeginCircle){var k=_.radians(s?270:0),y=Math.asin(c/2/m),T=Math.cos(y),x=Math.sin(y),S=v+(s?m*x:m*T-u/2),W=s?g-m*T:g+m*x,O=E(s?W-g:S-v);e.barDimensions.barOffset=N(O+m);var V=s?N(v-m*x):S,P=s?W:N(g-m*x);"progress"===i&&(h=e.barDimensions.barOffset+(h-e.barDimensions.barOffset)*(_.normalizedValue(t).normal-t.minValue)/(t.maxValue-t.minValue));var A=N(S+h-e.barDimensions.barOffset+u/2),M=N(W-h+e.barDimensions.barOffset-u/2);e.arc(v,g,m,k+y,k-y),s?(e.moveTo(S,P),e.lineTo(S,M),e.lineTo(V,M),e.lineTo(V,P)):(e.moveTo(S,P),e.lineTo(A,P),e.lineTo(A,W),e.lineTo(S,W))}else{var j=N(s?b+(d-c)/2:b+f),B=N(s?p+h+f:p+(d-c)/2);"progress"===i&&(h*=(t.value-t.minValue)/(t.maxValue-t.minValue)),s?e.rect(j,B,c,-h):e.rect(j,B,h,c)}"progress"!==i&&t.barStrokeWidth&&(e.lineWidth=u,e.strokeStyle=t.colorBarStroke,e.stroke()),"progress"!==i&&t.colorBar?(e.fillStyle=t.colorBarEnd?_.linearGradient(e,t.colorBar,t.colorBarEnd,h,s,s?p:b):t.colorBar,e.fill()):"progress"===i&&t.colorBarProgress&&(e.fillStyle=t.colorBarProgressEnd?_.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 ne(e,t){return t.needleSide!==e||t.tickSide!==e||t.numberSide!==e}function ae(e,t,i,r,o){e.beginPath(),e.moveTo(t,i),e.lineTo(r,o),e.stroke(),e.closePath(),e.save()}function le(e,t,i,r,o,n,a,l,s){var d=e.barDimensions,c=d.isVertical,h=d.length,u=d.barWidth,f=d.barOffset,m=d.barMargin,v=d.pixelRatio,g=d.width,b=d.X,p=d.Y,w=d.ticksLength,k=d.ticksPadding,y=(g-u)/2,T=void 0,x=void 0,S=0,W=i.length,O=void 0,V=s*g,P=y-k*g,A=y+u+V+k*g,M=t instanceof Array?t:new Array(i.length).fill(t);e.lineWidth=l*v,e.save();for(var j=w/(o-r);S<W;S++)O=i[S],e.strokeStyle=M[S],c?(x=p+h-m-f+(r-O)*j,n&&ae(e,T=b+P,x,N(T-V),x),a&&ae(e,T=b+A,x,N(T-V),x)):(T=b+m+f-(r-O)*j,n&&ae(e,T,x=p+P,T,N(x-V)),a&&ae(e,T,N(x=p+A),T,x-V))}function se(e,t,i,r,o){e.beginPath(),e.moveTo(t,i),e.lineTo(r,o),e.stroke(),e.closePath()}function de(e,t,i,r){return t.colorNeedleEnd?_.linearGradient(e,r?t.colorNeedleEnd:t.colorNeedle,r?t.colorNeedle:t.colorNeedleEnd,i,!e.barDimensions.isVertical):t.colorNeedle}function ce(e,t,i,r,o,n,a,l){e.lineWidth=t.needleWidth,e.strokeStyle=de(e,t,a,l),e.beginPath(),e.moveTo(i,r),e.lineTo(o,n),e.stroke(),e.closePath()}function he(e,t,i,r,o,n,a,l){var s=a-N(.4*a),d=i===o,c=t.needleWidth/2;e.fillStyle=de(e,t,a,l),e.beginPath(),d?(n<r&&(s*=-1),e.moveTo(i-c,r),e.lineTo(i+c,r),e.lineTo(i+c,r+s),e.lineTo(i,n),e.lineTo(i-c,r+s),e.lineTo(i-c,r)):(o<i&&(s*=-1),e.moveTo(i,r-c),e.lineTo(i,r+c),e.lineTo(i+s,r+c),e.lineTo(o,r),e.lineTo(i+s,r-c),e.lineTo(i,r-c)),e.fill(),e.closePath()}var ue=(t(fe,T),e(fe,[{key:"draw",value:function(){try{var e=this.canvas,t=[-e.drawX,-e.drawY,e.drawWidth,e.drawHeight],i=t[0],r=t[1],o=t[2],n=t[3],a=this.options;if(!e.elementClone.initialized){var l=e.contextClone;l.clearRect(i,r,o,n),l.save(),this.emit("beforePlate"),this.drawBox=re(l,a,i,r,o,n),this.emit("beforeBar"),function(e,t,i,r,o,n){oe(e,t,"",i,r,o,n)}.apply(void 0,[l,a].concat(s(this.drawBox))),e.context.barDimensions=l.barDimensions,this.emit("beforeHighlights"),function(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,f=o*(parseFloat(t.highlightsWidth)||0)/100;if(t.highlights&&f){var m="right"!==t.tickSide,v="left"!==t.tickSide,g=0,b=t.highlights.length,p=(o-a)/2,w=t.maxValue-t.minValue,k=N(r?d+p:d+s+l),y=f,T=r?c+n-s-l:c+p,x=N((t.ticksWidth/100+u)*o)+(f-t.ticksWidth/100*o),S=N(a+u*o);for(e.save();g<b;g++){var W=t.highlights[g],O=h*E(t.minValue-W.from)/w,V=h*E((W.to-W.from)/w);e.beginPath(),e.fillStyle=W.color,r?(m&&e.rect(k-x,T-O,y,-V),v&&e.rect(k+S,T-O,y,-V)):(m&&e.rect(k+O,T-x,V,y),v&&e.rect(k+O,T+S,V,y)),e.fill(),e.closePath()}}}(l,a),this.emit("beforeMinorTicks"),function(e,t){var i=_.prepareTicks(t),r=V(i,2),o=r[0],n=r[1],a=[],l=t.minValue,s=Math.abs(t.minorTicks)||0,d=s?(t.maxValue-t.minValue)/(s*(t.majorTicks.length-1)):0;if(s)if(t.exactTicks)for(var c=T.mod(t.majorTicks[0],s)||0;l<t.maxValue;l+=s)c+l<t.maxValue&&a.push(c+l);else for(;l<t.maxValue;l+=d)a.push(l);le(e,t.colorMinorTicks||t.colorStrokeTicks,a,t.minValue,t.maxValue,o,n,1,t.ticksWidthMinor/100)}(l,a),this.emit("beforeMajorTicks"),function(e,i){var t=_.prepareTicks(i),r=V(t,2),o=r[0],n=r[1],a=2,l=(i.maxValue-i.minValue)/(i.majorTicks.length-1),s=i.colorMajorTicks instanceof Array?i.colorMajorTicks:new Array(i.majorTicks.length).fill(i.colorStrokeTicks||i.colorMajorTicks);if(le(e,s,i.exactTicks?i.majorTicks:i.majorTicks.map(function(e,t){return i.minValue+l*t}),i.minValue,i.maxValue,o,n,a,i.ticksWidth/100),i.strokeTicks){var d=e.barDimensions,c=d.isVertical,h=d.length,u=d.width,f=d.barWidth,m=d.barMargin,v=d.barOffset,g=d.X,b=d.Y,p=d.ticksLength,w=d.pixelRatio,k=d.ticksPadding,y=(u-f)/2+f+k*u,T=(u-f)/2-k*u,x=void 0,S=void 0,W=void 0,O=void 0;e.strokeStyle=i.colorStrokeTicks||s[0],a*=w,c?(O=(S=b+h-m-v+a/2)-p-a,o&&(W=x=N(g+T),se(e,x,S,W,O)),n&&(W=x=N(g+y),se(e,x,S,W,O))):(W=(x=g+m+v-a/2)+p+a,o&&(O=S=N(b+T),se(e,x,S,W,O)),n&&(O=S=N(b+y),se(e,x,S,W,O)))}}(l,a),this.emit("beforeNumbers"),function(e,i){var t=e.barDimensions,r=t.isVertical,o=t.length,n=t.width,a=t.barWidth,l=t.barMargin,s=t.barOffset,d=t.X,c=t.Y,h=t.ticksLength,u=t.ticksPadding,f=i.maxValue-i.minValue,m=f/(i.majorTicks.length-1),v=i.exactTicks?i.majorTicks:i.majorTicks.map(function(e,t){return i.minValue+m*t}),g=v.length,b="right"!==i.numberSide,p="left"!==i.numberSide,w=i.fontNumbersSize*n/200,k=0,y=(i.ticksWidth/100+2*u)*n,T=(n-a)/2-y,x=(n-a)/2+a+y,S=void 0,W=void 0,O=void 0,V=void 0,P=i.colorNumbers instanceof Array?i.colorNumbers:new Array(g).fill(i.colorNumbers),A=i.numbersMargin/100*n;for(e.font=_.font(i,"Numbers",n/200),e.lineWidth=0,e.textAlign="center";k<g;k++)e.fillStyle=P[k],V=i.majorTicks[k],O=i.exactTicks?h*((v[k]-i.minValue)/f):k*h/(g-1),r?(W=c+o-l-s-O+w/3,b&&(e.textAlign="right",e.fillText(V,d+T-A,W)),p&&(e.textAlign="left",e.fillText(V,d+x+A,W))):(e.measureText(V).width,S=d+l+s+O,b&&e.fillText(V,S,c+T-A),p&&e.fillText(V,S,c+x+w+A))}(l,a),this.emit("beforeTitle"),function(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=N(a+(r?o:n)/2),h=N(l+s/2-(r?d:d/2)-.025*(r?n:o));e.save(),e.textAlign="center",e.fillStyle=t.colorTitle,e.font=_.font(t,"Title",o/200),e.lineWidth=0,e.fillText(t.title,c,h,r?o:n)}}(l,a),this.emit("beforeUnits"),function(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=N(a+(r?o:n)/2),h=N(l+(r?n:o)+s/2-d/2);e.save(),e.textAlign="center",e.fillStyle=t.colorUnits,e.font=_.font(t,"Units",o/200),e.lineWidth=0,e.fillText(t.units,c,h,r?o:n)}}(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(),this.emit("beforeProgressBar"),function(e,t,i,r,o,n){t.barProgress&&oe(e,t,"progress",i,r,o,n)}.apply(void 0,[e.context,a].concat(s(this.drawBox))),this.emit("beforeNeedle"),function(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,m="left"!==t.needleSide,v=d*(_.normalizedValue(t).indented-t.minValue)/(t.maxValue-t.minValue),g=(t.ticksWidth/100+u)*o,b=a/2+g,p=b*(t.needleEnd/100),w=void 0,k=void 0,y="arrow"===t.needleType.toLowerCase()?he:ce,T=(o-a)/2,x=b*(t.needleStart/100),S=T-g-x,W=T+a+g+x;e.save(),_.drawNeedleShadow(e,t),r?(k=N(h+n-s-l-v),f&&y(e,t,w=N(c+S),k,w+p,k,p),m&&y(e,t,w=N(c+W),k,w-p,k,p,!0)):(w=N(c+s+l+v),f&&y(e,t,w,k=N(h+S),w,k+p,p),m&&y(e,t,w,k=N(h+W),w,k-p,p,!0)),e.restore()}}(e.context,a),this.emit("beforeValueBox"),function(e,t,i,r,o,n,a){var l=(parseFloat(t.fontValueSize)||0)*n/200,s=(.11*a-l)/2;e.barDimensions.isVertical&&_.drawValueBox(e,t,i,r+n/2,o+a-l-s,n)}.apply(void 0,[e.context,a,a.animatedValue?this.options.value:this.value].concat(s(this.drawBox))),c(fe.prototype.__proto__||Object.getPrototypeOf(fe.prototype),"draw",this).call(this)}catch(e){_.verifyError(e)}return this}}],[{key:"configure",value:function(e){return e.barStrokeWidth>=e.barWidth&&(e.barStrokeWidth=N(e.barWidth/2)),e.hasLeft=ne("right",e),e.hasRight=ne("left",e),e.value>e.maxValue&&(e.value=e.maxValue),e.value<e.minValue&&(e.value=e.minValue),T.configure(e)}}]),fe);function fe(e){return a(this,fe),e=Object.assign({},te,e||{}),n(this,(fe.__proto__||Object.getPrototypeOf(fe)).call(this,fe.configure(e)))}void 0!==o&&(o.LinearGauge=ue),T.initialize("LinearGauge",te),"undefined"!=typeof module&&Object.assign(o,{Collection:w,GenericOptions:p,Animation:f,BaseGauge:T,drawings:_,SmartCanvas:C,DomObserver:v,vendorize:l})}("undefined"!=typeof module?module.exports:window);
//# sourceMappingURL=gauge.min.js.map