jmgraph 3.1.96 → 3.1.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jmgraph.core.min.js +1 -1
- package/dist/jmgraph.core.min.js.map +1 -1
- package/dist/jmgraph.js +105 -140
- package/dist/jmgraph.min.js +1 -1
- package/package.json +1 -1
- package/src/core/jmControl.js +59 -94
- package/src/core/jmGraph.js +6 -6
- package/src/core/jmProperty.js +18 -0
- package/src/core/jmUtils.js +6 -14
package/dist/jmgraph.core.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jmGraph={})}(this,function(t){"use strict";function l(t){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function h(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function u(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function a(t,e,n){return(a=s()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);i=new(Function.bind.apply(t,i));return n&&o(i,n.prototype),i}).apply(null,arguments)}function e(t){var n="function"==typeof Map?new Map:void 0;return function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return a(t,arguments,r(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)}(t)}function f(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function v(n){var i=s();return function(){var t,e=r(n);return f(this,i?(t=r(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments))}}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return d(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,e=function(){};return{s:e,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,r=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw r}}}}var y=function(){c(a,e(Array));var s=v(a);function a(){var t;h(this,a);for(var e=[],n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];if(i&&i.length&&Array.isArray(i[0])){for(var o=0;o<i[0].length;o++)e.push(i[0][o]);t=s.call.apply(s,[this].concat(e))}else t=s.call(this);return t.option={},t.type="jmList",f(t)}return u(a,[{key:"add",value:function(t){if(t&&Array.isArray(t)){for(var e=0;e<t.length;e++)this.includes(t[e])||this.push(t[e]);return t}return"object"==l(t)&&this.includes(t)||this.push(t),t}},{key:"remove",value:function(t){for(var e=this.length-1;0<=e;e--)this[e]==t&&this.removeAt(e)}},{key:"removeAt",value:function(t){var e;this.length>t&&(e=this[t],this.splice(t,1),this.option.removeHandler&&this.option.removeHandler.call(this,e,t))}},{key:"contain",value:function(t){return this.includes(t)}},{key:"get",value:function(t){return"function"==typeof t?this.find(t):this[t]}},{key:"each",value:function(t,e){if(t&&"function"==typeof t)if(e){for(var n=this.length-1;0<=n;n--)if(!1===t.call(this,n,this[n]))break}else for(var i=this.length,r=0;r<i;r++)if(!1===t.call(this,r,this[r]))break}},{key:"count",value:function(t){if(t&&"function"==typeof t){for(var e=0,n=this.length,i=0;i<n;i++)t(this[i])&&e++;return e}return this.length}},{key:"clear",value:function(){this.splice(0,this.length)}}]),a}(),m=function(){function t(){h(this,t)}function e(t){return n.apply(this,arguments)}var n,i;function r(t){return i.apply(this,arguments)}return u(t,null,[{key:"clone",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0;if("function"==typeof i){var o=i(t,n,r);if(o)return o}if("boolean"==typeof e&&(n=e,e=void 0),100<++r)return e;if(t&&"object"===l(t)){if(e=e||{},this.isType(t,y))return new y(t);if(Array.isArray(t)){if(n){for(var s=[],a=0;a<t.length;a++)s.push(this.clone(t[a],e[a],n,i,r));return s}return t.slice(0)}for(var h in t.__proto__&&(e.__proto__=t.__proto__),t)"constructor"!==h&&("object"!==l(e[h])&&void 0!==e[h]||(e[h]=this.clone(t[h],e[h],n,i,r)));return e}return void 0!==e?e:t}},{key:"bindEvent",value:function(t,e,n,i){if(e&&e.indexOf&&-1!=e.indexOf(" "))for(var r=e.split(" "),o=0;o<r.length;o++)this.bindEvent(t,r[o],n,i);return t.attachEvent?t.attachEvent("on"+e,n,i):t.addEventListener&&t.addEventListener(e,n,i),{name:e,target:t,fun:n}}},{key:"removeEvent",value:function(t,e,n){return t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent?(t.detachEvent("on"+e,n),!0):void(t["on"+e]=null)}},{key:"getElementPosition",value:function(t){var e={top:0,left:0};if(!t)return e;if(t.offsetParent)for(;t.offsetParent;)e.top+=t.offsetTop,e.left+=t.offsetLeft,t=t.offsetParent;else t.x?e.left+=t.x:t.x&&(e.top+=t.y);return e}},{key:"getEventPosition",value:function(t,e){var n=!1,i=(t=t||event).changedTouches||t.targetTouches||t.touches,r=t.target||t.srcElement;i&&i.length&&((t=i[0]).target||(t.target=r),n=!0);var o=t.pageX||t.x;void 0===o&&(o=t.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var s=t.pageY||t.y;void 0===s&&(s=t.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var a=t.offsetX,h=t.offsetY;return void 0===a&&void 0===h&&(a=o-(r=this.getElementPosition(r)).left,h=s-r.top),e&&(e.x&&(a/=e.x),e.y&&(h/=e.y)),{pageX:o,pageY:s,clientX:t.clientX,clientY:t.clientY,offsetX:a,offsetY:h,layerX:t.layerX,layerY:t.layerY,screenX:t.screenX,screenY:t.screenY,x:a,y:h,isTouch:n,touches:i}}},{key:"isType",value:function(t,e){return!(!t||"object"!==l(t))&&t.constructor===e}},{key:"pointInPolygon",value:function(t,e,n){n=n||1,n/=2;var i,r,o=e.length,s=!1,a=!0;if(!e||0==o)return 0;if(1==o)return Math.abs(e[0].x-t.x)<=n&&Math.abs(e[0].y-t.y)<=n;if(2==o){if(Math.min(e[0].x,e[1].x)-t.x>n||t.x-Math.max(e[0].x,e[1].x)>n)return 0;if(Math.min(e[0].y,e[1].y)-t.y>n||t.y-Math.max(e[0].y,e[1].y)>n)return 0;if(e[0].x==e[1].x)return Math.abs(e[0].x-t.x)<=n&&(t.y-e[0].y)*(t.y-e[1].y)<=0?1:0;if(e[0].y==e[1].y)return Math.abs(e[0].y-t.y)<=n&&(t.x-e[0].x)*(t.x-e[1].x)<=0?1:0;if(Math.abs(e[0].x-t.x)<n&&Math.abs(e[0].y-t.y)<n)return 1;if(Math.abs(e[1].x-t.x)<n&&Math.abs(e[1].y-t.y)<n)return 1;if(t.y==e[0].y||t.y==e[1].y)return 0;var h=(e[1].x-e[0].x)/(e[1].y-e[0].y)*(t.y-e[0].y),h=(t.y-e[0].y)/Math.sqrt(h*h+(t.y-e[0].y)*(t.y-e[0].y))*(t.x-e[0].x-h);return Math.abs(h)<=n?1:0}for(i=0;i<o;++i)if(e[i].x==t.x&&e[i].y==t.y)return 1;for(;a;)for(s=a=!1,i=0,r=o-1;i<o;r=i++)if(e[i].y<t.y&&t.y<e[r].y||e[r].y<t.y&&t.y<e[i].y){if(t.x<=e[i].x||t.x<=e[r].x){var u=(t.y-e[i].y)*(e[r].x-e[i].x)/(e[r].y-e[i].y)+e[i].x;if(t.x<u)s=!s;else if(t.x==u)return 1}}else if(t.y==e[i].y){if(t.x<e[i].x){e[i].y>e[r].y?--t.y:++t.y,a=!0;break}}else if(e[i].y==e[r].y&&t.y==e[i].y&&(e[i].x<t.x&&t.x<e[r].x||e[r].x<t.x&&t.x<e[i].x)){s=!0;break}return s?2:0}},{key:"checkOutSide",value:function(t,e,n){var i={left:0,right:0,top:0,bottom:0};return n.x<0?i.left=e.left+n.x-t.left:0<n.x&&(i.right=e.right+n.x-t.right),n.y<0?i.top=e.top+n.y-t.top:0<n.y&&(i.bottom=e.bottom+n.y-t.bottom),i}},{key:"rotatePoints",value:function(t,e,n){if(!n||!t)return t;var i=Math.cos(n),r=Math.sin(n);if(t.length)for(var o,s,a=0;a<t.length;a++)t[a]&&(o=t[a].x-e.x,s=t[a].y-e.y,t[a].x=o*i-s*r+e.x,t[a].y=o*r+s*i+e.y);else{var h=t.x-e.x,n=t.y-e.y;t.x=h*i-n*r+e.x,t.y=h*r+n*i+e.y}return t}},{key:"trimStart",value:function(t,e){if(e=e||" ",t&&0<t.length){var n=t[0];if(n===e||0<=e.indexOf(n))return t=t.substring(1),this.trimStart(t,e)}return t}},{key:"trimEnd",value:function(t,e){if(e=e||" ",t&&0<t.length){var n=t[t.length-1];if(n===e||0<=e.indexOf(n))return t=t.substring(0,t.length-1),this.trimStart(t,e)}return t}},{key:"trim",value:function(t,e){return this.trimEnd(this.trimStart(t,e),e)}},{key:"checkPercent",value:function(t){if("string"==typeof t&&"%"==(t=this.trim(t))[t.length-1])return t}},{key:"percentToNumber",value:function(t){var e;return"string"!=typeof t||(e=this.checkPercent(t))&&(t=this.trim(e,"% "),t/=100),t}},{key:"hexToNumber",value:function(t){if("string"!=typeof t)return t;for(var e=0,n=(t=t.toLowerCase()).length,i=0;i<n;i++){var r="0123456789abcdef".indexOf(t[i]);if(0!=r){for(var o=1;o<n-i;o++)r*=16;e+=r}}return e}},{key:"numberToHex",value:function(t){for(var e="";0<t;){e="0123456789abcdef"[t%16]+e;t=Math.floor(t/16)}return e}},{key:"hexToRGBA",value:function(t){if("#"==(t=this.trim(t))[0]){var e={a:1};if(8<=t.length)return e.a=t.substr(1,2),e.g=t.substr(5,2),e.b=t.substr(7,2),e.r=t.substr(3,2),e.a=(this.hexToNumber(e.a)/255).toFixed(4),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),e;if(7===t.length||4===t.length)return 4===t.length?(e.g=t.substr(2,1),e.g=e.g+e.g,e.b=t.substr(3,1),e.b=e.b+e.b,e.r=t.substr(1,1),e.r=e.r+e.r):(e.g=t.substr(3,2),e.b=t.substr(5,2),e.r=t.substr(1,2)),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),e;if(5===t.length)return e.a=t.substr(1,1),e.g=t.substr(3,1),e.b=t.substr(4,1),e.r=t.substr(2,1),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),e.a=(this.hexToNumber(e.a)/255).toFixed(4),e}return t}},{key:"toColor",value:function(t,e,n,i){if("string"==typeof t&&t){if("#"===(t=this.trim(t))[0]&&(4===t.length||7===t.length))return t;var r=this.hexToRGBA(t);if("string"==typeof r)return r;t=r.r||t,e=r.g||e,n=r.b||n,i=r.a||i}return void 0!==t&&void 0!==e&&void 0!==n?void 0!==i?"rgba("+t+","+e+","+n+","+i+")":"rgb("+t+","+e+","+n+")":t}},{key:"requestAnimationFrame",value:(i=function(t){return"undefined"==typeof requestAnimationFrame?setTimeout(t,20):requestAnimationFrame(t)},r.toString=function(){return i.toString()},r)},{key:"cancelAnimationFrame",value:(n=function(t){return("undefined"==typeof requestAnimationFrame?clearTimeout:cancelAnimationFrame)(t)},e.toString=function(){return n.toString()},e)}]),t}(),g=function(){function e(t){h(this,e),t&&"jmGraph"==t.type&&(this.graph=t)}return u(e,[{key:"is",value:function(t){return"string"==typeof t?this.type==t:this instanceof t}},{key:"animate",value:function(){if(this.is("jmGraph")){if(1<arguments.length){this.animateHandles||(this.animateHandles=new y);var t=[];if(2<arguments.length)for(var e=2;e<arguments.length;e++)t.push(e<0||arguments.length<=e?void 0:arguments[e]);this.animateHandles.add({millisec:(arguments.length<=1?void 0:arguments[1])||20,handle:arguments.length<=0?void 0:arguments[0],params:t})}var o;this.animateHandles&&0<this.animateHandles.count()&&((o=this).dispatcher=setTimeout(function(n){n=n||o;var t,i=[],r=(new Date).getTime();for(t in n.animateHandles.each(function(t,e){try{e&&e.handle&&(!e.times||r-e.times>=e.millisec)&&(!1===e.handle.apply(n,e.params)&&i.push(e),e.times=r)}catch(t){window.console&&window.console.info&&window.console.info(t.toString()),e&&i.push(e)}}),i)n.animateHandles.remove(i[t]);n.animate()},10,this))}else{var n=this.graph;n&&n.animate.apply(n,arguments)}}}]),e}(),b=Symbol("properties"),n=function(){c(n,g);var e=v(n);function n(){var t;return h(this,n),(t=e.call(this))[b]={},t}return u(n,[{key:"__pro",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(e){var i=this[b],r=e[0];if(1<e.length){var o=e[1],o={oldValue:i[r],newValue:o};return i[r]=e[1],this.emit&&this.emit("propertyChange",r,o),e[1]}if(1==e.length)return i[r]}}},{key:"needUpdate",get:function(){return this.__pro("needUpdate")},set:function(t){this.__pro("needUpdate",t),t&&!this.is("jmGraph")&&this.graph&&(this.graph.needUpdate=!0)}},{key:"graph",get:function(){return this.__pro("graph")||this.__pro("graph",this.findParent("jmGraph"))},set:function(t){return this.__pro("graph",t)}}]),n}(),x=function(){function r(t,e,n,i){h(this,r),"string"!=typeof t||e||n||i?(this.x=t,this.y=e,this.blur=n,this.color=i):this.fromString(t)}return u(r,[{key:"fromString",value:function(t){if(t){t=t.match(/\s*([^,]+)\s*,\s*([^,]+)\s*(,[^,]+)?\s*(,[\s\S]+)?\s*/i);return t&&(this.x=t[1]||0,this.y=t[2]||0,t[3]&&(t[3]=m.trim(t[3],", "),0===t[3].indexOf("#")||/^rgb/i.test(t[3])?this.color=t[3]:this.blur=m.trim(t[3],", ")),t[4]&&(this.color=m.trim(t[4],", "))),this}}},{key:"toString",value:function(){var t=this.x+","+this.y;return this.blur&&(t+=","+this.blur),this.color&&(t+=","+this.color),t}}]),r}(),_=function(){function n(t){if(h(this,n),this.stops=new y,t&&"object"==l(t))for(var e in t)this[e]=t[e];else"string"==typeof t&&this.fromString(t)}return u(n,[{key:"addStop",value:function(t,e){this.stops.add({offset:Number(t),color:e})}},{key:"toGradient",value:function(t){var i,e=t.context||t,n=t.absoluteBounds||t.getAbsoluteBounds(),r=this.x1||0,o=this.y1||0,s=this.x2,a=this.y2,h=t.getLocation(),t=0,t=(t=h.radius?2*h.radius:t)||Math.min(h.width,h.height);m.checkPercent(r)&&(r=m.percentToNumber(r)*(n.width||t)),m.checkPercent(s)&&(s=m.percentToNumber(s)*(n.width||t)),m.checkPercent(o)&&(o=m.percentToNumber(o)*(n.height||t)),m.checkPercent(a)&&(a=m.percentToNumber(a)*(n.height||t));h=Number(r)+n.left,r=Number(o)+n.top,o=Number(s)+n.left,s=Number(a)+n.top;return"linear"===this.type?i=e.createLinearGradient(h,r,o,s):"radial"===this.type&&(a=this.r1||0,n=this.r2,m.checkPercent(a)&&(a=m.percentToNumber(a),a*=t),m.checkPercent(n)&&(n=m.percentToNumber(n),n*=t),i=e.createCircularGradient?e.createCircularGradient(h,r,n):e.createRadialGradient(h,r,a,o,s,n)),this.stops.each(function(t,e){var n=m.toColor(e.color);i.addColorStop(e.offset,n)}),i}},{key:"fromString",value:function(t){if(t){var e=t.match(/(linear|radial)-gradient\s*\(\s*([^,]+)\s*,\s*((.|\s)+)\)/i);if(e&&!(e.length<3)){this.type=e[1].toLowerCase();t=m.trim(e[2]).split(/\s+/);"linear"==this.type?t.length<=2?(this.x2=t[0],this.y2=t[1]||0):(this.x1=t[0],this.y1=t[1],this.x2=t[2],this.y2=t[3]):t.length<=3?(this.x2=t[0],this.y2=t[1]||0,this.r2=t[2]||0):(this.x1=t[0],this.y1=t[1],this.r1=t[2],this.x2=t[3],this.y2=t[3],this.r2=t[3]);var n=e[3].match(/((rgb(a)?\s*\([\d,\.\s]+\))|(#[a-zA-Z\d]+))\s+([\d\.]+)/gi);if(n&&n.length)for(var i=0;i<n.length;i++){var r,o=m.trim(n[i]),s=o.lastIndexOf(" ");-1<s&&(r=Number(o.substr(s+1)),s=m.trim(o.substr(0,s)),!isNaN(r)&&s&&this.addStop(r,s))}}}}},{key:"toString",value:function(){var n=this.type+"-gradient(";return"linear"==this.type?n+=this.x1+" "+this.y1+" "+this.x2+" "+this.y2:n+=this.x1+" "+this.y1+" "+this.r1+" "+this.x2+" "+this.y2+" "+this.r2,this.stops.each(function(t,e){n+=","+e.color+" "+e.offset}),n+")"}}]),n}(),w=function(){function n(t,e){h(this,n),this.container=t,this.target=e||t,this.mouseHandler=new k(this,t,e),this.keyHandler=new E(this,t,e)}return u(n,[{key:"touchStart",value:function(t){if((t=t||window.event).eventName="touchstart",this.container.raiseEvent("touchstart",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchMove",value:function(t){if((t=t||window.event).eventName="touchmove",this.container.raiseEvent("touchmove",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchEnd",value:function(t){if((t=t||window.event).eventName="touchend",this.container.raiseEvent("touchend",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchCancel",value:function(t){if((t=t||window.event).eventName="touchcancel",this.container.raiseEvent("touchcancel",t),(t.target||t.srcElement)==this.target)return!1}},{key:"destroy",value:function(){this.mouseHandler.destroy(),this.keyHandler.destroy()}}]),n}(),k=function(){function i(t,e,n){h(this,i),this.instance=t,this.container=e,this.target=n||e,this.eventEvents={},this.init(t,e,n)}return u(i,[{key:"init",value:function(e,n,t){var i=this.target,r=void 0!==("undefined"==typeof document?"undefined":l(document))?document:null;this.eventEvents.mousedown=m.bindEvent(this.target,"mousedown",function(t){(t=t||window.event).eventName="mousedown",n.raiseEvent("mousedown",t)}),this.eventEvents.mousedown=m.bindEvent(this.target,"mousemove",function(t){if((t=t||window.event).eventName="mousemove",(t.target||t.srcElement)==i)return n.raiseEvent("mousemove",t),t.preventDefault&&t.preventDefault(),!1}),this.eventEvents.mousedown=m.bindEvent(this.target,"mouseover",function(t){(t=t||window.event).eventName="mouseover",n.raiseEvent("mouseover",t)}),this.eventEvents.mouseleave=m.bindEvent(this.target,"mouseleave",function(t){(t=t||window.event).eventName="mouseleave",n.raiseEvent("mouseleave",t)}),this.eventEvents.mouseout=m.bindEvent(this.target,"mouseout",function(t){(t=t||window.event).eventName="mouseout",n.raiseEvent("mouseout",t)}),r&&(this.eventEvents.mouseup=m.bindEvent(r,"mouseup",function(t){if(!((t=t||window.event).eventName="mouseup")===n.raiseEvent("mouseup",t))return t.preventDefault&&t.preventDefault(),!1})),this.eventEvents.dblclick=m.bindEvent(this.target,"dblclick",function(t){(t=t||window.event).eventName="dblclick",n.raiseEvent("dblclick",t)}),this.eventEvents.click=m.bindEvent(this.target,"click",function(t){(t=t||window.event).eventName="click",n.raiseEvent("click",t)}),r&&(this.eventEvents.resize=m.bindEvent(r,"resize",function(t){return(t=t||window.event).eventName="resize",n.raiseEvent("resize",t)})),this.eventEvents.touchstart=m.bindEvent(this.target,"touchstart",function(t){return t.eventName="touchstart",e.touchStart(t)},{passive:!1}),this.eventEvents.touchmove=m.bindEvent(this.target,"touchmove",function(t){return t.eventName="touchmove",e.touchMove(t)},{passive:!1}),r&&(this.eventEvents.touchend=m.bindEvent(r,"touchend",function(t){return t.eventName="touchend",e.touchEnd(t)},{passive:!1})),r&&(this.eventEvents.touchcancel=m.bindEvent(r,"touchcancel",function(t){return t.eventName="touchcancel",e.touchCancel(t)},{passive:!1}))}},{key:"destroy",value:function(){for(var t in this.eventEvents){var e=this.eventEvents[t];e&&e.fun&&m.removeEvent(e.target,t,e.fun)}}}]),i}(),E=function(){function i(t,e,n){h(this,i),this.instance=t,this.container=e,this.target=n||e,this.eventEvents={},this.init(e,n)}return u(i,[{key:"init",value:function(n,t){function i(t){return!(t=t.srcElement||t.target)||"INPUT"!=t.tagName&&"TEXTAREA"!=t.tagName&&"ANCHOR"!=t.tagName&&"FORM"!=t.tagName&&"FILE"!=t.tagName&&"IMG"!=t.tagName&&"HIDDEN"!=t.tagName&&"RADIO"!=t.tagName&&"TEXT"!=t.tagName}var e=void 0!==("undefined"==typeof document?"undefined":l(document))?document:null;e&&(this.eventEvents.keypress=m.bindEvent(e,"keypress",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keypress",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}})),e&&(this.eventEvents.keydown=m.bindEvent(e,"keydown",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keydown",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}})),e&&(this.eventEvents.keyup=m.bindEvent(e,"keyup",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keyup",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}}))}},{key:"destroy",value:function(){for(var t in this.eventEvents){var e=this.eventEvents[t];e&&e.fun&&m.removeEvent(e.target,t,e.fun)}}}]),i}(),S=function(){c(r,n);var i=v(r);function r(t,e){var n;return h(this,r),t=t||{},(n=i.call(this)).__pro("type",e||(this instanceof r?this.constructor:void 0).name),n.style=t&&t.style?t.style:{},n.width=t.width||0,n.height=t.height||0,t.position&&(n.position=t.position),n.graph=t.graph||null,n.zIndex=t.zIndex||0,n.interactive=void 0===t.interactive||t.interactive,n.jmStyleMap={fill:"fillStyle",stroke:"strokeStyle","shadow.blur":"shadowBlur","shadow.x":"shadowOffsetX","shadow.y":"shadowOffsetY","shadow.color":"shadowColor",lineWidth:"lineWidth",miterLimit:"miterLimit",fillStyle:"fillStyle",strokeStyle:"strokeStyle",font:"font",opacity:"globalAlpha",textAlign:"textAlign",textBaseline:"textBaseline",shadowBlur:"shadowBlur",shadowOffsetX:"shadowOffsetX",shadowOffsetY:"shadowOffsetY",shadowColor:"shadowColor",lineJoin:"lineJoin",lineCap:"lineCap"},n.initializing(),n.on=n.bind,n.option=t,n}return u(r,[{key:"type",get:function(){return this.__pro("type")}},{key:"context",get:function(){var t=this.__pro("context");if(t)return t;if(this.is("jmGraph")&&this.canvas&&this.canvas.getContext)return this.context=this.canvas.getContext("2d");t=this.graph;return t?t.context:t.canvas.getContext("2d")},set:function(t){return this.__pro("context",t)}},{key:"style",get:function(){return this.__pro("style")||this.__pro("style",{})},set:function(t){return this.needUpdate=!0,this.__pro("style",t)}},{key:"visible",get:function(){var t=this.__pro("visible");return t=void 0===t?this.__pro("visible",!0):t},set:function(t){return this.needUpdate=!0,this.__pro("visible",t)}},{key:"interactive",get:function(){return this.__pro("interactive")},set:function(t){return this.__pro("interactive",t)}},{key:"children",get:function(){return this.__pro("children")||this.__pro("children",new y)},set:function(t){return this.needUpdate=!0,this.__pro("children",t)}},{key:"width",get:function(){var t=this.__pro("width");return t=void 0===t?this.__pro("width",0):t},set:function(t){return this.needUpdate=!0,this.__pro("width",t)}},{key:"height",get:function(){var t=this.__pro("height");return t=void 0===t?this.__pro("height",0):t},set:function(t){return this.needUpdate=!0,this.__pro("height",t)}},{key:"zIndex",get:function(){return this.__pro("zIndex")||this.__pro("zIndex",0)},set:function(t){return this.needUpdate=!0,this.__pro("zIndex",t),this.children.sort(),this.needUpdate=!0,t}},{key:"cursor",get:function(){var t=this.graph;if(t)return t.css("cursor")},set:function(t){var e=this.graph;e&&e.css("cursor",t)}},{key:"initializing",value:function(){var e=this;this.children=this.children||new y;var n=this.children.add;this.children.add=function(t){if("object"===l(t))return t.parent&&t.parent!=e&&t.parent.children&&t.parent.children.remove(t),t.parent=e,this.contain(t)&&this.oremove(t),n.call(this,t),t.emit("add",t),e.needUpdate=!0,e.graph&&(t.graph=e.graph),this.sort(),t},this.children.oremove=this.children.remove,this.children.remove=function(t){"object"===l(t)&&(t.parent=null,t.graph=null,t.remove(!0),this.oremove(t),e.needUpdate=!0)},this.children.sort=function(){var t,i={};for(t in this.each(function(t,e){var n;e&&(!(n=e.zIndex)&&e.style&&e.style.zIndex&&(n=Number(e.style.zIndex),isNaN(n)&&(n=e.style.zIndex||0)),(i[n]||(i[n]=[])).push(e))}),this.splice(0,this.length),i)n.call(this,i[t])},this.children.clear=function(){this.each(function(t,e){this.remove(e)},!0)},this.needUpdate=!0}},{key:"setStyle",value:function(t){var u=this;if(t=t||m.clone(this.style,!0)){var e,n,i=function t(e,n,i){if(e){if("function"==typeof e)try{e=e.call(u)}catch(t){return void console.warn(t)}var r=l(e),i=u.jmStyleMap[i||n];if(e instanceof _||"string"==r&&-1<e.indexOf("-gradient"))t((e="string"==r&&-1<e.indexOf("-gradient")?new _(e):e).toGradient(u),i||n);else if("function"==r)i&&(e=e.call(u,i))&&t(e,i);else if(i)"string"==r&&-1<["fillStyle","strokeStyle","shadowColor"].indexOf(i)&&(e=m.toColor(e)),u.context[i]=e;else switch(n){case"shadow":if("string"==r){t(new x(e),n);break}for(var o in e)t(e[o],o,n+"."+o);break;case"translate":u.context.translate(e.x,e.y);break;case"rotation":if(!e.angle)break;var s,a=0,h=0;e.point&&(s=u.absoluteBounds||u.getAbsoluteBounds(),a=(e=u.getRotation(e)).rotateX+s.left,h=e.rotateY+s.top),0==a&&0==h||u.context.translate(a,h),u.context.rotate(e.angle),0==a&&0==h||u.context.translate(-a,-h);break;case"transform":Array.isArray(e)?u.context.transform.apply(u.context,e):"object"==l(e)&&u.context.transform(e.scaleX,e.skewX,e.skewY,e.scaleY,e.offsetX,e.offsetY);break;case"cursor":u.cursor=e}}};for(e in this.translate&&i(this.translate,"translate"),this.transform&&i(this.transform,"transform"),t)"constructor"!==e&&("string"==(n=l(t[e]))&&-1<t[e].indexOf("-gradient")?t[e]=new _(t[e]):"string"==n&&"shadow"==e&&(t[e]=new x(t[e])),i(t[e],e))}}},{key:"getBounds",value:function(t){if(this.bounds&&!t)return this.bounds;var e={};if("jmGraph"==this.type&&this.canvas)"function"==typeof this.canvas.width?e.right=this.canvas.width():this.canvas.width?e.right=this.canvas.width:this.width&&(e.right=this.width),"function"==typeof this.canvas.height?e.bottom=this.canvas.height():this.canvas.height?e.bottom=this.canvas.height:this.height&&(e.bottom=this.height);else if(this.points&&0<this.points.length)for(var n in this.points){n=this.points[n];(void 0===e.left||e.left>n.x)&&(e.left=n.x),(void 0===e.top||e.top>n.y)&&(e.top=n.y),(void 0===e.right||e.right<n.x)&&(e.right=n.x),(void 0===e.bottom||e.bottom<n.y)&&(e.bottom=n.y)}else!this.getLocation||(t=this.getLocation())&&(e.left=t.left,e.top=t.top,e.right=t.left+t.width,e.bottom=t.top+t.height);return e.left||(e.left=0),e.top||(e.top=0),e.right||(e.right=0),e.bottom||(e.bottom=0),e.width=e.right-e.left,e.height=e.bottom-e.top,this.bounds=e}},{key:"getLocation",value:function(){var t=this.location={left:0,top:0,width:0,height:0};t.position="function"==typeof this.position?this.position():m.clone(this.position),t.center=this.center&&"function"==typeof this.center?this.center():m.clone(this.center),t.start=this.start&&"function"==typeof this.start?this.start():m.clone(this.start),t.end=this.end&&"function"==typeof this.end?this.end():m.clone(this.end),t.radius=this.radius,t.width=this.width,t.height=this.height;var e=m.clone(this.style.margin,{});if(e.left=e.left||0,e.top=e.top||0,e.right=e.right||0,e.bottom=e.bottom||0,t.position?(t.left=t.position.x,t.top=t.position.y):(t.left=e.left,t.top=e.top),!this.parent)return t;e=this.parent.getBounds();return m.checkPercent(t.left)&&(t.left=m.percentToNumber(t.left)*e.width),m.checkPercent(t.top)&&(t.top=m.percentToNumber(t.top)*e.height),m.checkPercent(t.width)&&(t.width=m.percentToNumber(t.width)*e.width),m.checkPercent(t.height)&&(t.height=m.percentToNumber(t.height)*e.height),t.center&&(m.checkPercent(t.center.x)&&(t.center.x=m.percentToNumber(t.center.x)*e.width),m.checkPercent(t.center.y)&&(t.center.y=m.percentToNumber(t.center.y)*e.height)),t.radius&&m.checkPercent(t.radius)&&(t.radius=m.percentToNumber(t.radius)*Math.min(e.width,e.height)),t}},{key:"getRotation",value:function(t){var e;return(t=t||this.style.rotation)?(e=this.getBounds(),t.rotateX=t.point.x,m.checkPercent(t.rotateX)&&(t.rotateX=m.percentToNumber(t.rotateX)*e.width),t.rotateY=t.point.y,m.checkPercent(t.rotateY)&&(t.rotateY=m.percentToNumber(t.rotateY)*e.height)):(t=this.parent&&this.parent.getRotation?this.parent.getRotation():null)&&(e=this.getBounds(),t.rotateX-=e.left,t.rotateY-=e.top),t}},{key:"remove",value:function(){this.parent&&this.parent.children.remove(this)}},{key:"offset",value:function(t,e,n,i){n=!1!==n;var r=this.getLocation(!0),o=!1;if(r.position&&(r.left+=t,r.top+=e,this.position.x=r.left,this.position.y=r.top,o=!0),r.center&&(this.center.x=r.center.x+t,this.center.y=r.center.y+e,o=!0),r.start&&"object"==l(r.start)&&(this.start.x=r.start.x+t,this.start.y=r.start.y+e,o=!0),r.end&&"object"==l(r.end)&&(this.end.x=r.end.x+t,this.end.y=r.end.y+e,o=!0),0==o&&this.cpoints){var s=(this.cpoints,this.cpoints);if(s){for(var a=s.length,h=0;h<a;h++)s[h].x+=t,s[h].y+=e;o=!0}}if(0==o&&this.points){for(var u=this.points.length,c=0;c<u;c++)this.points[c].x+=t,this.points[c].y+=e;o=!0}this.emit("move",{offsetX:t,offsetY:e,trans:n,evt:i}),this.needUpdate=!0}},{key:"rotate",value:function(t,e){this.style.rotation={angle:t,point:e},this.needUpdate=!0}},{key:"getAbsoluteBounds",value:function(){var t=this.getBounds();if(this.parent&&this.parent.absoluteBounds){var e=this.parent.absoluteBounds||this.parent.getAbsoluteBounds();return{left:e.left+t.left,top:e.top+t.top,right:e.left+t.right,bottom:e.top+t.bottom,width:t.width,height:t.height}}return t}},{key:"beginDraw",value:function(){this.getLocation(!0),this.context.beginPath()}},{key:"endDraw",value:function(){this.style.close&&this.context.closePath(),this.style.fill&&this.context.fill(),!this.style.stroke&&this.style.fill||this.context.stroke(),this.needUpdate=!1}},{key:"draw",value:function(){if(this.points&&0<this.points.length){var t=(this.parent&&this.parent.absoluteBounds?this.parent:this).absoluteBounds;this.context.moveTo(this.points[0].x+t.left,this.points[0].y+t.top);for(var e=this.points.length,n=1;n<e;n++){var i=this.points[n];i.m?this.context.moveTo(i.x+t.left,i.y+t.top):this.context.lineTo(i.x+t.left,i.y+t.top)}}}},{key:"paint",value:function(t){!1!==t&&!1!==this.visible&&(this.initPoints&&this.initPoints(),this.bounds=null,this.absoluteBounds=this.getAbsoluteBounds(),t=!0,!this.is("jmGraph")&&this.graph&&(this.absoluteBounds.left>=this.graph.width||this.absoluteBounds.top>=this.graph.height||this.absoluteBounds.right<=0||this.absoluteBounds.bottom<=0)&&(t=!1),this.context.save(),this.emit("beginDraw",this),this.setStyle(),t&&this.beginDraw&&this.beginDraw(),t&&this.draw&&this.draw(),t&&this.endDraw&&this.endDraw(),this.children&&this.children.each(function(t,e){e&&e.paint&&e.paint()}),this.emit("endDraw",this),this.context.restore(),this.is("jmGraph")&&this.context.draw&&this.context.draw(),this.needUpdate=!1)}},{key:"getEvent",value:function(t){return this.__events?this.__events[t]:null}},{key:"bind",value:function(t,e){if(t&&-1<t.indexOf(" ")){var n,i=p(t=t.split(" "));try{for(i.s();!(n=i.n()).done;){var r=n.value;r&&this.bind(r,e)}}catch(t){i.e(t)}finally{i.f()}}else{t=this.getEvent(t)||function(t,e){return this.__events||(this.__events={}),this.__events[t]=e}.call(this,t,new y);t.contain(e)||t.add(e)}}},{key:"unbind",value:function(t,e){if(t&&-1<t.indexOf(" ")){var n,i=p(t=t.split(" "));try{for(i.s();!(n=i.n()).done;){var r=n.value;r&&this.unbind(r,e)}}catch(t){i.e(t)}finally{i.f()}}else{t=this.getEvent(t);t&&(e?t.remove(e):t.clear())}}},{key:"emit",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.runEventHandle(e[0],e.slice(1)),this}},{key:"runEventHandle",value:function(t,n){var i,t=this.getEvent(t);return t&&(i=this,Array.isArray(n)||(n=[n]),t.each(function(t,e){!1===e.apply(i,n)&&(n.cancel=!0)})),n.cancel}},{key:"checkPoint",value:function(t,e){if("jmGraph"==this.type){var n=this.getPosition(),i=n.left+(this.canvas.clientWidth||this.canvas.offsetWidth||this.canvas.width),r=n.top+(this.canvas.clientHeight||this.canvas.offsetHeight||this.canvas.height);return t.pageX>i||t.pageX<n.left?!1:!(t.pageY>r||t.pageY<n.top)}var r=this.getBounds(),n=this.getRotation(),o=this.points;if(o&&o.length||((o=[]).push({x:r.left,y:r.top}),o.push({x:r.right,y:r.top}),o.push({x:r.right,y:r.bottom}),o.push({x:r.left,y:r.bottom}),o.push({x:r.left,y:r.top})),e=Number(e||this.style.touchPadding||this.style.lineWidth||1),o&&o.length){if(n&&0!=n.angle&&(o=m.clone(o,!0),o=m.rotatePoints(o,{x:n.rotateX+r.left,y:n.rotateY+r.top},n.angle)),2<o.length&&(!this.style.fill||this.style.stroke)){for(var s=0,a=o.length,h=s+1;h<=a;h=++s+1)if(h==a){if(this.style.close)if(m.pointInPolygon(t,[o[s],o[0]],e))return!0}else if(m.pointInPolygon(t,[o[s],o[h]],e))return!0;if(!this.style.fill)return!1}return m.pointInPolygon(t,o,e)}return!(t.x>r.right||t.x<r.left)&&!(t.y>r.bottom||t.y<r.top)}},{key:"raiseEvent",value:function(n,i){if(!1!==this.visible){var t;i.position||(t=this.graph,e=i.srcElement||i.target,t=m.getEventPosition(i,t.scaleSize),i={position:t,button:0==i.button||t.isTouch?1:i.button,keyCode:i.keyCode||i.charCode||i.which,ctrlKey:i.ctrlKey,cancel:!1,event:i,srcElement:e}),i.path=i.path||[];var r=!1;if(this.children&&this.children.each(function(t,e){if(!0!==i.cancel&&(r=!1===e.raiseEvent(n,i)||r))return!1},!0),r)return!1;var e=(this.parent&&this.parent.absoluteBounds?this.parent:this).absoluteBounds;if(!e)return!1;i.position.x=i.position.offsetX-e.left,i.position.y=i.position.offsetY-e.top;e=!1!==this.interactive&&this.checkPoint(i.position);return e?(i.target||(i.target=this),this.runEventAndPopEvent(n,i),this.focused||"mousemove"!==n&&"touchmove"!==n||(this.focused=!0,this.raiseEvent("mousemove"===n?"mouseover":"touchover",i))):!1===this.interactive||e||!this.focused||"mousemove"!==n&&"touchmove"!==n||(this.focused=!1,this.runEventHandle("mousemove"===n?"mouseleave":"touchleave",i)),!1===i.cancel}}},{key:"runEventAndPopEvent",value:function(t,e){!0!==e.cancel&&(e.path.push(this),this.runEventHandle(t,e))}},{key:"clearEvents",value:function(t){t=this.getEvent(t);t&&t.clear}},{key:"findParent",value:function(t){if("string"==typeof t){if(this.type==t)return this}else if(this.is(t))return this;return this.parent?this.parent.findParent(t):null}},{key:"canMove",value:function(t,e){var s;return this.__mvMonitor||(this.__mvMonitor={},this.__mvMonitor.mouseDown=!1,this.__mvMonitor.curposition={x:0,y:0},(s=this).__mvMonitor.mv=function(t){var e=s;if(e.__mvMonitor.mouseDown){e.parent.bounds=null;var n,i=e.parent.getAbsoluteBounds(),r=t.position.offsetX-e.__mvMonitor.curposition.x,o=t.position.offsetY-e.__mvMonitor.curposition.y;return e.lockSide&&(n=e.bounds||e.getAbsoluteBounds(),(n=m.checkOutSide(i,n,{x:r,y:o})).left<0?e.lockSide.left&&(r-=n.left):0<n.right&&e.lockSide.right&&(r-=n.right),n.top<0?e.lockSide.top&&(o-=n.top):0<n.bottom&&e.lockSide.bottom&&(o-=n.bottom)),(r||o)&&(e.offset(r,o,!0,t),e.__mvMonitor.curposition.x=t.position.offsetX,e.__mvMonitor.curposition.y=t.position.offsetY),!1}},this.__mvMonitor.mu=function(t){var e=s;e.__mvMonitor.mouseDown&&(e.__mvMonitor.mouseDown=!1,e.emit("moveend",{position:e.__mvMonitor.curposition}))},this.__mvMonitor.ml=function(){var t=s;if(t.__mvMonitor.mouseDown)return t.__mvMonitor.mouseDown=!1,t.emit("moveend",{position:t.__mvMonitor.curposition}),!1},this.__mvMonitor.md=function(t){if(!this.__mvMonitor.mouseDown)return 0==t.button||1==t.button?(this.__mvMonitor.mouseDown=!0,this.__mvMonitor.curposition.x=t.position.offsetX,this.__mvMonitor.curposition.y=t.position.offsetY,this.emit("movestart",{position:this.__mvMonitor.curposition}),!(t.cancel=!0)):void 0}),e=e||this.graph,!1!==t?(e.bind("mousemove",this.__mvMonitor.mv),e.bind("mouseup",this.__mvMonitor.mu),e.bind("mouseleave",this.__mvMonitor.ml),this.bind("mousedown",this.__mvMonitor.md),e.bind("touchmove",this.__mvMonitor.mv),e.bind("touchend",this.__mvMonitor.mu),this.bind("touchstart",this.__mvMonitor.md)):(e.unbind("mousemove",this.__mvMonitor.mv),e.unbind("mouseup",this.__mvMonitor.mu),e.unbind("mouseleave",this.__mvMonitor.ml),this.unbind("mousedown",this.__mvMonitor.md),e.unbind("touchmove",this.__mvMonitor.mv),e.unbind("touchend",this.__mvMonitor.mu),this.unbind("touchstart",this.__mvMonitor.md)),this}}]),r}(),N=function(){c(i,S);var n=v(i);function i(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"jmPath";return h(this,i),(e=n.call(this,t,e)).points=t&&t.points?t.points:[],e}return u(i,[{key:"points",get:function(){return this.__pro("points")},set:function(t){return this.needUpdate=!0,this.__pro("points",t)}}]),i}(),M=function(){c(o,S);var r=v(o);function o(t,e,n){var i;return h(this,o),"function"==typeof e&&(n=e,e={}),(e=e||{}).mode=e.mode||"2d",e.interactive=!0,(i=r.call(this,e,"jmGraph")).option=e||{},i.devicePixelRatio=1,i.util=i.utils=m,"undefined"!=typeof wx&&wx.canIUse&&wx.canIUse("canvas")?("string"==typeof t&&(t=wx.createSelectorQuery().select("#"+t)),i.isWXMiniApp=!0):("string"==typeof t&&"undefined"!=typeof document?t=document.getElementById(t):t.length&&(t=t[0]),"CANVAS"!=t.tagName?(i.container=t,e=document.createElement("canvas"),t.appendChild(e),e.width=t.offsetWidth||t.clientWidth,e.height=t.offsetHeight||t.clientHeight,t=e):i.container=t.parentElement),i.canvas=t,i.context=t.getContext("2d"),i.__init(n),i}return u(o,[{key:"__init",value:function(t){this.shapes=Object.assign({path:N},this.option.shapes),this.on("beginDraw",function(){this.context.translate(.5,.5)}),this.on("endDraw",function(){this.context.translate(-.5,-.5)});var e="undefined"!=typeof window&&1<window.devicePixelRatio?window.devicePixelRatio:1;this.isWXMiniApp&&(e=wx.getSystemInfoSync().pixelRatio||1),this.devicePixelRatio=e,this.dprScaleSize=1<this.devicePixelRatio?this.devicePixelRatio:2,0<this.option.width&&(this.width=this.option.width),0<this.option.height&&(this.height=this.option.height),this.resize(),this.eventHandler=new w(this,this.canvas.canvas||this.canvas),this.option.autoRefresh&&this.autoRefresh(),t&&t(this)}},{key:"resize",value:function(t,e){this.canvas&&(this.__normalSize=this.__normalSize||{width:0,height:0},t=t||this.__normalSize.width||this.width,e=e||this.__normalSize.height||this.height,t&&(this.__normalSize.width=t),e&&(this.__normalSize.height=e),this.css("width",t+"px"),this.css("height",e+"px"),this.canvas.height=e*this.dprScaleSize,this.canvas.width=t*this.dprScaleSize,this.context.scale(this.dprScaleSize,this.dprScaleSize))}},{key:"pointToPixes",value:function(t){return t=this.dprScaleSize&&1!==this.dprScaleSize?Object.assign({},t,{x:t.x/this.dprScaleSize,y:t.y/this.dprScaleSize}):t}},{key:"width",get:function(){return this.__normalSize&&this.__normalSize.width?this.__normalSize.width:this.canvas?this.canvas.width:0},set:function(t){return this.needUpdate=!0,this.canvas&&this.resize(t),t}},{key:"height",get:function(){return this.__normalSize&&this.__normalSize.height?this.__normalSize.height:this.canvas?this.canvas.height:0},set:function(t){return this.needUpdate=!0,this.canvas&&this.resize(0,t),t}},{key:"getPosition",value:function(){var t=m.getElementPosition(this.canvas.canvas||this.canvas);return t.width=this.canvas.width,t.height=this.canvas.height,t.right=t.left+t.width,t.bottom=t.top+t.height,t}},{key:"registerShape",value:function(t,e){this.shapes[t]=e}},{key:"createShape",value:function(t,e){if(t="string"==typeof t?this.shapes[t]:t)return(e=e||{}).graph=this,new t(e)}},{key:"createShadow",value:function(t,e,n,i){return new x(t,e,n,i)}},{key:"createLinearGradient",value:function(t,e,n,i){return new _({type:"linear",x1:t,y1:e,x2:n,y2:i})}},{key:"createRadialGradient",value:function(t,e,n,i,r,o){return new _({type:"radial",x1:t,y1:e,r1:n,x2:i,y2:r,r2:o})}},{key:"refresh",value:function(){this.redraw()}},{key:"redraw",value:function(t,e){this.clear(t||this.width,e||this.height),this.paint()}},{key:"clear",value:function(t,e){t&&e||(t=this.width,e=this.height),this.style&&this.style.fill?this.points=[{x:0,y:0},{x:t,y:0},{x:t,y:e},{x:0,y:e}]:this.context.clearRect&&this.context.clearRect(0,0,t,e)}},{key:"css",value:function(t,e){if(this.canvas&&this.canvas.style)return void 0!==e&&(this.canvas.style[t]=e),this.canvas.style[t]}},{key:"createPath",value:function(t,e){return this.createShape("path",{points:t,style:e})}},{key:"createLine",value:function(t,e,n){return this.createShape("line",{start:t,end:e,style:n})}},{key:"zoomOut",value:function(){this.scale(.9,.9)}},{key:"zoomIn",value:function(){this.scale(1.1,1.1)}},{key:"zoomActual",value:function(){this.scaleSize?this.scale(1/this.scaleSize.x,1/this.scaleSize.y):this.scale(1,1)}},{key:"scale",value:function(t,e){this.normalSize||(this.normalSize={width:this.canvas.width,height:this.canvas.height}),this.context.scale(t,e),this.scaleSize?this.scaleSize={x:t*this.scaleSize.x,y:e*this.scaleSize.y}:this.scaleSize={x:t,y:e},this.refresh()}},{key:"toDataURL",value:function(){return this.canvas.toDataURL?this.canvas.toDataURL():""}},{key:"autoRefresh",value:function(e){if(!this.___isAutoRefreshing){var n=this;return this.___isAutoRefreshing=!0,n.__requestAnimationFrameFunHandler&&m.cancelAnimationFrame(n.__requestAnimationFrameFunHandler),n.__requestAnimationFrameFunHandler=m.requestAnimationFrame(function t(){n.destroyed?n.___isAutoRefreshing=!1:(n.needUpdate&&n.redraw(),n.emit("update"),n.__requestAnimationFrameFunHandler&&m.cancelAnimationFrame(n.__requestAnimationFrameFunHandler),n.__requestAnimationFrameFunHandler=m.requestAnimationFrame(t),e&&e())}),this}}},{key:"destroy",value:function(){this.eventHandler.destroy(),this.destroyed=!0}}],[{key:"create",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return a(o,e)}}]),o}();t.default=M,t.jmControl=S,t.jmEvents=w,t.jmGradient=_,t.jmGraph=M,t.jmList=y,t.jmPath=N,t.jmProperty=n,t.jmShadow=x,t.jmUtils=m,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jmGraph={})}(this,function(t){"use strict";function l(t){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function h(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function u(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function a(t,e,n){return(a=s()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);i=new(Function.bind.apply(t,i));return n&&o(i,n.prototype),i}).apply(null,arguments)}function e(t){var n="function"==typeof Map?new Map:void 0;return function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return a(t,arguments,r(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)}(t)}function f(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function v(n){var i=s();return function(){var t,e=r(n);return f(this,i?(t=r(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments))}}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return d(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,e=function(){};return{s:e,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,r=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw r}}}}var y=function(){c(a,e(Array));var s=v(a);function a(){var t;h(this,a);for(var e=[],n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];if(i&&i.length&&Array.isArray(i[0])){for(var o=0;o<i[0].length;o++)e.push(i[0][o]);t=s.call.apply(s,[this].concat(e))}else t=s.call(this);return t.option={},t.type="jmList",f(t)}return u(a,[{key:"add",value:function(t){if(t&&Array.isArray(t)){for(var e=0;e<t.length;e++)this.includes(t[e])||this.push(t[e]);return t}return"object"==l(t)&&this.includes(t)||this.push(t),t}},{key:"remove",value:function(t){for(var e=this.length-1;0<=e;e--)this[e]==t&&this.removeAt(e)}},{key:"removeAt",value:function(t){var e;this.length>t&&(e=this[t],this.splice(t,1),this.option.removeHandler&&this.option.removeHandler.call(this,e,t))}},{key:"contain",value:function(t){return this.includes(t)}},{key:"get",value:function(t){return"function"==typeof t?this.find(t):this[t]}},{key:"each",value:function(t,e){if(t&&"function"==typeof t)if(e){for(var n=this.length-1;0<=n;n--)if(!1===t.call(this,n,this[n]))break}else for(var i=this.length,r=0;r<i;r++)if(!1===t.call(this,r,this[r]))break}},{key:"count",value:function(t){if(t&&"function"==typeof t){for(var e=0,n=this.length,i=0;i<n;i++)t(this[i])&&e++;return e}return this.length}},{key:"clear",value:function(){this.splice(0,this.length)}}]),a}(),m=function(){function t(){h(this,t)}return u(t,null,[{key:"clone",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0;if("function"==typeof i){var o=i(t,n,r);if(o)return o}if("boolean"==typeof e&&(n=e,e=void 0),100<++r)return e;if(t&&"object"===l(t)){if(e=e||{},this.isType(t,y))return new y(t);if(Array.isArray(t)){if(n){for(var s=[],a=0;a<t.length;a++)s.push(this.clone(t[a],e[a],n,i,r));return s}return t.slice(0)}for(var h in t.__proto__&&(e.__proto__=t.__proto__),t)"constructor"!==h&&("object"!==l(e[h])&&void 0!==e[h]||(e[h]=this.clone(t[h],e[h],n,i,r)));return e}return void 0!==e?e:t}},{key:"bindEvent",value:function(t,e,n,i){if(e&&e.indexOf&&-1!=e.indexOf(" "))for(var r=e.split(" "),o=0;o<r.length;o++)this.bindEvent(t,r[o],n,i);return t.attachEvent?t.attachEvent("on"+e,n,i):t.addEventListener&&t.addEventListener(e,n,i),{name:e,target:t,fun:n}}},{key:"removeEvent",value:function(t,e,n){return t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent?(t.detachEvent("on"+e,n),!0):void(t["on"+e]=null)}},{key:"getElementPosition",value:function(t){var e={top:0,left:0};if(!t)return e;if(t.offsetParent)for(;t.offsetParent;)e.top+=t.offsetTop,e.left+=t.offsetLeft,t=t.offsetParent;else t.x?e.left+=t.x:t.x&&(e.top+=t.y);return e}},{key:"getEventPosition",value:function(t,e){var n=!1,i=(t=t||event).changedTouches||t.targetTouches||t.touches,r=t.target||t.srcElement;i&&i.length&&((t=i[0]).target||(t.target=r),n=!0);var o=t.pageX||t.x;void 0===o&&(o=t.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var s=t.pageY||t.y;void 0===s&&(s=t.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var a=t.offsetX,h=t.offsetY;return void 0===a&&void 0===h&&(a=o-(r=this.getElementPosition(r)).left,h=s-r.top),e&&(e.x&&(a/=e.x),e.y&&(h/=e.y)),{pageX:o,pageY:s,clientX:t.clientX,clientY:t.clientY,offsetX:a,offsetY:h,layerX:t.layerX,layerY:t.layerY,screenX:t.screenX,screenY:t.screenY,x:a,y:h,isTouch:n,touches:i}}},{key:"isType",value:function(t,e){return!(!t||"object"!==l(t))&&t.constructor===e}},{key:"pointInPolygon",value:function(t,e,n){n=n||1,n/=2;var i,r,o=e.length,s=!1,a=!0;if(!e||0==o)return 0;if(1==o)return Math.abs(e[0].x-t.x)<=n&&Math.abs(e[0].y-t.y)<=n;if(2==o){if(Math.min(e[0].x,e[1].x)-t.x>n||t.x-Math.max(e[0].x,e[1].x)>n)return 0;if(Math.min(e[0].y,e[1].y)-t.y>n||t.y-Math.max(e[0].y,e[1].y)>n)return 0;if(e[0].x==e[1].x)return Math.abs(e[0].x-t.x)<=n&&(t.y-e[0].y)*(t.y-e[1].y)<=0?1:0;if(e[0].y==e[1].y)return Math.abs(e[0].y-t.y)<=n&&(t.x-e[0].x)*(t.x-e[1].x)<=0?1:0;if(Math.abs(e[0].x-t.x)<n&&Math.abs(e[0].y-t.y)<n)return 1;if(Math.abs(e[1].x-t.x)<n&&Math.abs(e[1].y-t.y)<n)return 1;if(t.y==e[0].y||t.y==e[1].y)return 0;var h=(e[1].x-e[0].x)/(e[1].y-e[0].y)*(t.y-e[0].y),h=(t.y-e[0].y)/Math.sqrt(h*h+(t.y-e[0].y)*(t.y-e[0].y))*(t.x-e[0].x-h);return Math.abs(h)<=n?1:0}for(i=0;i<o;++i)if(e[i].x==t.x&&e[i].y==t.y)return 1;for(;a;)for(s=a=!1,i=0,r=o-1;i<o;r=i++)if(e[i].y<t.y&&t.y<e[r].y||e[r].y<t.y&&t.y<e[i].y){if(t.x<=e[i].x||t.x<=e[r].x){var u=(t.y-e[i].y)*(e[r].x-e[i].x)/(e[r].y-e[i].y)+e[i].x;if(t.x<u)s=!s;else if(t.x==u)return 1}}else if(t.y==e[i].y){if(t.x<e[i].x){e[i].y>e[r].y?--t.y:++t.y,a=!0;break}}else if(e[i].y==e[r].y&&t.y==e[i].y&&(e[i].x<t.x&&t.x<e[r].x||e[r].x<t.x&&t.x<e[i].x)){s=!0;break}return s?2:0}},{key:"checkOutSide",value:function(t,e,n){var i={left:0,right:0,top:0,bottom:0};return n.x<0?i.left=e.left+n.x-t.left:0<n.x&&(i.right=e.right+n.x-t.right),n.y<0?i.top=e.top+n.y-t.top:0<n.y&&(i.bottom=e.bottom+n.y-t.bottom),i}},{key:"rotatePoints",value:function(t,e,n){if(!n||!t)return t;var i=Math.cos(n),r=Math.sin(n);if(t.length)for(var o,s,a=0;a<t.length;a++)t[a]&&(o=t[a].x-e.x,s=t[a].y-e.y,t[a].x=o*i-s*r+e.x,t[a].y=o*r+s*i+e.y);else{var h=t.x-e.x,n=t.y-e.y;t.x=h*i-n*r+e.x,t.y=h*r+n*i+e.y}return t}},{key:"trimStart",value:function(t,e){if(e=e||" ",t&&0<t.length){var n=t[0];if(n===e||0<=e.indexOf(n))return t=t.substring(1),this.trimStart(t,e)}return t}},{key:"trimEnd",value:function(t,e){if(e=e||" ",t&&0<t.length){var n=t[t.length-1];if(n===e||0<=e.indexOf(n))return t=t.substring(0,t.length-1),this.trimStart(t,e)}return t}},{key:"trim",value:function(t,e){return this.trimEnd(this.trimStart(t,e),e)}},{key:"checkPercent",value:function(t){if("string"==typeof t&&"%"==(t=this.trim(t))[t.length-1])return t}},{key:"percentToNumber",value:function(t){var e;return"string"!=typeof t||(e=this.checkPercent(t))&&(t=this.trim(e,"% "),t/=100),t}},{key:"hexToNumber",value:function(t){if("string"!=typeof t)return t;for(var e=0,n=(t=t.toLowerCase()).length,i=0;i<n;i++){var r="0123456789abcdef".indexOf(t[i]);if(0!=r){for(var o=1;o<n-i;o++)r*=16;e+=r}}return e}},{key:"numberToHex",value:function(t){for(var e="";0<t;){e="0123456789abcdef"[t%16]+e;t=Math.floor(t/16)}return e}},{key:"hexToRGBA",value:function(t){if("#"==(t=this.trim(t))[0]){var e={a:1};if(8<=t.length)return e.a=t.substr(1,2),e.g=t.substr(5,2),e.b=t.substr(7,2),e.r=t.substr(3,2),e.a=(this.hexToNumber(e.a)/255).toFixed(4),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),e;if(7===t.length||4===t.length)return 4===t.length?(e.g=t.substr(2,1),e.g=e.g+e.g,e.b=t.substr(3,1),e.b=e.b+e.b,e.r=t.substr(1,1),e.r=e.r+e.r):(e.g=t.substr(3,2),e.b=t.substr(5,2),e.r=t.substr(1,2)),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),e;if(5===t.length)return e.a=t.substr(1,1),e.g=t.substr(3,1),e.b=t.substr(4,1),e.r=t.substr(2,1),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),e.a=(this.hexToNumber(e.a)/255).toFixed(4),e}return t}},{key:"toColor",value:function(t,e,n,i){if("string"==typeof t&&t){if("#"===(t=this.trim(t))[0]&&(4===t.length||7===t.length))return t;var r=this.hexToRGBA(t);if("string"==typeof r)return r;t=r.r||t,e=r.g||e,n=r.b||n,i=r.a||i}return void 0!==t&&void 0!==e&&void 0!==n?void 0!==i?"rgba("+t+","+e+","+n+","+i+")":"rgb("+t+","+e+","+n+")":t}},{key:"requestAnimationFrame",value:function(t,e){return(e&&e.requestAnimationFrame?e.requestAnimationFrame:"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:setTimeout)(t,20)}},{key:"cancelAnimationFrame",value:function(t,e){return(e&&e.cancelAnimationFrame?e.cancelAnimationFrame:"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame:clearTimeout)(t)}}]),t}(),g=function(){function e(t){h(this,e),t&&"jmGraph"==t.type&&(this.graph=t)}return u(e,[{key:"is",value:function(t){return"string"==typeof t?this.type==t:this instanceof t}},{key:"animate",value:function(){if(this.is("jmGraph")){if(1<arguments.length){this.animateHandles||(this.animateHandles=new y);var t=[];if(2<arguments.length)for(var e=2;e<arguments.length;e++)t.push(e<0||arguments.length<=e?void 0:arguments[e]);this.animateHandles.add({millisec:(arguments.length<=1?void 0:arguments[1])||20,handle:arguments.length<=0?void 0:arguments[0],params:t})}var o;this.animateHandles&&0<this.animateHandles.count()&&((o=this).dispatcher=setTimeout(function(n){n=n||o;var t,i=[],r=(new Date).getTime();for(t in n.animateHandles.each(function(t,e){try{e&&e.handle&&(!e.times||r-e.times>=e.millisec)&&(!1===e.handle.apply(n,e.params)&&i.push(e),e.times=r)}catch(t){window.console&&window.console.info&&window.console.info(t.toString()),e&&i.push(e)}}),i)n.animateHandles.remove(i[t]);n.animate()},10,this))}else{var n=this.graph;n&&n.animate.apply(n,arguments)}}}]),e}(),b=Symbol("properties"),n=function(){c(n,g);var e=v(n);function n(){var t;return h(this,n),(t=e.call(this))[b]={},t}return u(n,[{key:"__pro",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(e){var i=this[b],r=e[0];if(1<e.length){var o=e[1],o={oldValue:i[r],newValue:o};return i[r]=e[1],this.emit&&this.emit("propertyChange",r,o),e[1]}if(1==e.length)return i[r]}}},{key:"needUpdate",get:function(){return this.__pro("needUpdate")},set:function(t){this.__pro("needUpdate",t),t&&!this.is("jmGraph")&&this.graph&&(this.graph.needUpdate=!0)}},{key:"graph",get:function(){return this.__pro("graph")||this.__pro("graph",this.findParent("jmGraph"))},set:function(t){return this.__pro("graph",t)}},{key:"requestAnimationFrame",value:function(t){return m.requestAnimationFrame(t,this.graph?this.graph.canvas:null)}},{key:"cancelAnimationFrame",value:function(t){return m.cancelAnimationFrame(t,this.graph?this.graph.canvas:null)}}]),n}(),x=function(){function r(t,e,n,i){h(this,r),"string"!=typeof t||e||n||i?(this.x=t,this.y=e,this.blur=n,this.color=i):this.fromString(t)}return u(r,[{key:"fromString",value:function(t){if(t){t=t.match(/\s*([^,]+)\s*,\s*([^,]+)\s*(,[^,]+)?\s*(,[\s\S]+)?\s*/i);return t&&(this.x=t[1]||0,this.y=t[2]||0,t[3]&&(t[3]=m.trim(t[3],", "),0===t[3].indexOf("#")||/^rgb/i.test(t[3])?this.color=t[3]:this.blur=m.trim(t[3],", ")),t[4]&&(this.color=m.trim(t[4],", "))),this}}},{key:"toString",value:function(){var t=this.x+","+this.y;return this.blur&&(t+=","+this.blur),this.color&&(t+=","+this.color),t}}]),r}(),_=function(){function n(t){if(h(this,n),this.stops=new y,t&&"object"==l(t))for(var e in t)this[e]=t[e];else"string"==typeof t&&this.fromString(t)}return u(n,[{key:"addStop",value:function(t,e){this.stops.add({offset:Number(t),color:e})}},{key:"toGradient",value:function(t){var i,e=t.context||t,n=t.absoluteBounds||t.getAbsoluteBounds(),r=this.x1||0,o=this.y1||0,s=this.x2,a=this.y2,h=t.getLocation(),t=0,t=(t=h.radius?2*h.radius:t)||Math.min(h.width,h.height);m.checkPercent(r)&&(r=m.percentToNumber(r)*(n.width||t)),m.checkPercent(s)&&(s=m.percentToNumber(s)*(n.width||t)),m.checkPercent(o)&&(o=m.percentToNumber(o)*(n.height||t)),m.checkPercent(a)&&(a=m.percentToNumber(a)*(n.height||t));h=Number(r)+n.left,r=Number(o)+n.top,o=Number(s)+n.left,s=Number(a)+n.top;return"linear"===this.type?i=e.createLinearGradient(h,r,o,s):"radial"===this.type&&(a=this.r1||0,n=this.r2,m.checkPercent(a)&&(a=m.percentToNumber(a),a*=t),m.checkPercent(n)&&(n=m.percentToNumber(n),n*=t),i=e.createCircularGradient?e.createCircularGradient(h,r,n):e.createRadialGradient(h,r,a,o,s,n)),this.stops.each(function(t,e){var n=m.toColor(e.color);i.addColorStop(e.offset,n)}),i}},{key:"fromString",value:function(t){if(t){var e=t.match(/(linear|radial)-gradient\s*\(\s*([^,]+)\s*,\s*((.|\s)+)\)/i);if(e&&!(e.length<3)){this.type=e[1].toLowerCase();t=m.trim(e[2]).split(/\s+/);"linear"==this.type?t.length<=2?(this.x2=t[0],this.y2=t[1]||0):(this.x1=t[0],this.y1=t[1],this.x2=t[2],this.y2=t[3]):t.length<=3?(this.x2=t[0],this.y2=t[1]||0,this.r2=t[2]||0):(this.x1=t[0],this.y1=t[1],this.r1=t[2],this.x2=t[3],this.y2=t[3],this.r2=t[3]);var n=e[3].match(/((rgb(a)?\s*\([\d,\.\s]+\))|(#[a-zA-Z\d]+))\s+([\d\.]+)/gi);if(n&&n.length)for(var i=0;i<n.length;i++){var r,o=m.trim(n[i]),s=o.lastIndexOf(" ");-1<s&&(r=Number(o.substr(s+1)),s=m.trim(o.substr(0,s)),!isNaN(r)&&s&&this.addStop(r,s))}}}}},{key:"toString",value:function(){var n=this.type+"-gradient(";return"linear"==this.type?n+=this.x1+" "+this.y1+" "+this.x2+" "+this.y2:n+=this.x1+" "+this.y1+" "+this.r1+" "+this.x2+" "+this.y2+" "+this.r2,this.stops.each(function(t,e){n+=","+e.color+" "+e.offset}),n+")"}}]),n}(),w=function(){function n(t,e){h(this,n),this.container=t,this.target=e||t,this.mouseHandler=new k(this,t,e),this.keyHandler=new E(this,t,e)}return u(n,[{key:"touchStart",value:function(t){if((t=t||window.event).eventName="touchstart",this.container.raiseEvent("touchstart",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchMove",value:function(t){if((t=t||window.event).eventName="touchmove",this.container.raiseEvent("touchmove",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchEnd",value:function(t){if((t=t||window.event).eventName="touchend",this.container.raiseEvent("touchend",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchCancel",value:function(t){if((t=t||window.event).eventName="touchcancel",this.container.raiseEvent("touchcancel",t),(t.target||t.srcElement)==this.target)return!1}},{key:"destroy",value:function(){this.mouseHandler.destroy(),this.keyHandler.destroy()}}]),n}(),k=function(){function i(t,e,n){h(this,i),this.instance=t,this.container=e,this.target=n||e,this.eventEvents={},this.init(t,e,n)}return u(i,[{key:"init",value:function(e,n,t){var i=this.target,r=void 0!==("undefined"==typeof document?"undefined":l(document))?document:null;this.eventEvents.mousedown=m.bindEvent(this.target,"mousedown",function(t){(t=t||window.event).eventName="mousedown",n.raiseEvent("mousedown",t)}),this.eventEvents.mousedown=m.bindEvent(this.target,"mousemove",function(t){if((t=t||window.event).eventName="mousemove",(t.target||t.srcElement)==i)return n.raiseEvent("mousemove",t),t.preventDefault&&t.preventDefault(),!1}),this.eventEvents.mousedown=m.bindEvent(this.target,"mouseover",function(t){(t=t||window.event).eventName="mouseover",n.raiseEvent("mouseover",t)}),this.eventEvents.mouseleave=m.bindEvent(this.target,"mouseleave",function(t){(t=t||window.event).eventName="mouseleave",n.raiseEvent("mouseleave",t)}),this.eventEvents.mouseout=m.bindEvent(this.target,"mouseout",function(t){(t=t||window.event).eventName="mouseout",n.raiseEvent("mouseout",t)}),r&&(this.eventEvents.mouseup=m.bindEvent(r,"mouseup",function(t){if(!((t=t||window.event).eventName="mouseup")===n.raiseEvent("mouseup",t))return t.preventDefault&&t.preventDefault(),!1})),this.eventEvents.dblclick=m.bindEvent(this.target,"dblclick",function(t){(t=t||window.event).eventName="dblclick",n.raiseEvent("dblclick",t)}),this.eventEvents.click=m.bindEvent(this.target,"click",function(t){(t=t||window.event).eventName="click",n.raiseEvent("click",t)}),r&&(this.eventEvents.resize=m.bindEvent(r,"resize",function(t){return(t=t||window.event).eventName="resize",n.raiseEvent("resize",t)})),this.eventEvents.touchstart=m.bindEvent(this.target,"touchstart",function(t){return t.eventName="touchstart",e.touchStart(t)},{passive:!1}),this.eventEvents.touchmove=m.bindEvent(this.target,"touchmove",function(t){return t.eventName="touchmove",e.touchMove(t)},{passive:!1}),r&&(this.eventEvents.touchend=m.bindEvent(r,"touchend",function(t){return t.eventName="touchend",e.touchEnd(t)},{passive:!1})),r&&(this.eventEvents.touchcancel=m.bindEvent(r,"touchcancel",function(t){return t.eventName="touchcancel",e.touchCancel(t)},{passive:!1}))}},{key:"destroy",value:function(){for(var t in this.eventEvents){var e=this.eventEvents[t];e&&e.fun&&m.removeEvent(e.target,t,e.fun)}}}]),i}(),E=function(){function i(t,e,n){h(this,i),this.instance=t,this.container=e,this.target=n||e,this.eventEvents={},this.init(e,n)}return u(i,[{key:"init",value:function(n,t){function i(t){return!(t=t.srcElement||t.target)||"INPUT"!=t.tagName&&"TEXTAREA"!=t.tagName&&"ANCHOR"!=t.tagName&&"FORM"!=t.tagName&&"FILE"!=t.tagName&&"IMG"!=t.tagName&&"HIDDEN"!=t.tagName&&"RADIO"!=t.tagName&&"TEXT"!=t.tagName}var e=void 0!==("undefined"==typeof document?"undefined":l(document))?document:null;e&&(this.eventEvents.keypress=m.bindEvent(e,"keypress",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keypress",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}})),e&&(this.eventEvents.keydown=m.bindEvent(e,"keydown",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keydown",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}})),e&&(this.eventEvents.keyup=m.bindEvent(e,"keyup",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keyup",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}}))}},{key:"destroy",value:function(){for(var t in this.eventEvents){var e=this.eventEvents[t];e&&e.fun&&m.removeEvent(e.target,t,e.fun)}}}]),i}(),S={fill:"fillStyle",stroke:"strokeStyle","shadow.blur":"shadowBlur","shadow.x":"shadowOffsetX","shadow.y":"shadowOffsetY","shadow.color":"shadowColor",lineWidth:"lineWidth",miterLimit:"miterLimit",fillStyle:"fillStyle",strokeStyle:"strokeStyle",font:"font",opacity:"globalAlpha",textAlign:"textAlign",textBaseline:"textBaseline",shadowBlur:"shadowBlur",shadowOffsetX:"shadowOffsetX",shadowOffsetY:"shadowOffsetY",shadowColor:"shadowColor",lineJoin:"lineJoin",lineCap:"lineCap"},A=function(){c(r,n);var i=v(r);function r(t,e){var n;return h(this,r),t=t||{},(n=i.call(this)).__pro("type",e||(this instanceof r?this.constructor:void 0).name),n.style=t&&t.style?t.style:{},n.width=t.width||0,n.height=t.height||0,t.position&&(n.position=t.position),n.graph=t.graph||null,n.zIndex=t.zIndex||0,n.interactive=void 0===t.interactive||t.interactive,n.initializing(),n.on=n.bind,n.option=t,n}return u(r,[{key:"type",get:function(){return this.__pro("type")}},{key:"context",get:function(){var t=this.__pro("context");if(t)return t;if(this.is("jmGraph")&&this.canvas&&this.canvas.getContext)return this.context=this.canvas.getContext("2d");t=this.graph;return t?t.context:t.canvas.getContext("2d")},set:function(t){return this.__pro("context",t)}},{key:"style",get:function(){return this.__pro("style")||this.__pro("style",{})},set:function(t){return this.needUpdate=!0,this.__pro("style",t)}},{key:"visible",get:function(){var t=this.__pro("visible");return t=void 0===t?this.__pro("visible",!0):t},set:function(t){return this.needUpdate=!0,this.__pro("visible",t)}},{key:"interactive",get:function(){return this.__pro("interactive")},set:function(t){return this.__pro("interactive",t)}},{key:"children",get:function(){return this.__pro("children")||this.__pro("children",new y)},set:function(t){return this.needUpdate=!0,this.__pro("children",t)}},{key:"width",get:function(){var t=this.__pro("width");return t=void 0===t?this.__pro("width",0):t},set:function(t){return this.needUpdate=!0,this.__pro("width",t)}},{key:"height",get:function(){var t=this.__pro("height");return t=void 0===t?this.__pro("height",0):t},set:function(t){return this.needUpdate=!0,this.__pro("height",t)}},{key:"zIndex",get:function(){return this.__pro("zIndex")||this.__pro("zIndex",0)},set:function(t){return this.needUpdate=!0,this.__pro("zIndex",t),this.children.sort(),this.needUpdate=!0,t}},{key:"cursor",get:function(){var t=this.graph;if(t)return t.css("cursor")},set:function(t){var e=this.graph;e&&e.css("cursor",t)}},{key:"initializing",value:function(){var e=this;this.children=this.children||new y;var n=this.children.add;this.children.add=function(t){if("object"===l(t))return t.parent&&t.parent!=e&&t.parent.children&&t.parent.children.remove(t),t.parent=e,this.contain(t)&&this.oremove(t),n.call(this,t),t.emit("add",t),e.needUpdate=!0,e.graph&&(t.graph=e.graph),this.sort(),t},this.children.oremove=this.children.remove,this.children.remove=function(t){"object"===l(t)&&(t.parent=null,t.graph=null,t.remove(!0),this.oremove(t),e.needUpdate=!0)},this.children.sort=function(){var t,i={};for(t in this.each(function(t,e){var n;e&&(!(n=e.zIndex)&&e.style&&e.style.zIndex&&(n=Number(e.style.zIndex),isNaN(n)&&(n=e.style.zIndex||0)),(i[n]||(i[n]=[])).push(e))}),this.splice(0,this.length),i)n.call(this,i[t])},this.children.clear=function(){this.each(function(t,e){this.remove(e)},!0)},this.needUpdate=!0}},{key:"setStyle",value:function(t){var c=this;if(t=t||m.clone(this.style,!0)){var e,n,i=function t(e,n,i){if(e){if("function"==typeof(a=e))try{a=a.call(c)}catch(t){return void console.warn(t)}var r=l(a),i=S[i||n];if(a instanceof _||"string"==r&&-1<a.indexOf("-gradient"))t((a="string"==r&&-1<a.indexOf("-gradient")?new _(a):a).toGradient(c),i||n);else if(i)"string"==r&&-1<["fillStyle","strokeStyle","shadowColor"].indexOf(i)&&(a=m.toColor(a)),c.context[i]=a;else switch(n){case"shadow":if("string"==r){t(new x(a),n);break}for(var o in a)t(a[o],o,n+"."+o);break;case"translate":c.context.translate(a.x,a.y);break;case"rotation":if(!a.angle)break;var s,a,h=0,u=0;a.point&&(s=c.absoluteBounds||c.getAbsoluteBounds(),h=(a=c.getRotation(a)).rotateX+s.left,u=a.rotateY+s.top),0==h&&0==u||c.context.translate(h,u),c.context.rotate(a.angle),0==h&&0==u||c.context.translate(-h,-u);break;case"transform":Array.isArray(a)?c.context.transform.apply(c.context,a):"object"==l(a)&&c.context.transform(a.scaleX,a.skewX,a.skewY,a.scaleY,a.offsetX,a.offsetY);break;case"cursor":c.cursor=a}}};for(e in this.translate&&i(this.translate,"translate"),this.transform&&i(this.transform,"transform"),t)"constructor"!==e&&("string"==(n=l(t[e]))&&-1<t[e].indexOf("-gradient")?t[e]=new _(t[e]):"string"==n&&"shadow"==e&&(t[e]=new x(t[e])),i(t[e],e))}}},{key:"getBounds",value:function(t){if(this.bounds&&!t)return this.bounds;var e={};if("jmGraph"==this.type&&this.canvas)"function"==typeof this.canvas.width?e.right=this.canvas.width():this.width&&(e.right=this.width),"function"==typeof this.canvas.height?e.bottom=this.canvas.height():this.height&&(e.bottom=this.height);else if(this.points&&0<this.points.length)for(var n in this.points){n=this.points[n];(void 0===e.left||e.left>n.x)&&(e.left=n.x),(void 0===e.top||e.top>n.y)&&(e.top=n.y),(void 0===e.right||e.right<n.x)&&(e.right=n.x),(void 0===e.bottom||e.bottom<n.y)&&(e.bottom=n.y)}else!this.getLocation||(t=this.getLocation())&&(e.left=t.left,e.top=t.top,e.right=t.left+t.width,e.bottom=t.top+t.height);return e.left||(e.left=0),e.top||(e.top=0),e.right||(e.right=0),e.bottom||(e.bottom=0),e.width=e.right-e.left,e.height=e.bottom-e.top,this.bounds=e}},{key:"getLocation",value:function(){var t=this.location={left:0,top:0,width:0,height:0};t.position="function"==typeof this.position?this.position():m.clone(this.position),t.center=this.center&&"function"==typeof this.center?this.center():m.clone(this.center),t.start=this.start&&"function"==typeof this.start?this.start():m.clone(this.start),t.end=this.end&&"function"==typeof this.end?this.end():m.clone(this.end),t.radius=this.radius,t.width=this.width,t.height=this.height;var e=m.clone(this.style.margin,{});if(e.left=e.left||0,e.top=e.top||0,e.right=e.right||0,e.bottom=e.bottom||0,t.position?(t.left=t.position.x,t.top=t.position.y):(t.left=e.left,t.top=e.top),!this.parent)return t;e=this.parent.getBounds();return m.checkPercent(t.left)&&(t.left=m.percentToNumber(t.left)*e.width),m.checkPercent(t.top)&&(t.top=m.percentToNumber(t.top)*e.height),m.checkPercent(t.width)&&(t.width=m.percentToNumber(t.width)*e.width),m.checkPercent(t.height)&&(t.height=m.percentToNumber(t.height)*e.height),t.center&&(m.checkPercent(t.center.x)&&(t.center.x=m.percentToNumber(t.center.x)*e.width),m.checkPercent(t.center.y)&&(t.center.y=m.percentToNumber(t.center.y)*e.height)),t.radius&&m.checkPercent(t.radius)&&(t.radius=m.percentToNumber(t.radius)*Math.min(e.width,e.height)),t}},{key:"getRotation",value:function(t){var e;return(t=t||this.style.rotation)?(e=this.getBounds(),t.rotateX=t.point.x,m.checkPercent(t.rotateX)&&(t.rotateX=m.percentToNumber(t.rotateX)*e.width),t.rotateY=t.point.y,m.checkPercent(t.rotateY)&&(t.rotateY=m.percentToNumber(t.rotateY)*e.height)):(t=this.parent&&this.parent.getRotation?this.parent.getRotation():null)&&(e=this.getBounds(),t.rotateX-=e.left,t.rotateY-=e.top),t}},{key:"remove",value:function(){this.parent&&this.parent.children.remove(this)}},{key:"offset",value:function(t,e,n,i){n=!1!==n;var r=this.getLocation(!0),o=!1;if(r.position&&(r.left+=t,r.top+=e,this.position.x=r.left,this.position.y=r.top,o=!0),r.center&&(this.center.x=r.center.x+t,this.center.y=r.center.y+e,o=!0),r.start&&"object"==l(r.start)&&(this.start.x=r.start.x+t,this.start.y=r.start.y+e,o=!0),r.end&&"object"==l(r.end)&&(this.end.x=r.end.x+t,this.end.y=r.end.y+e,o=!0),0==o&&this.cpoints){var s=(this.cpoints,this.cpoints);if(s){for(var a=s.length,h=0;h<a;h++)s[h].x+=t,s[h].y+=e;o=!0}}if(0==o&&this.points){for(var u=this.points.length,c=0;c<u;c++)this.points[c].x+=t,this.points[c].y+=e;o=!0}this.emit("move",{offsetX:t,offsetY:e,trans:n,evt:i}),this.needUpdate=!0}},{key:"rotate",value:function(t,e){this.style.rotation={angle:t,point:e},this.needUpdate=!0}},{key:"getAbsoluteBounds",value:function(){var t=this.getBounds();if(this.parent&&this.parent.absoluteBounds){var e=this.parent.absoluteBounds||this.parent.getAbsoluteBounds();return{left:e.left+t.left,top:e.top+t.top,right:e.left+t.right,bottom:e.top+t.bottom,width:t.width,height:t.height}}return t}},{key:"beginDraw",value:function(){this.getLocation(!0),this.context.beginPath()}},{key:"endDraw",value:function(){this.style.close&&this.context.closePath(),this.style.fill&&this.context.fill(),!this.style.stroke&&this.style.fill||this.context.stroke(),this.needUpdate=!1}},{key:"draw",value:function(){if(this.points&&0<this.points.length){var t=(this.parent&&this.parent.absoluteBounds?this.parent:this).absoluteBounds;this.context.moveTo(this.points[0].x+t.left,this.points[0].y+t.top);for(var e=this.points.length,n=1;n<e;n++){var i=this.points[n];i.m?this.context.moveTo(i.x+t.left,i.y+t.top):this.context.lineTo(i.x+t.left,i.y+t.top)}}}},{key:"paint",value:function(t){!1!==t&&!1!==this.visible&&(this.initPoints&&this.initPoints(),this.bounds=null,this.absoluteBounds=this.getAbsoluteBounds(),t=!0,!this.is("jmGraph")&&this.graph&&(this.absoluteBounds.left>=this.graph.width||this.absoluteBounds.top>=this.graph.height||this.absoluteBounds.right<=0||this.absoluteBounds.bottom<=0)&&(t=!1),this.context.save(),this.emit("beginDraw",this),this.setStyle(),t&&this.beginDraw&&this.beginDraw(),t&&this.draw&&this.draw(),t&&this.endDraw&&this.endDraw(),this.children&&this.children.each(function(t,e){e&&e.paint&&e.paint()}),this.emit("endDraw",this),this.context.restore(),this.needUpdate=!1)}},{key:"getEvent",value:function(t){return this.__events?this.__events[t]:null}},{key:"bind",value:function(t,e){if(t&&-1<t.indexOf(" ")){var n,i=p(t=t.split(" "));try{for(i.s();!(n=i.n()).done;){var r=n.value;r&&this.bind(r,e)}}catch(t){i.e(t)}finally{i.f()}}else{t=this.getEvent(t)||function(t,e){return this.__events||(this.__events={}),this.__events[t]=e}.call(this,t,new y);t.contain(e)||t.add(e)}}},{key:"unbind",value:function(t,e){if(t&&-1<t.indexOf(" ")){var n,i=p(t=t.split(" "));try{for(i.s();!(n=i.n()).done;){var r=n.value;r&&this.unbind(r,e)}}catch(t){i.e(t)}finally{i.f()}}else{t=this.getEvent(t);t&&(e?t.remove(e):t.clear())}}},{key:"emit",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.runEventHandle(e[0],e.slice(1)),this}},{key:"runEventHandle",value:function(t,n){var i,t=this.getEvent(t);return t&&(i=this,Array.isArray(n)||(n=[n]),t.each(function(t,e){!1===e.apply(i,n)&&(n.cancel=!0)})),n.cancel}},{key:"checkPoint",value:function(t,e){if("jmGraph"==this.type){var n=this.getPosition(),i=n.left+this.width,r=n.top+this.height;return t.pageX>i||t.pageX<n.left?!1:!(t.pageY>r||t.pageY<n.top)}var r=this.getBounds(),n=this.getRotation(),o=this.points;if(o&&o.length||((o=[]).push({x:r.left,y:r.top}),o.push({x:r.right,y:r.top}),o.push({x:r.right,y:r.bottom}),o.push({x:r.left,y:r.bottom}),o.push({x:r.left,y:r.top})),e=Number(e||this.style.touchPadding||this.style.lineWidth||1),o&&o.length){if(n&&0!=n.angle&&(o=m.clone(o,!0),o=m.rotatePoints(o,{x:n.rotateX+r.left,y:n.rotateY+r.top},n.angle)),2<o.length&&(!this.style.fill||this.style.stroke)){for(var s=0,a=o.length,h=s+1;h<=a;h=++s+1)if(h==a){if(this.style.close)if(m.pointInPolygon(t,[o[s],o[0]],e))return!0}else if(m.pointInPolygon(t,[o[s],o[h]],e))return!0;if(!this.style.fill)return!1}return m.pointInPolygon(t,o,e)}return!(t.x>r.right||t.x<r.left)&&!(t.y>r.bottom||t.y<r.top)}},{key:"raiseEvent",value:function(n,i){if(!1!==this.visible){var t;i.position||(t=this.graph,e=i.srcElement||i.target,t=m.getEventPosition(i,t.scaleSize),i={position:t,button:0==i.button||t.isTouch?1:i.button,keyCode:i.keyCode||i.charCode||i.which,ctrlKey:i.ctrlKey,cancel:!1,event:i,srcElement:e}),i.path=i.path||[];var r=!1;if(this.children&&this.children.each(function(t,e){if(!0!==i.cancel&&(r=!1===e.raiseEvent(n,i)||r))return!1},!0),r)return!1;var e=(this.parent&&this.parent.absoluteBounds?this.parent:this).absoluteBounds;if(!e)return!1;i.position.x=i.position.offsetX-e.left,i.position.y=i.position.offsetY-e.top;e=!1!==this.interactive&&this.checkPoint(i.position);return e?(i.target||(i.target=this),this.runEventAndPopEvent(n,i),this.focused||"mousemove"!==n&&"touchmove"!==n||(this.focused=!0,this.raiseEvent("mousemove"===n?"mouseover":"touchover",i))):!1===this.interactive||e||!this.focused||"mousemove"!==n&&"touchmove"!==n||(this.focused=!1,this.runEventHandle("mousemove"===n?"mouseleave":"touchleave",i)),!1===i.cancel}}},{key:"runEventAndPopEvent",value:function(t,e){!0!==e.cancel&&(e.path.push(this),this.runEventHandle(t,e))}},{key:"clearEvents",value:function(t){t=this.getEvent(t);t&&t.clear}},{key:"findParent",value:function(t){if("string"==typeof t){if(this.type==t)return this}else if(this.is(t))return this;return this.parent?this.parent.findParent(t):null}},{key:"canMove",value:function(t,e){var s;return this.__mvMonitor||(this.__mvMonitor={},this.__mvMonitor.mouseDown=!1,this.__mvMonitor.curposition={x:0,y:0},(s=this).__mvMonitor.mv=function(t){var e=s;if(e.__mvMonitor.mouseDown){e.parent.bounds=null;var n,i=e.parent.getAbsoluteBounds(),r=t.position.offsetX-e.__mvMonitor.curposition.x,o=t.position.offsetY-e.__mvMonitor.curposition.y;return e.lockSide&&(n=e.bounds||e.getAbsoluteBounds(),(n=m.checkOutSide(i,n,{x:r,y:o})).left<0?e.lockSide.left&&(r-=n.left):0<n.right&&e.lockSide.right&&(r-=n.right),n.top<0?e.lockSide.top&&(o-=n.top):0<n.bottom&&e.lockSide.bottom&&(o-=n.bottom)),(r||o)&&(e.offset(r,o,!0,t),e.__mvMonitor.curposition.x=t.position.offsetX,e.__mvMonitor.curposition.y=t.position.offsetY),!1}},this.__mvMonitor.mu=function(t){var e=s;e.__mvMonitor.mouseDown&&(e.__mvMonitor.mouseDown=!1,e.emit("moveend",{position:e.__mvMonitor.curposition}))},this.__mvMonitor.ml=function(){var t=s;if(t.__mvMonitor.mouseDown)return t.__mvMonitor.mouseDown=!1,t.emit("moveend",{position:t.__mvMonitor.curposition}),!1},this.__mvMonitor.md=function(t){if(!this.__mvMonitor.mouseDown)return 0==t.button||1==t.button?(this.__mvMonitor.mouseDown=!0,this.__mvMonitor.curposition.x=t.position.offsetX,this.__mvMonitor.curposition.y=t.position.offsetY,this.emit("movestart",{position:this.__mvMonitor.curposition}),!(t.cancel=!0)):void 0}),e=e||this.graph,!1!==t?(e.bind("mousemove",this.__mvMonitor.mv),e.bind("mouseup",this.__mvMonitor.mu),e.bind("mouseleave",this.__mvMonitor.ml),this.bind("mousedown",this.__mvMonitor.md),e.bind("touchmove",this.__mvMonitor.mv),e.bind("touchend",this.__mvMonitor.mu),this.bind("touchstart",this.__mvMonitor.md)):(e.unbind("mousemove",this.__mvMonitor.mv),e.unbind("mouseup",this.__mvMonitor.mu),e.unbind("mouseleave",this.__mvMonitor.ml),this.unbind("mousedown",this.__mvMonitor.md),e.unbind("touchmove",this.__mvMonitor.mv),e.unbind("touchend",this.__mvMonitor.mu),this.unbind("touchstart",this.__mvMonitor.md)),this}}]),r}(),N=function(){c(i,A);var n=v(i);function i(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"jmPath";return h(this,i),(e=n.call(this,t,e)).points=t&&t.points?t.points:[],e}return u(i,[{key:"points",get:function(){return this.__pro("points")},set:function(t){return this.needUpdate=!0,this.__pro("points",t)}}]),i}(),M=function(){c(o,A);var r=v(o);function o(t,e,n){var i;return h(this,o),"function"==typeof e&&(n=e,e={}),(e=e||{}).mode=e.mode||"2d",e.interactive=!0,(i=r.call(this,e,"jmGraph")).option=e||{},i.devicePixelRatio=1,i.util=i.utils=m,"undefined"!=typeof wx&&wx.canIUse&&wx.canIUse("canvas")?("string"==typeof t&&(t=wx.createSelectorQuery().select("#"+t)),i.isWXMiniApp=!0):("string"==typeof t&&"undefined"!=typeof document?t=document.getElementById(t):t.length&&(t=t[0]),"CANVAS"!=t.tagName?(i.container=t,e=document.createElement("canvas"),t.appendChild(e),e.width=t.offsetWidth||t.clientWidth,e.height=t.offsetHeight||t.clientHeight,t=e):i.container=t.parentElement),i.canvas=t,i.context=t.getContext("2d"),i.__init(n),i}return u(o,[{key:"__init",value:function(t){this.shapes=Object.assign({path:N},this.option.shapes),this.on("beginDraw",function(){this.context.translate(.5,.5)}),this.on("endDraw",function(){this.context.translate(-.5,-.5)});var e="undefined"!=typeof window&&1<window.devicePixelRatio?window.devicePixelRatio:1;this.isWXMiniApp&&(e=wx.getSystemInfoSync().pixelRatio||1),this.devicePixelRatio=e,this.dprScaleSize=1<this.devicePixelRatio?this.devicePixelRatio:2,0<this.option.width&&(this.width=this.option.width),0<this.option.height&&(this.height=this.option.height),this.resize(),this.eventHandler=new w(this,this.canvas.canvas||this.canvas),this.option.autoRefresh&&this.autoRefresh(),t&&t(this)}},{key:"resize",value:function(t,e){this.canvas&&(this.__normalSize=this.__normalSize||{width:0,height:0},t=t||this.__normalSize.width||this.width,e=e||this.__normalSize.height||this.height,t&&(this.__normalSize.width=t),e&&(this.__normalSize.height=e),this.css("width",t+"px"),this.css("height",e+"px"),this.canvas.height=e*this.dprScaleSize,this.canvas.width=t*this.dprScaleSize,this.context.scale(this.dprScaleSize,this.dprScaleSize))}},{key:"pointToPixes",value:function(t){return t=this.dprScaleSize&&1!==this.dprScaleSize?Object.assign({},t,{x:t.x/this.dprScaleSize,y:t.y/this.dprScaleSize}):t}},{key:"width",get:function(){return this.__normalSize&&this.__normalSize.width?this.__normalSize.width:this.canvas?this.canvas.width:0},set:function(t){return this.needUpdate=!0,this.canvas&&this.resize(t),t}},{key:"height",get:function(){return this.__normalSize&&this.__normalSize.height?this.__normalSize.height:this.canvas?this.canvas.height:0},set:function(t){return this.needUpdate=!0,this.canvas&&this.resize(0,t),t}},{key:"getPosition",value:function(){var t=m.getElementPosition(this.canvas.canvas||this.canvas);return t.width=this.width,t.height=this.height,t.right=t.left+t.width,t.bottom=t.top+t.height,t}},{key:"registerShape",value:function(t,e){this.shapes[t]=e}},{key:"createShape",value:function(t,e){if(t="string"==typeof t?this.shapes[t]:t)return(e=e||{}).graph=this,new t(e)}},{key:"createShadow",value:function(t,e,n,i){return new x(t,e,n,i)}},{key:"createLinearGradient",value:function(t,e,n,i){return new _({type:"linear",x1:t,y1:e,x2:n,y2:i})}},{key:"createRadialGradient",value:function(t,e,n,i,r,o){return new _({type:"radial",x1:t,y1:e,r1:n,x2:i,y2:r,r2:o})}},{key:"refresh",value:function(){this.redraw()}},{key:"redraw",value:function(t,e){this.clear(t||this.width,e||this.height),this.paint()}},{key:"clear",value:function(t,e){t&&e||(t=this.width,e=this.height),this.style&&this.style.fill?this.points=[{x:0,y:0},{x:t,y:0},{x:t,y:e},{x:0,y:e}]:this.context.clearRect&&this.context.clearRect(0,0,t,e)}},{key:"css",value:function(t,e){if(this.canvas&&this.canvas.style)return void 0!==e&&(this.canvas.style[t]=e),this.canvas.style[t]}},{key:"createPath",value:function(t,e){return this.createShape("path",{points:t,style:e})}},{key:"createLine",value:function(t,e,n){return this.createShape("line",{start:t,end:e,style:n})}},{key:"zoomOut",value:function(){this.scale(.9,.9)}},{key:"zoomIn",value:function(){this.scale(1.1,1.1)}},{key:"zoomActual",value:function(){this.scaleSize?this.scale(1/this.scaleSize.x,1/this.scaleSize.y):this.scale(1,1)}},{key:"scale",value:function(t,e){this.normalSize||(this.normalSize={width:this.canvas.width,height:this.canvas.height}),this.context.scale(t,e),this.scaleSize?this.scaleSize={x:t*this.scaleSize.x,y:e*this.scaleSize.y}:this.scaleSize={x:t,y:e},this.refresh()}},{key:"toDataURL",value:function(){return this.canvas.toDataURL?this.canvas.toDataURL():""}},{key:"autoRefresh",value:function(e){if(!this.___isAutoRefreshing){var n=this;return this.___isAutoRefreshing=!0,n.__requestAnimationFrameFunHandler&&m.cancelAnimationFrame(n.__requestAnimationFrameFunHandler,n.canvas),n.__requestAnimationFrameFunHandler=m.requestAnimationFrame(function t(){n.destroyed?n.___isAutoRefreshing=!1:(n.needUpdate&&n.redraw(),n.emit("update"),n.__requestAnimationFrameFunHandler&&m.cancelAnimationFrame(n.__requestAnimationFrameFunHandler,n.canvas),n.__requestAnimationFrameFunHandler=m.requestAnimationFrame(t,n.canvas),e&&e())},n.canvas),this}}},{key:"destroy",value:function(){this.eventHandler.destroy(),this.destroyed=!0}}],[{key:"create",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return a(o,e)}}]),o}();t.default=M,t.jmControl=A,t.jmEvents=w,t.jmGradient=_,t.jmGraph=M,t.jmList=y,t.jmPath=N,t.jmProperty=n,t.jmShadow=x,t.jmUtils=m,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=jmgraph.core.min.js.map
|