29 lines
35 KiB
JavaScript
29 lines
35 KiB
JavaScript
|
|
/*!
|
||
|
|
* The MIT License (MIT)
|
||
|
|
*
|
||
|
|
* Copyright (c) 2016 Mykhailo Stadnyk <mikhus@gmail.com>
|
||
|
|
*
|
||
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
|
|
* of this software and associated documentation files (the "Software"), to deal
|
||
|
|
* in the Software without restriction, including without limitation the rights
|
||
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
|
|
* copies of the Software, and to permit persons to whom the Software is
|
||
|
|
* furnished to do so, subject to the following conditions:
|
||
|
|
*
|
||
|
|
* The above copyright notice and this permission notice shall be included in
|
||
|
|
* all copies or substantial portions of the Software.
|
||
|
|
*
|
||
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||
|
|
* SOFTWARE.
|
||
|
|
*
|
||
|
|
* @version 2.0.8
|
||
|
|
*/
|
||
|
|
!function(e){"use strict";function t(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function r(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 i(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 r=["webkit","moz","ms","o"],i=0,o=r.length,n=e.charAt(0).toUpperCase()+e.substr(1);i<o;i++){var a=t[r[i]+n];if("undefined"!=typeof a)return a}return null}function a(e,t,r,i,o,n,l){if("function"!=typeof i)throw new TypeError("Invalid animation rule:",i);var s=e-r,d=s/o;d>1&&(d=1),t&&t(1===d?d:i(d)),s<o?l.frame=oe(function(e){return a(e,t,r,i,o,n,l)}):n&&n()}function l(){Array.prototype.constructor.apply(this,arguments)}function s(e){if(!(e instanceof DOMException&&2152923147===e.result))throw e}function d(e){return e.majorTicks instanceof Array||(e.majorTicks=e.majorTicks?[e.majorTicks]:[]),e.majorTicks.length||(e.majorTicks.push(me.formatMajorTickNumber(e.minValue,e)),e.majorTicks.push(me.formatMajorTickNumber(e.maxValue,e))),["right"!==e.tickSide,"left"!==e.tickSide]}function c(e,t,r,i,o,n){e.beginPath(),e.moveTo(t+n,r),e.lineTo(t+i-n,r),e.quadraticCurveTo(t+i,r,t+i,r+n),e.lineTo(t+i,r+o-n),e.quadraticCurveTo(t+i,r+o,t+i-n,r+o),e.lineTo(t+n,r+o),e.quadraticCurveTo(t,r+o,t,r+o-n),e.lineTo(t,r+n),e.quadraticCurveTo(t,r,t+n,r),e.closePath()}function h(e,t){var r=t.valueDec,i=t.valueInt,o=0,n=void 0,a=void 0,l=void 0;if(e=parseFloat(e),l=e<0,e=Math.abs(e),r>0){for(a=e.toFixed(r).toString().split("."),n=i-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=i-a.length;o<n;++o)a="0"+a;a=(l?"-":"")+a}return a}function u(e,t){var r=void 0,i=!1;return r=0===t.majorTicksDec?Math.round(e).toString():e.toFixed(t.majorTicksDec),t.majorTicksInt>1?(i=~r.indexOf("."),~r.indexOf("-")?"-"+[t.majorTicksInt+t.majorTicksDec+2+(i?1:0)-r.length].join("0")+r.replace("-",""):[t.majorTicksInt+t.majorTicksDec+1+(i?1:0)-r.length].join("0")+r):r}function f(e){return e*Math.PI/180}function v(e,t){return{x:-e*Math.sin(t),y:e*Math.cos(t)}}function m(e,t,r,i){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:i,o?i:0);return a.addColorStop(0,t),a.addColorStop(1,r),a}function b(e,t){var r=!(arguments.length<=2||void 0===arguments[2])&&arguments[2];if(r)return e.restore(),!0;e.save();var i=t.borderShadowWidth;return i&&(e.shadowBlur=i,e.shadowColor=t.colorBorderShadow),!0}function g(e,t){t.needleShadow&&(e.shadowOffsetX=2,e.shadowOffsetY=2,e.shadowBlur=10,e.shadowColor=t.colorNeedleShadowDown)}function p(e,t,r,i,o,n){if(t.valueBox){var a=t.valueText||h(r,t);e.shadowOffsetX=null,e.shadowOffsetY=null,e.shadowBlur=null,e.shadowColor="",e.strokeStyle=null,e.lineWidth=0,e.save(),e.font=t.fontValueStyle+" "+t.fontValueWeight+" "+t.fontValueSize*(n/200)+"px "+t.fontValue,e.save(),e.beginPath();var l=.12*n,s=parseFloat(t.valueBoxStroke)||0,d=2*n-2*s,u=e.measureText(t.valueText?a:"-"+h(0,t)).width,f=u+.05*n,v=l+.07*n,m=n*t.valueBoxBorderRadius/100,b=(parseFloat(t.valueBoxWidth)||0)/100*d;b>f&&(f=b),f>d&&(f=d);var g=i-f/2,p=o-l-.04*n;m?c(e,g,p,f,v,m):e.rect(g,p,f,v);var w=o-.12*n-.025*n+(.12*n+.045*n)/2;if(t.valueBoxStroke){var y=e.createRadialGradient(i,w,n/10,i,w,n/5);y.addColorStop(0,t.colorValueBoxRect),y.addColorStop(1,t.colorValueBoxRectEnd),e.strokeStyle=y,e.lineWidth=n*t.valueBoxStroke/100,e.stroke()}t.colorValueBoxShadow&&(e.shadowBlur=.012*n,e.shadowColor=t.colorValueBoxShadow),t.col
|
||
|
|
r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return i(t,e),ie(t,[{key:"draw",value:function(){try{var e=this.canvas,r=-e.drawX,i=-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(r,i,o,n),l.save(),x(l,a),T(l,a),k(l,a),W(l,a),B(l,a),P(l,a),V(l,a),e.elementClone.initialized=!0}this.canvas.commit(),e.context.clearRect(r,i,o,n),e.context.save(),e.context.drawImage(e.elementClone,r,i,o,n),e.context.save(),N(e.context,a,a.animatedValue?this.options.value:this.value),A(e.context,a)}else{var s=-me.radians((a.value-a.minValue)/(a.maxValue-a.minValue)*a.ticksAngle);if(e.context.clearRect(r,i,o,n),e.context.save(),x(e.context,a),e.context.rotate(s),T(e.context,a),k(e.context,a),W(e.context,a),B(e.context,a),e.context.rotate(-s),e.context.save(),!e.elementClone.initialized){var d=e.contextClone;d.clearRect(r,i,o,n),d.save(),P(d,a),V(d,a),A(d,a),e.elementClone.initialized=!0}e.context.drawImage(e.elementClone,r,i,o,n)}N(e.context,a,a.animatedValue?this.options.value:this.value),re(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"draw",this).call(this)}catch(e){me.verifyError(e)}return this}}]),t}(ve);"undefined"!=typeof e&&(e.RadialGauge=we),ve.initialize("RadialGauge",pe);var ye=Object.assign({},de,{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,highlightsWidth:10}),xe=function(e){function n(e){return o(this,n),e=Object.assign({},ye,e||{}),e.barStrokeWidth>=e.barWidth&&(e.barStrokeWidth=he(e.barWidth/2)),e.hasLeft=z("right",e),e.hasRight=z("left",e),r(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e))}return i(n,e),ie(n,[{key:"draw",value:function(){try{var e=this.canvas,r=-e.drawX,i=-e.drawY,o=e.drawWidth,a=e.drawHeight,l=this.options;if(!e.elementClone.initialized){var s=e.contextClone;s.clearRect(r,i,o,a),s.save(),this.drawBox=E(s,l,r,i,o,a),D.apply(void 0,[s,l].concat(t(this.drawBox))),e.context.barDimensions=s.barDimensions,_(s,l),F(s,l),Y(s,l),q(s,l),H(s,l),J(s,l),e.elementClone.initialized=!0}this.canvas.commit(),e.context.clearRect(r,i,o,a),e.context.save(),e.context.drawImage(e.elementClone,r,i,o,a),e.context.save(),L.apply(void 0,[e.context,l].concat(t(this.drawBox))),Z(e.context,l),ee.apply(void 0,[e.context,l,l.animatedValue?this.options.value:this.value].concat(t(this.drawBox))),re(n.prototype.__proto__||Object.getPrototypeOf(n.prototype),"draw",this).call(this)}catch(e){me.verifyError(e)}return this}}]),n}(ve);"undefined"!=typeof e&&(e.LinearGauge=xe),ve.initialize("LinearGauge",ye),"undefined"!=typeof module&&Object.assign(e,{Collection:l,GenericOptions:de,Animation:ae,BaseGauge:ve,drawings:me,SmartCanvas:se,vendorize:n})}("undefined"!=typeof module?module.exports:window);
|
||
|
|
//# sourceMappingURL=gauge.min.js.map
|