@fc-plot/ts-graph 0.23.3 → 0.24.1
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/BundleReport.html +2 -2
- package/dist/index.js +1 -1
- package/examples/index.js +11 -6
- package/package.json +1 -1
- package/src/index.ts +90 -21
- package/src/interface.ts +4 -0
- package/src/line.ts +13 -8
- package/src/tooltip.ts +9 -2
- package/src/utils.ts +4 -1
- package/src/xAxis.ts +11 -3
- package/src/yAxis.ts +1 -37
- package/src/yAxis2.ts +154 -0
package/dist/BundleReport.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@fc-plot/ts-graph [
|
|
6
|
+
<title>@fc-plot/ts-graph [29 Nov 2023 at 14:38]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
<body>
|
|
47
47
|
<div id="app"></div>
|
|
48
48
|
<script>
|
|
49
|
-
window.chartData = [{"label":"index.js","isAsset":true,"statSize":
|
|
49
|
+
window.chartData = [{"label":"index.js","isAsset":true,"statSize":123426,"parsedSize":54667,"gzipSize":15534,"groups":[{"label":"node_modules","path":"./node_modules","statSize":18573,"groups":[{"label":"@babel/runtime/helpers","path":"./node_modules/@babel/runtime/helpers","statSize":3683,"groups":[{"id":2,"label":"classCallCheck.js","path":"./node_modules/@babel/runtime/helpers/classCallCheck.js","statSize":274,"parsedSize":169,"gzipSize":140},{"id":3,"label":"createClass.js","path":"./node_modules/@babel/runtime/helpers/createClass.js","statSize":752,"parsedSize":349,"gzipSize":230},{"id":4,"label":"defineProperty.js","path":"./node_modules/@babel/runtime/helpers/defineProperty.js","statSize":367,"parsedSize":195,"gzipSize":154},{"id":5,"label":"toConsumableArray.js","path":"./node_modules/@babel/runtime/helpers/toConsumableArray.js","statSize":521,"parsedSize":154,"gzipSize":128},{"id":6,"label":"arrayLikeToArray.js","path":"./node_modules/@babel/runtime/helpers/arrayLikeToArray.js","statSize":312,"parsedSize":181,"gzipSize":151},{"id":8,"label":"arrayWithoutHoles.js","path":"./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","statSize":266,"parsedSize":134,"gzipSize":117},{"id":9,"label":"iterableToArray.js","path":"./node_modules/@babel/runtime/helpers/iterableToArray.js","statSize":274,"parsedSize":189,"gzipSize":153},{"id":10,"label":"unsupportedIterableToArray.js","path":"./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js","statSize":609,"parsedSize":374,"gzipSize":270},{"id":11,"label":"nonIterableSpread.js","path":"./node_modules/@babel/runtime/helpers/nonIterableSpread.js","statSize":308,"parsedSize":244,"gzipSize":193}],"parsedSize":1989,"gzipSize":720},{"label":"events","path":"./node_modules/events","statSize":14890,"groups":[{"id":7,"label":"events.js","path":"./node_modules/events/events.js","statSize":14890,"parsedSize":6026,"gzipSize":2003}],"parsedSize":6026,"gzipSize":2003}],"parsedSize":8015,"gzipSize":2554},{"label":"assets","path":"./assets","statSize":1972,"groups":[{"id":12,"label":"style.less","path":"./assets/style.less","statSize":1972,"parsedSize":17,"gzipSize":37}],"parsedSize":17,"gzipSize":37},{"label":"src","path":"./src","statSize":102881,"groups":[{"id":13,"label":"index.ts + 12 modules (concatenated)","path":"./src/index.ts + 12 modules (concatenated)","statSize":102881,"parsedSize":45237,"gzipSize":13037,"concatenated":true,"groups":[{"label":"src","path":"./src/index.ts + 12 modules (concatenated)/src","statSize":94799,"groups":[{"id":null,"label":"index.ts","path":"./src/index.ts + 12 modules (concatenated)/src/index.ts","statSize":32364,"parsedSize":14230,"gzipSize":4101,"inaccurateSizes":true},{"id":null,"label":"utils.ts","path":"./src/index.ts + 12 modules (concatenated)/src/utils.ts","statSize":5536,"parsedSize":2434,"gzipSize":701,"inaccurateSizes":true},{"id":null,"label":"xAxis.ts","path":"./src/index.ts + 12 modules (concatenated)/src/xAxis.ts","statSize":4825,"parsedSize":2121,"gzipSize":611,"inaccurateSizes":true},{"id":null,"label":"yAxis.ts","path":"./src/index.ts + 12 modules (concatenated)/src/yAxis.ts","statSize":7228,"parsedSize":3178,"gzipSize":915,"inaccurateSizes":true},{"id":null,"label":"yAxis2.ts","path":"./src/index.ts + 12 modules (concatenated)/src/yAxis2.ts","statSize":5129,"parsedSize":2255,"gzipSize":649,"inaccurateSizes":true},{"id":null,"label":"tooltip.ts","path":"./src/index.ts + 12 modules (concatenated)/src/tooltip.ts","statSize":15938,"parsedSize":7007,"gzipSize":2019,"inaccurateSizes":true},{"id":null,"label":"line.ts","path":"./src/index.ts + 12 modules (concatenated)/src/line.ts","statSize":4661,"parsedSize":2049,"gzipSize":590,"inaccurateSizes":true},{"id":null,"label":"bar.ts","path":"./src/index.ts + 12 modules (concatenated)/src/bar.ts","statSize":2181,"parsedSize":958,"gzipSize":276,"inaccurateSizes":true},{"id":null,"label":"zoom.ts","path":"./src/index.ts + 12 modules (concatenated)/src/zoom.ts","statSize":4348,"parsedSize":1911,"gzipSize":550,"inaccurateSizes":true},{"id":null,"label":"legend.ts","path":"./src/index.ts + 12 modules (concatenated)/src/legend.ts","statSize":3739,"parsedSize":1644,"gzipSize":473,"inaccurateSizes":true},{"id":null,"label":"shapes.ts","path":"./src/index.ts + 12 modules (concatenated)/src/shapes.ts","statSize":3100,"parsedSize":1363,"gzipSize":392,"inaccurateSizes":true},{"id":null,"label":"getNearestPoints.ts","path":"./src/index.ts + 12 modules (concatenated)/src/getNearestPoints.ts","statSize":5750,"parsedSize":2528,"gzipSize":728,"inaccurateSizes":true}],"parsedSize":41683,"gzipSize":12012,"inaccurateSizes":true},{"label":"node_modules/resize-detector/esm","path":"./src/index.ts + 12 modules (concatenated)/node_modules/resize-detector/esm","statSize":8042,"groups":[{"id":null,"label":"index.js","path":"./src/index.ts + 12 modules (concatenated)/node_modules/resize-detector/esm/index.js","statSize":8042,"parsedSize":3536,"gzipSize":1019,"inaccurateSizes":true}],"parsedSize":3536,"gzipSize":1019,"inaccurateSizes":true}]}],"parsedSize":45237,"gzipSize":13037}]}];
|
|
50
50
|
window.defaultSizes = "parsed";
|
|
51
51
|
</script>
|
|
52
52
|
</body>
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("d3"),require("lodash"));else if("function"==typeof define&&define.amd)define([,],t);else{var i="object"==typeof exports?t(require("d3"),require("lodash")):t(e.d3,e._);for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(window,(function(e,t){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=13)}([function(t,i){t.exports=e},function(e,i){e.exports=t},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){function i(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,i){var n=i(8),o=i(9),r=i(10),s=i(11);e.exports=function(e){return n(e)||o(e)||r(e)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,i){"use strict";var n,o="object"==typeof Reflect?Reflect:null,r=o&&"function"==typeof o.apply?o.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};n=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,e.exports.once=function(e,t){return new Promise((function(i,n){function o(i){e.removeListener(t,r),n(i)}function r(){"function"==typeof e.removeListener&&e.removeListener("error",o),i([].slice.call(arguments))}m(e,t,r,{once:!0}),"error"!==t&&function(e,t,i){"function"==typeof e.on&&m(e,"error",t,i)}(e,o,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function u(e,t,i,n){var o,r,s,a;if(l(i),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),r=e._events),s=r[t]),void 0===s)s=r[t]=i,++e._eventsCount;else if("function"==typeof s?s=r[t]=n?[i,s]:[s,i]:n?s.unshift(i):s.push(i),(o=h(e))>0&&s.length>o&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return e}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},o=d.bind(n);return o.listener=i,n.wrapFn=o,o}function p(e,t,i){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(o):y(o,o.length)}function v(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function y(e,t){for(var i=new Array(t),n=0;n<t;++n)i[n]=e[n];return i}function m(e,t,i,n){if("function"==typeof e.on)n.once?e.once(t,i):e.on(t,i);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(r){n.once&&e.removeEventListener(t,o),i(r)}))}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return h(this)},a.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)r(c,this,t);else{var l=c.length,h=y(c,l);for(i=0;i<l;++i)r(h[i],this,t)}return!0},a.prototype.addListener=function(e,t){return u(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return u(this,e,t,!0)},a.prototype.once=function(e,t){return l(t),this.on(e,f(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,f(this,e,t)),this},a.prototype.removeListener=function(e,t){var i,n,o,r,s;if(l(t),void 0===(n=this._events))return this;if(void 0===(i=n[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(o=-1,r=i.length-1;r>=0;r--)if(i[r]===t||i[r].listener===t){s=i[r].listener,o=r;break}if(o<0)return this;0===o?i.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(i,o),1===i.length&&(n[e]=i[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,i,n;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var o,r=Object.keys(i);for(n=0;n<r.length;++n)"removeListener"!==(o=r[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},a.prototype.listenerCount=v,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,i){var n=i(6);e.exports=function(e){if(Array.isArray(e))return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,i){var n=i(6);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,i){},function(e,t,i){"use strict";i.r(t),i.d(t,"default",(function(){return ee}));var n=i(5),o=i.n(n),r=i(4),s=i.n(r),a=i(2),c=i.n(a),l=i(3),h=i.n(l),u=i(0),d=i(1);let f=null;let p=null;function v(e,t={}){let i=document.createElement(e);return Object.keys(t).forEach(e=>{i[e]=t[e]}),i}function y(e,t,i){return(window.getComputedStyle(e,i||null)||{display:"none"})[t]}function m(e){if(!document.documentElement.contains(e))return{detached:!0,rendered:!1};let t=e;for(;t!==document;){if("none"===y(t,"display"))return{detached:!1,rendered:!1};t=t.parentNode}return{detached:!1,rendered:!0}}let g=0,b=null;function x(e,t){if(e.__resize_mutation_handler__||(e.__resize_mutation_handler__=_.bind(e)),!e.__resize_listeners__)if(e.__resize_listeners__=[],window.ResizeObserver){let{offsetWidth:t,offsetHeight:i}=e,n=new ResizeObserver(()=>{(e.__resize_observer_triggered__||(e.__resize_observer_triggered__=!0,e.offsetWidth!==t||e.offsetHeight!==i))&&w(e)}),{detached:o,rendered:r}=m(e);e.__resize_observer_triggered__=!1===o&&!1===r,e.__resize_observer__=n,n.observe(e)}else if(e.attachEvent&&e.addEventListener)e.__resize_legacy_resize_handler__=function(){w(e)},e.attachEvent("onresize",e.__resize_legacy_resize_handler__),document.addEventListener("DOMSubtreeModified",e.__resize_mutation_handler__);else if(g||(b=function(e){var t=document.createElement("style");return t.type="text/css",t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e)),(document.querySelector("head")||document.body).appendChild(t),t}('.resize-triggers{visibility:hidden;opacity:0;pointer-events:none}.resize-contract-trigger,.resize-contract-trigger:before,.resize-expand-trigger,.resize-triggers{content:"";position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden}.resize-contract-trigger,.resize-expand-trigger{background:#eee;overflow:auto}.resize-contract-trigger:before{width:200%;height:200%}')),function(e){let t=y(e,"position");t&&"static"!==t||(e.style.position="relative");e.__resize_old_position__=t,e.__resize_last__={};let i=v("div",{className:"resize-triggers"}),n=v("div",{className:"resize-expand-trigger"}),o=v("div"),r=v("div",{className:"resize-contract-trigger"});n.appendChild(o),i.appendChild(n),i.appendChild(r),e.appendChild(i),e.__resize_triggers__={triggers:i,expand:n,expandChild:o,contract:r},O(e),e.addEventListener("scroll",k,!0),e.__resize_last__={width:e.offsetWidth,height:e.offsetHeight}}(e),e.__resize_rendered__=m(e).rendered,window.MutationObserver){let t=new MutationObserver(e.__resize_mutation_handler__);t.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0}),e.__resize_mutation_observer__=t}e.__resize_listeners__.push(t),g++}function _(){let{rendered:e,detached:t}=m(this);e!==this.__resize_rendered__&&(!t&&this.__resize_triggers__&&(O(this),this.addEventListener("scroll",k,!0)),this.__resize_rendered__=e,w(this))}function k(){var e,t;O(this),this.__resize_raf__&&(e=this.__resize_raf__,p||(p=(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||function(e){clearTimeout(e)}).bind(window)),p(e)),this.__resize_raf__=(t=()=>{let e=function(e){let{width:t,height:i}=e.__resize_last__,{offsetWidth:n,offsetHeight:o}=e;return n!==t||o!==i?{width:n,height:o}:null}(this);e&&(this.__resize_last__=e,w(this))},f||(f=(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e){return setTimeout(e,16)}).bind(window)),f(t))}function w(e){e&&e.__resize_listeners__&&e.__resize_listeners__.forEach(t=>{t.call(e,e)})}function O(e){let{expand:t,expandChild:i,contract:n}=e.__resize_triggers__,{scrollWidth:o,scrollHeight:r}=n,{offsetWidth:s,offsetHeight:a,scrollWidth:c,scrollHeight:l}=t;n.scrollLeft=o,n.scrollTop=r,i.style.width=s+1+"px",i.style.height=a+1+"px",t.scrollLeft=c,t.scrollTop=l}var C=i(7),S=i.n(C);function L(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function E(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?L(Object(i),!0).forEach((function(t){s()(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):L(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function j(e,t){return"X"===t?1e3*e:e}function z(e){var t,i=e.series,n=e.x,o=e.xkey,r=e.ykey,s=e.ykey2,a=e.oykey,c=e.timestamp,l=e.fillNull,h=(t=function(e,t){return(i=j(e[o],c))<(n=t)?-1:i>n?1:i>=n?0:NaN;var i,n},{left:function(e,i,n,o){for(null==n&&(n=0),null==o&&(o=e.length);n<o;){var r=n+o>>>1;t(e[r],i)<0?n=r+1:o=r}return n},right:function(e,i,n,o){for(null==n&&(n=0),null==o&&(o=e.length);n<o;){var r=n+o>>>1;t(e[r],i)>0?o=r:n=r+1}return n}}).left,u=new Date(n).getTime(),f=[];return"[object Array]"!==Object.prototype.toString.call(i)?[]:(i.forEach((function(e,t){if(!function(e,t){return Object(d.some)(e.data,(function(e){return t&&t in e}))}(e,s)&&!1!==e.visible){var i=e.name,p=e.color,v=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&"[object Function]"===Object.prototype.toString.call(t)&&t(n)&&(i[n]=e[n]);return i}(e,(function(e){return"data"!==e})),y=e.data,m=void 0===y?[]:y;if("[object Array]"===Object.prototype.toString.call(m)&&0!==(m=m.filter((function(e){return"number"==typeof e[r]||"number"==typeof l}))).length){var g,b=h(m,n),x=m[b-1],_=m[b];if(x&&_){var k=j(x[o],c),w=j(_[o],c),O=x[r],C=_[r];null===O&&void 0!==l&&(O=l),null===C&&void 0!==l&&(C=l),g=u-k<w-u?E(E({},x),{},{name:i,color:p,timestamp:k,value:O,origin:x[a],serieIndex:t,serieOptions:v}):E(E({},_),{},{name:i,color:p,timestamp:w,value:C,origin:_[a],serieIndex:t,serieOptions:v}),f.push(g)}else if(x){var S=j(x[o],c),L=x[r];null===L&&void 0!==l&&(L=l),g=E(E({},x),{},{name:i,color:p,timestamp:S,value:L,origin:x[a],serieIndex:t,serieOptions:v}),f.push(g)}else if(_){var z=j(_[o],c),A=_[r];null===A&&void 0!==l&&(A=l),g=E(E({},_),{},{name:i,color:p,timestamp:z,value:A,origin:_[a],serieIndex:t,serieOptions:v}),f.push(g)}}}})),f)}function A(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function M(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?A(Object(i),!0).forEach((function(t){s()(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):A(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function P(e,t){var i=e.length;return t<i?e[t]:P(e,t-i)}function T(e,t){return"X"===t?1e3*e:e}function N(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=e.getBoundingClientRect(),o=t.touches[i].clientX,r=t.touches[i].clientY,s=o-n.left,a=r-n.top;return{offsetX:s,offsetY:a,clientX:o,clientY:r}}function I(e){var t=String(e);if(e>=1e3){t=u.format(".5s")(e);var i=/[kMGTPEZY]$/;if(i.test(t)){var n=t[t.length-1];t=t.replace(i,""),t=parseFloat(t)+n}}return t}function D(e,t){var i=e;return null!==e&&"function"==typeof t&&(i=t(e)),i}function B(e,t,i,n){var o=t.xkey,r=t.ykey,s=t.ykey2,a=t.oykey,c=t.timestamp,l=t.series,h=t.fillNull,u=e.offsetX||e.layerX,d=e.offsetY||e.layerY,f=i.invert(u);return{x:f,y:n.invert(d),nearestPoints:z({x:f,xkey:o,ykey:r,ykey2:s,oykey:a,timestamp:c,series:l,fillNull:h})}}var W=function(){function e(t,i,n){c()(this,e),this.options=void 0,this.ctx=void 0,this.yAxis=void 0,this.options=t,this.ctx=i,this.yAxis=n}return h()(e,[{key:"init",value:function(){var e=this.options,t=e.chart.width,i=e.timestamp,n=e.xmin,o=e.xmax,r=e.xAxis,s=u.scaleTime().range([r.visible?this.yAxis.tickMaxWidth:0,t]);return s.domain([T(n,i)-(n===o?1e3:0),T(o,i)+(n===o?1e3:0)]),s}},{key:"draw",value:function(e){var t=this.ctx,i=this.options,n=i.chart,o=i.xAxis,r=i.time,s=e.ticks(Math.floor(n.width/90));o.ticks&&(s=o.ticks);var a=n.height-o.tickpadding-o.labels.fontSize;t.beginPath(),s.forEach((function(i){var n=e(i);n&&(t.moveTo(n,a),t.lineTo(n,a-o.tickLength))})),t.lineWidth=1,t.strokeStyle=o.tickColor,t.stroke(),t.closePath(),t.beginPath(),t.moveTo(0,a-o.tickLength),t.lineTo(n.width,a-o.tickLength),t.lineWidth=1,t.strokeStyle=o.lineColor,t.stroke(),t.closePath(),t.textAlign="center",t.textBaseline="bottom",t.fillStyle=o.labels.color,t.font="".concat(o.labels.fontSize,"px Palantino"),s.forEach((function(i,a){var c="%H:%M";0!==i.getSeconds()&&(c="%H:%M:%S"),0===i.getHours()&&0===i.getMinutes()&&0===i.getSeconds()&&(c="%m-%d"),o.labels.timeFormat&&(c=o.labels.timeFormat);var l=i;if(r&&void 0!==r.timezoneOffset){var h=i.getTimezoneOffset(),d=i.getTime()+60*h*1e3+60*r.timezoneOffset*1e3;l=new Date(d)}if(o.ticks&&o.ticks.length>1){var f=e(i);0===a?f+=c.length*o.labels.fontSize/4+1:a===s.length-1&&(f-=c.length*o.labels.fontSize/4-1),t.fillText(u.timeFormat(c)(l),f,n.height)}else e(i)&&t.fillText(u.timeFormat(c)(l),e(i),n.height)}))}},{key:"drawPlotLines",value:function(e){var t=this.ctx,i=this.options,n=i.chart,o=i.xAxis,r=i.xAxis.plotLines,s=n.height-o.tickpadding-o.labels.fontSize;Array.isArray(r)&&r.forEach((function(n){var r=e("X"===i.timestamp?1e3*n.value:n.value);t.setLineDash([5,3]),t.beginPath(),t.moveTo(r,0),t.lineTo(r,s-o.tickLength),t.strokeStyle=n.color,t.stroke(),t.setLineDash([])}))}}]),e}(),X=function(){function e(t,i){c()(this,e),this.options=void 0,this.ctx=void 0,this.tickLength=void 0,this.ticks=void 0,this.tickMaxWidth=void 0,this.options=t;var n=t.yAxis;i.font="".concat(n.labels.fontSize,"px Palantino"),this.ctx=i,this.tickLength=Math.floor(t.chart.height/50),this.ticks=[],this.tickMaxWidth=0}return h()(e,[{key:"init",value:function(){var e=this.options,t=e.chart,i=e.xAxis,n=e.yAxis,o=u.scaleLinear();n.scale&&"log"===n.scale.type&&(o=u.scaleLog().base(n.scale.log||10));var r=o.range([t.height-(i.labels.fontSize+i.tickpadding+i.tickLength),10]);return this.setDomain(r,this.options),r}},{key:"getRealData",value:function(e){var t=this.options,i=t.yAxis.plotLines,n=t.ykey,o=t.fillNull;return Array.isArray(e)?(Array.isArray(i)&&i.forEach((function(t){"number"==typeof t.value&&e.push(s()({},n,t.value))})),"number"==typeof o&&e.push(s()({},n,o)),e):[]}},{key:"getPlotLinesMaxAbs",value:function(){var e,t=this.options.yAxis.plotLines;return Array.isArray(t)&&t.forEach((function(t){(!e||Math.abs(e)<Math.abs(t.value))&&(e=t.value)})),e}},{key:"setDomain",value:function(e,t){var i=t.ymin,n=t.ymax,o=this.options.yAxis,r=this.tickLength;if(i===n&&0!==i){var s=(n-i)/(this.tickLength-1),a=s/2||n||1;r=0===s?1:this.tickLength,i-=a,n+=a}if(i>n){var c=i;i=n,n=c}if(o.plotLinesFixed||i===n){var l=this.getPlotLinesMaxAbs();l&&(l<i&&(i=l),l>n&&(n=l))}var h=[];if("number"==typeof o.min||"number"==typeof o.max){var f="number"==typeof o.min?o.min:i,p="number"==typeof o.max?o.max:n;if(e.domain([f,p]),"number"==typeof o.min&&o.min>p)h=[o.min];else if("number"==typeof o.max&&o.max<f)h=[o.max];else{var v=u.tickStep(f,p,r);h=Object(d.map)(u.range(f,p,v),(function(e){return Object(d.floor)(e,2)}))}}else e.domain([i,n]),e.nice(r),h=e.ticks(r);var y=function(e,t,i){var n=e.map((function(e){var n;return n="function"==typeof i?i(e):I(e),t.measureText(n).width}));return Object(d.max)(n)}(h,this.ctx,o.tickValueFormatter)+5;this.ticks=h,this.tickMaxWidth=y}},{key:"draw",value:function(e){var t=this,i=this.ctx,n=this.options,o=n.yAxis,r=n.chart;i.beginPath(),i.fillStyle=o.backgroundColor||"#fff",i.fillRect(0,0,this.tickMaxWidth,r.height-12),i.stroke(),i.closePath(),i.textAlign="right",i.textBaseline="middle",i.strokeStyle=o.labels.color,i.lineWidth=1,i.fillStyle=o.labels.color,this.ticks.forEach((function(n){var r;r="function"==typeof o.tickValueFormatter?o.tickValueFormatter(n):I(n);var s=e(n);i.fillText(r,t.tickMaxWidth-5,s)}))}},{key:"drawGridLine",value:function(e){var t=this.ctx,i=this.options,n=i.chart,o=i.yAxis;t.beginPath(),this.ticks.forEach((function(i){var o=e(i);t.moveTo(0,o),t.lineTo(n.width,o)})),t.lineWidth=1,t.strokeStyle=o.gridLineColor,t.stroke(),t.closePath()}},{key:"drawPlotLines",value:function(e){var t=this,i=this.ctx,n=this.options,o=n.chart,r=n.yAxis,s=n.yAxis.plotLines;Array.isArray(s)&&s.forEach((function(n){var s=n.labelEnable,a=void 0===s||s,c=n.label,l=n.textAlign,h=void 0===l?"right":l,u=e(n.value);if(i.setLineDash([5,3]),i.beginPath(),i.moveTo(0,u),i.lineTo(o.width,u),i.strokeStyle=n.color,i.stroke(),i.setLineDash([]),a){var d=c||String(n.value),f="right"===h?o.width-8:t.tickMaxWidth+8;i.textAlign=h,i.textBaseline="top",i.shadowColor=n.shadowColor||"#fff",i.shadowBlur=1,i.lineWidth=1,i.fillStyle=n.color,i.font="".concat(r.labels.fontSize,"px Palantino"),i.strokeText(d,f,u),i.fillText(d,f,u)}}))}}]),e}();function R(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function F(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?R(Object(i),!0).forEach((function(t){s()(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):R(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var H=function(){function e(t,i,n,o){c()(this,e),this.options=void 0,this.ctx=void 0,this.flag=void 0,this.container=void 0,this.isMouserover=void 0,this.options=t,this.ctx=i,this.flag=!1,this.container=n,this.init(n,o),this.isMouserover=!1}return h()(e,[{key:"init",value:function(e,t){var i=this.options.chart.id,n=document.createElement("div");n.id="".concat(i,"-tooltip"),n.className="ts-graph-tooltip",document.getElementById(n.id)||document.body.append(n)}},{key:"clear",value:function(){var e=this.options,t=e.ratio,i=e.chart,n=i.id,o=i.containerWidth,r=i.containerHeight,s=document.getElementById("".concat(n,"-tooltip"));this.isMouserover=!1,this.ctx.save(),this.ctx.setTransform(1*t,0,0,1*t,0,0),this.ctx.clearRect(0,0,o,r),this.ctx.restore(),s.style.top="-99999px",s.lastChild&&s.removeChild(s.lastChild)}},{key:"getNearestPoints",value:function(e,t,i,n,o){var r=this.options,s=r.series,a=void 0===s?[]:s,c=r.chart.colors,l=r.tooltip.shared,h=r.xkey,u=r.ykey,f=r.ykey2,p=r.oykey,v=r.timestamp,y=r.fillNull,m=e.offsetX||e.layerX,g=e.offsetY||e.layerY,b=t.invert(m),x=i.invert(g),_=[];if(!1!==this.isMouserover){var k=[];k=o?function(e,t){var i=t.series,n=void 0===i?[]:i,o=t.xkey,r=t.ykey,s=t.oykey,a=t.timestamp,c=[];return n.forEach((function(t,i){if(!1!==t.visible){var n=t.name,l=t.color,h=Object(d.pickBy)(t,(function(e,t){return"data"!==t})),u=t.data,f=void 0===u?[]:u;"[object Array]"===Object.prototype.toString.call(f)&&f.forEach((function(t){var u=T(t[o],a);u===e&&c.push(M(M({},t),{},{name:n,color:l,timestamp:u,value:t[r],origin:t[s],serieIndex:i,serieOptions:h}))}))}})),c}(o,this.options):z({x:b,xkey:h,ykey:u,ykey2:f,oykey:p,timestamp:v,series:a,fillNull:y});var w,O,C=function(e,t){var i=e.map((function(e){return E(E({},e),{},{distance:Math.abs(e.value-t)})})).sort((function(e,t){return e.distance-t.distance}))[0];return Object(d.omit)(i,["distance"])}(_=k.map((function(e){return F(F({},e),{},{x:t(e.timestamp),y:i(e.value),color:e.color||P(c,e.serieIndex)})})),x),S=Object(d.groupBy)(_,"x");if(Object(d.keys)(S).length>1){var L=Number.POSITIVE_INFINITY;for(var j in S)if(Object.prototype.hasOwnProperty.call(S,j)){var A=(w=e.offsetX,O=Number(j),Math.sqrt(Math.pow(O-w,2)));A<L&&(L=A,_=S[j])}}if(!l){var N=Number.POSITIVE_INFINITY;_.forEach((function(t){var i,n,o=(i={x:e.offsetX,y:e.offsetY},n=t,Math.sqrt(Math.pow(n.x-i.x,2)+Math.pow(n.y-i.y,2)));o<N&&(N=o,_=[t])}))}n(_,C)}}},{key:"draw",value:function(e,t,i,n,o){var r,s=this,a=t.xScales,c=t.yScales,l=t.yAxis,h=t.options,u=null==h||null===(r=h.tooltip)||void 0===r?void 0:r.cascadeMode;this.isMouserover=!0,this.getNearestPoints(e,a,c,(function(t,r){if(s.clear(),s.drawCrosshair(e,n,o),t.length){if(t[0].x<l.tickMaxWidth)return;(void 0===i||void 0!==i&&"sharedTooltip"===u)&&(s.drawSymbol(t),s.drawModal(t,r,e,n,o))}}),i)}},{key:"drawModal",value:function(e,t,i,n,r){var s=this.options,a=s.chart,c=a.id,l=a.renderTo,h=s.tooltip,f=s.time,p=s.notDisplayedSeries,v=s.oykey,y=l.offsetHeight,m=document.getElementById("".concat(c,"-tooltip")),g=document.createElement("div"),b=e,x=((y=window.innerHeight/1.5)-18-100)/15,_=!1;if(h.sharedSortDirection&&(e=Object(d.orderBy)(e,(function(e){return e[v]}),h.sharedSortDirection)),e.length>x&&(e=e.slice(0,x),_=!0),g.className="ts-graph-tooltip-content",m.appendChild(g),"[object Function]"===Object.prototype.toString.call(h.formatter))g.innerHTML=h.formatter(o()(e),o()(b),Object(d.clone)(t));else{var k=e[0],w=document.createDocumentFragment(),O=document.createElement("ul"),C=document.createElement("li"),S=new Date(k.timestamp);if(f&&void 0!==f.timezoneOffset){var L=S.getTimezoneOffset(),E=S.getTime()+60*L*1e3+60*f.timezoneOffset*1e3;S=new Date(E)}var j=document.createTextNode(u.timeFormat(h.timeFormat)(S));if(C.appendChild(j),C.style.color="#666",O.style.maxWidth="".concat(window.innerWidth/1.5,"px"),O.appendChild(C),w.appendChild(O),e.forEach((function(e){var i=e.color,n=e.name,o=e.origin,r=e.filledNull;if(!(p.indexOf(n)>-1)){var s=document.createElement("li");if(i){var a=document.createElement("span"),c=document.createTextNode("● ");a.style.color=i,a.appendChild(c),s.appendChild(a)}if(n){var l=document.createElement("span"),f=document.createTextNode("".concat(n,": "));(null==t?void 0:t.name)===n&&(l.style.fontWeight="bold"),l.appendChild(f),s.appendChild(l)}var v=o;if(Object(d.isNumber)(v)){var y,m=document.createElement("span");if((null==t?void 0:t.name)===n&&(m.style.fontWeight="bold"),"function"==typeof h.pointValueformatter)y=h.pointValueformatter(v);else if("origin"===h.precision)y=v;else if("short"===h.precision){y=function(e){e:for(var t,i=e.length,n=1,o=-1;n<i;++n)switch(e[n]){case".":o=t=n;break;case"0":0===o&&(o=n),t=n;break;default:if(o>0){if(!+e[n])break e;o=0}}return o>0?e.slice(0,o)+e.slice(t+1):e}(u.format(".5s")(v))}else y=h.precision>0?u.format(",."+h.precision+"f")(v):u.format(",.3f")(v);y+=r?"(空值填补,仅限看图使用)":"";var g=document.createTextNode(y);m.appendChild(g),s.appendChild(m)}O.appendChild(s)}})),_){var z=document.createElement("li"),A=document.createTextNode("......");z.appendChild(A),O.appendChild(z)}g.appendChild(w)}var M=g.offsetWidth,P=g.offsetHeight,T=this.container.getBoundingClientRect(),N=(n||i.layerX)+T.left,I=(r||i.layerY)+T.top;m.style.left="".concat(N-M-20,"px"),m.style.top="".concat(I+20,"px"),N-M-20<0&&(m.style.left="".concat(N+20,"px")),I+20+P>y&&(m.style.top=I-P-20<0?"0px":"".concat(I-P-20,"px")),m.style.zIndex="9999",m.style.visibility="visible"}},{key:"drawSymbol",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=this.ctx,i=this.options;e.forEach((function(e){var n=e.x,o=e.y,r=e.color,s=e.name;i.notDisplayedSeries.indexOf(s)>-1||(t.beginPath(),t.arc(n,o,5,0,360,!1),t.lineWidth=1,t.fillStyle=r,t.fill(),t.beginPath(),t.arc(n,o,3,0,360,!1),t.lineWidth=1,t.fillStyle="white",t.fill())}))}},{key:"drawCrosshair",value:function(e,t,i){var n=this.ctx,o=this.options,r=o.chart,s=o.xAxis,a=t||e.offsetX||e.layerX,c=i||e.offsetY||e.layerY,l=r.height-s.tickpadding-s.labels.fontSize-s.tickLength,h=r.width,u=[3,3];n.beginPath(),n.setLineDash(u),n.moveTo(a,0),n.lineTo(a,l),n.lineWidth=1,n.strokeStyle="#666",n.stroke(),n.closePath(),n.beginPath(),n.setLineDash(u),n.moveTo(0,c),n.lineTo(h,c),n.lineWidth=1,n.strokeStyle="#666",n.stroke(),n.closePath()}},{key:"destroy",value:function(){var e=this.options.chart.id,t=document.getElementById("".concat(e,"-tooltip"));t&&t.parentNode&&t.parentNode.removeChild(t)}}]),e}(),Z=function(){function e(t,i){c()(this,e),this.options=void 0,this.ctx=void 0,this.options=t,this.ctx=i}return h()(e,[{key:"draw",value:function(e,t){var i=this.options,n=i.series,o=i.chart,r=o.colors,s=o.height,a=i.xAxis,c=i.xkey,l=i.ykey,h=i.ykey2,f=i.timestamp,p=i.fillNull,v=i.notDisplayedSeries,y=i.curve,m=this.options.line.width,g=this.options.area,b=g.opacity,x=g.gradientMode,_=g.gradientOpacityStopColor,k=this.ctx,w=function(t){var i="X"===f?1e3*t[c]:t[c];return e(new Date(i))},O=function(e,i){var n=e[i];return"number"!=typeof n||isNaN(n)?"number"==typeof p?t(p):void 0:t(n)},C=function(e){return"number"==typeof e[l]||"number"==typeof p};Object(d.sortBy)(n,"zIndex").forEach((function(e,t){if(!1!==e.visible&&!(v.indexOf(e.name)>-1)){var i,n=e.color||P(r,t);if(e.color=n,"opacity"===x&&((i=k.createLinearGradient(0,0,0,s)).addColorStop(0,n),i.addColorStop(1,_)),b>0||e.opacity){k.beginPath();var o=u.area().x(w).y0((function(e){return h&&h in e?O(e,l):a.visible?s-a.tickpadding-a.labels.fontSize-5:s})).y1((function(e){return O(e,h&&h in e?h:l)})).defined(C).context(k);y.enabled&&"smooth"===y.mode&&o.curve(u.curveMonotoneX),o(e.data||[]),k.fillStyle="opacity"===x&&i?i:n,k.globalAlpha=b||(e.opacity?e.opacity:.5),k.fill(),k.closePath()}if(m>0&&void 0===e.opacity){k.beginPath();var c=u.line().x(w).y((function(e){return O(e,l)})).defined(C).context(k);y.enabled&&"smooth"===y.mode&&c.curve(u.curveMonotoneX),k.lineTo(0,0),c(e.data||[]),k.lineJoin="round",k.lineWidth=m,k.strokeStyle=n,k.lineCap="round",k.globalAlpha=1,k.setLineDash(e.lineDash||[]),k.stroke(),k.closePath()}}}))}}]),e}(),Y=function(){function e(t,i){c()(this,e),this.options=void 0,this.ctx=void 0,this.options=t,this.ctx=i}return h()(e,[{key:"draw",value:function(e,t,i){var n=this.options,o=n.series,r=n.chart,s=r.colors,a=r.height,c=r.width,l=n.xAxis,h=n.timestamp,f=n.xkey,p=n.ykey,v=n.notDisplayedSeries,y=this.ctx,m=this.options.area.opacity;Object(d.sortBy)(o,"zIndex").forEach((function(n,o){if(!1!==n.visible&&!(v.indexOf(n.name)>-1)){var r=n.color||P(s,o);n.color=r,y.fillStyle=r,y.globalAlpha=m;var d=u.scaleBand().domain(n.data.map((function(e){return"X"===h?1e3*e[f]:e[f]}))).range([0,c]).padding(.3),g=(null==i?void 0:i.k)||1;n.data.forEach((function(i){var n="X"===h?1e3*i[f]:i[f];y.fillRect(e(n)-d.bandwidth()*g/2,t(i[p]),d.bandwidth()*g,a-t(i[p])-l.tickpadding-l.labels.fontSize-5)})),y.globalAlpha=1}}))}}]),e}(),q=function(){function e(t,i,n,o){c()(this,e),this.options=void 0,this.reset=void 0,this.options=t,this.init(n,o),this.reset=i}return h()(e,[{key:"init",value:function(e,t){var i=this.options.chart,n=i.id,o=i.containerHeight,r=document.getElementById("".concat(n,"-zoom"));r&&r.remove(),r=document.createElement("div");var s=document.createElement("div"),a=document.createElement("a"),c=document.createTextNode("Reset zoom");r.id="".concat(n,"-zoom"),r.className="ts-graph-zoom",s.id="".concat(n,"-zoom-marker"),s.className="ts-graph-zoom-marker",s.style.height="".concat(o,"px"),a.id="".concat(n,"-zoom-resetBtn"),a.className="ts-graph-zoom-resetBtn",a.appendChild(c),r.appendChild(s),r.appendChild(a),e.insertBefore(r,t),this.onReset()}},{key:"onReset",value:function(){var e=this,t=this.options.chart.id,i=document.getElementById("".concat(t,"-zoom-resetBtn"));null==i||i.addEventListener("click",(function(t){t.stopPropagation(),e.reset(),e.clearResetBtn()}))}},{key:"onZoom",value:function(e,t,i){var n=this.options.chart.width,o=t.layerX-e.layerX;if(o){var r=n/Math.abs(o),s=t.layerX>e.layerX?e.layerX:t.layerX,a=u.zoomIdentity.translate(-s*r,0).scale(r);this.options.onZoomWithoutDefult||this.drawResetBtn(),i(a)}}},{key:"clearMarker",value:function(){var e=this.options.chart.id,t=document.getElementById("".concat(e,"-zoom-marker"));t.style.display="none",t.style.width="0px",t.style.left="unset",t.style.right="unset"}},{key:"drawMarker",value:function(e,t){var i=this.options.chart.marginLeft,n=e.layerX,o=t.layerX,r=this.options.chart,s=r.id,a=r.containerWidth,c=document.getElementById("".concat(s,"-zoom-marker"));c.style.display="block",c.style.top="0px",n<o?(c.style.right="unset",c.style.left="".concat(n+i,"px"),c.style.width="".concat(o-n,"px")):(c.style.left="unset",c.style.right="".concat(a-n-i,"px"),c.style.width="".concat(n-o,"px"))}},{key:"clearResetBtn",value:function(){var e=this.options.chart.id;document.getElementById("".concat(e,"-zoom-resetBtn")).style.display="none"}},{key:"drawResetBtn",value:function(){var e=this.options.chart.id;document.getElementById("".concat(e,"-zoom-resetBtn")).style.display="block"}}]),e}(),V=function(){function e(t,i,n,o){var r=this;c()(this,e),this.options=void 0,this.onLegendItemClick=void 0,this.handelLegendItemClick=function(e){var t=e.currentTarget;if(t){t.classList.contains("ts-graph-legend-item-active")?t.classList.remove("ts-graph-legend-item-active"):t.classList.add("ts-graph-legend-item-active");var i=t.getAttribute("data-serie");i&&r.onLegendItemClick(i)}},this.options=t,this.init(n,o),this.onLegendItemClick=i}return h()(e,[{key:"init",value:function(e,t){var i=this.options.chart.id,n=document.createElement("div");n.id="".concat(i,"-legend"),n.className="ts-graph-legend",document.getElementById(n.id)||e.insertBefore(n,t)}},{key:"initEvent",value:function(){var e=this,t=this.options.chart.id;document.getElementById("".concat(t,"-legend")).querySelectorAll(".ts-graph-legend-item").forEach((function(t){t.removeEventListener("click",e.handelLegendItemClick),t.addEventListener("click",e.handelLegendItemClick)}))}},{key:"updateOptions",value:function(e){this.options=e}},{key:"draw",value:function(){var e=this.options,t=e.chart.id,i=e.series,n=e.legend,o=document.getElementById("".concat(t,"-legend"));if(n.enabled){if("[object Array]"===Object.prototype.toString.call(i)){o.innerHTML="";var r=document.createDocumentFragment();i.forEach((function(e){var t=document.createElement("span"),i=document.createElement("span"),n=document.createElement("span"),o=document.createElement("span"),s=document.createTextNode(e.name);t.className="ts-graph-legend-item",t.setAttribute("data-serie",e.name),i.className="ts-graph-legend-item-symbol",n.className="ts-graph-legend-item-symbol-line",n.style.borderColor=e.color,o.className="ts-graph-legend-item-symbol-point",o.style.backgroundColor=e.color,i.appendChild(n),i.appendChild(o),t.appendChild(i),t.appendChild(s),r.appendChild(t)})),o.appendChild(r)}this.initEvent()}}}]),e}(),G=function(){function e(t,i){c()(this,e),this.options=void 0,this.options=t,this.init(i)}return h()(e,[{key:"init",value:function(e){var t=this.options.chart.id,i=document.getElementById("".concat(t,"-shapes"));i&&i.remove(),(i=document.createElement("div")).id="".concat(t,"-shapes"),i.className="ts-graph-shapes",e.appendChild(i),i.addEventListener("mouseover",this.onMouseMove.bind(this)),i.addEventListener("click",this.onClick.bind(this))}},{key:"onMouseMove",value:function(e){var t=this.options,i=t.shapes,n=t.onShapeMouseOver;if("IMG"===e.target.tagName){var o=Object(d.find)(i,{id:e.target.dataset.id});o&&"function"==typeof n&&n(e,o)}}},{key:"onClick",value:function(e){var t=this.options,i=t.shapes,n=t.onShapeClick;if("IMG"===e.target.tagName){var o=Object(d.find)(i,{id:e.target.dataset.id});o&&"function"==typeof n&&n(e,o)}}},{key:"draw",value:function(e,t){var i=this.options,n=i.chart.id,o=i.shapes,r=document.getElementById("".concat(n,"-shapes"));r&&"[object Array]"===Object.prototype.toString.call(o)&&(r.innerHTML="",o.forEach((function(i){var n=document.createElement("img");n.src=i.imgData,n.dataset.id=i.id,n.style.position="absolute",n.onload=function(){n.style.left="".concat(e(i.x)+n.width/2,"px"),n.style.top="".concat(t(i.y)-n.height/2,"px")},r.appendChild(n)})))}},{key:"destroy",value:function(){var e=this.options.chart.id,t=document.getElementById("".concat(e,"-shapes"));t&&(t.removeEventListener("mouseover",this.onMouseMove),t.removeEventListener("click",this.onClick),t.parentNode&&(t.innerHTML=""))}}]),e}();i(12);function U(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return $(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return $(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}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,s=!0,a=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return s=e.done,e},e:function(e){a=!0,r=e},f:function(){try{s||null==i.return||i.return()}finally{if(a)throw r}}}}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function K(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function J(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?K(Object(i),!0).forEach((function(t){s()(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):K(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var Q=new S.a,ee=function(){function e(t){var i=this;c()(this,e),this.options=void 0,this.container=void 0,this.frontContext=void 0,this.backContext=void 0,this.eventCanvas=void 0,this.frontCanvas=void 0,this.backCanvas=void 0,this.xAxis=void 0,this.xScales=void 0,this.yAxis=void 0,this.yScales=void 0,this.line=void 0,this.bar=void 0,this.legend=void 0,this.tooltip=void 0,this.zoom=void 0,this.transform=void 0,this.shapes=void 0,this.isMouserover=void 0,this.showTooltip=function(e,t,n,o){if(!i.isMouserover){var r=i.options.chart.width*n,s=i.options.chart.height*o;i.tooltip.draw(e,i,t,r,s)}},this.hideTooltip=function(){i.tooltip.clear()},this.getZoomedSeries=function(){var e=i.options,t=e.chart.renderTo,n=e.series,o=e.timestamp,r=e.xkey,s=t.offsetWidth;return n.map((function(e){if("[object Array]"===Object.prototype.toString.call(e.data)){var t=e.data.filter((function(e){var t="X"===o?1e3*e[r]:e[r],n=i.xScales(new Date(t));return n>=0&&n<=s}));return J(J({},e),{},{data:t})}return e}))},this.handleResize=function(){var e=i.options.chart,t=e.renderTo.offsetWidth,n=e.renderTo.offsetHeight;i.options.chart.width=t-e.marginLeft-e.marginRight,i.options.chart.height=n-e.marginTop-e.marginBottom,i.options.chart.containerWidth=t,i.options.chart.containerHeight=n,i.container.style.width="".concat(t,"px"),i.container.style.height="".concat(n,"px"),i.retinaScaled(i.backCanvas,"back"),i.retinaScaled(i.frontCanvas,"front"),i.retinaScaled(i.eventCanvas,"event"),i.initScales(),i.initZoom(),i.draw(!1)},this.handleZoom=function(e,t){if(i.options.onZoomWithoutDefult){var n;t&&(n=Object(d.sortBy)(t,"layerX").map((function(e){return i.xScales.invert(e.layerX)}))),i.options.onZoomWithoutDefult(n)}else{var o=i.options,r=o.ykey,s=o.ykey2,a=o.yAxis,c=o.ykeyFormatter,l=i.options.series;if(e?(i.transform=e,i.xScales=e.rescaleX(i.xScales),l=i.getZoomedSeries()):(i.transform=void 0,i.xScales=i.xAxis.init()),Array.isArray(l)){var h,u=a.min||-1/0,f=a.max||1/0,p=U(l);try{for(p.s();!(h=p.n()).done;){var v=h.value,y=Array.isArray(v.data)?v.data:[],m=void 0;for(m=0;m<y.length;m++){var g=y[m],b=D(g[r],c);if(null!==b&&(u<b&&(u=b),f>b&&(f=b),s)){var x=D(g[s],c);if(null===x)continue;u<x&&(u=x),f>x&&(f=x)}}}}catch(e){p.e(e)}finally{p.f()}u!==-1/0&&f!==1/0&&i.yAxis.setDomain(i.yScales,{ymin:u,ymax:f})}i.options.onZoom(i.getZoomedSeries)}i.draw(!1)},this.handleLegendItemClick=function(e){var t=i.options.notDisplayedSeries;-1===t.indexOf(e)?t.push(e):i.options.notDisplayedSeries=t.filter((function(t){return t!==e})),i.draw(!1)};var n={ratio:window.devicePixelRatio||1,xkey:0,ykey:1,ykey2:2,oykey:"__originValue",timestamp:"x",chart:{id:Object(d.uniqueId)("ts-graph-"),colors:["#3399CC","#CC9933","#9966CC","#66CC66","#CC3333","#99CCCC","#CCCC66","#CC99CC","#99CC99","#CC6666","#336699","#996633","#993399","#339966","#993333"],width:t.chart.renderTo.offsetWidth,height:t.chart.renderTo.offsetHeight||350,marginTop:10,marginRight:10,marginBottom:10,marginLeft:10},xAxis:{visible:!0,lineColor:"#ccc",lineWidth:1,tickLength:5,tickpadding:5,tickColor:"#ccc",labels:{color:"#999",fontSize:11}},yAxis:{scale:{type:"linear",log:10},visible:!0,lineColor:"#ccc",lineWidth:1,tickLength:5,tickpadding:5,tickColor:"#ccc",gridLineColor:"#f6f6f6",labels:{color:"#999",fontSize:11}},type:"line",line:{enable:!0,width:2},area:{opacity:0,gradientMode:"none",gradientOpacityStopColor:"rgba(255, 255, 255, 0)"},bars:{},stack:{enabled:!1},curve:{enabled:!1},tooltip:{shared:!0,cascade:!1,cascadeScope:void 0,cascadeMode:"sharedTooltip",timeFormat:"%Y-%m-%d %H:%M:%S"},series:[],legend:{align:"center",verticalAlign:"top",enabled:!1},fillNull:void 0,onClick:void 0,onRightClick:function(){},onZoom:function(){},onShapeMouseOver:function(){},onShapeClick:function(){}},o=Object(d.merge)({},n,t);void 0===t.chart.marginTop&&o.legend.enabled&&(o.chart.marginTop=20),this.handleResize=Object(d.debounce)(this.handleResize,300),this.init(o)}return h()(e,[{key:"init",value:function(e){var t=e.chart;this.isMouserover=!1,this.options=e,this.options.notDisplayedSeries=[],this.options.chart.containerWidth=t.width,this.options.chart.containerHeight=t.height,this.options.chart.width=t.width-t.marginLeft-t.marginRight,this.options.chart.height=t.height-t.marginTop-t.marginBottom,this.createContainer(),this.createCanvas(),this.initSeries(),this.initScales(),this.initEvent(),"line"===this.options.type&&this.initLine(),"bar"===this.options.type&&this.initBar(),this.initLegend(),this.initTooltip(),this.initZoom(),this.initShapes(),this.draw()}},{key:"clearRect",value:function(e){var t=this.options.chart,i=t.containerWidth,n=t.containerHeight;e.clearRect(0,0,i,n)}},{key:"draw",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.transform;this.clearRect(this.backContext),this.options.yAxis.visible&&this.yAxis.drawGridLine(this.yScales),this.options.xAxis.visible&&this.xAxis.draw(this.xScales),"line"===this.options.type&&this.line.draw(this.xScales,this.yScales),"bar"===this.options.type&&this.bar.draw(this.xScales,this.yScales,t),this.xAxis.drawPlotLines(this.xScales),this.yAxis.drawPlotLines(this.yScales),this.options.yAxis.visible&&this.yAxis.draw(this.yScales),e&&this.legend.draw(),this.shapes.draw(this.xScales,this.yScales)}},{key:"update",value:function(e){var t=Object(d.assign)({},this.options,e);e.series&&(t.series=e.series),this.options=t,this.offEvents(),this.initSeries(),this.initScales(),this.initEvent(),"line"===this.options.type&&this.initLine(),"bar"===this.options.type&&this.initBar(),this.initTooltip(),this.initShapes(),this.legend.updateOptions(t),this.draw()}},{key:"getSeries",value:function(){return o()(this.options.series)}},{key:"initEvent",value:function(){var e,t=this.options.tooltip,i=t.cascade,n=t.cascadeScope,o=n?"plotmove:".concat(n):"plotmove",r=n?"plotleave:".concat(n):"plotleave",s=!1,a={},c={},l=this;l.isMouserover=!1;var h=Object(d.debounce)((function(e){l.isMouserover&&(l.tooltip.draw(e,l),s&&l.zoom.drawMarker(a,e))}),5),f=Object(d.throttle)((function(){l.tooltip.clear()}),5),p=function(){if("function"==typeof l.options.onClick){var e=B(u.event,l.options,l.xScales,l.yScales),t=e.x,i=e.y,n=e.nearestPoints;l.options.onClick(u.event,t,i,n)}};u.select(this.eventCanvas).on("mousemove",(function(){if(l.isMouserover=!0,h(u.event),i){var e,t=B(u.event,l.options,l.xScales,l.yScales).nearestPoints;if(t.length)e=t[0].timestamp;var n=u.event.offsetX||u.event.layerX,r=u.event.offsetY||u.event.layerY,s=l.options.chart.width,a=l.options.chart.height;Q.emit(o,u.event,e,n/s,r/a)}})).on("mouseleave",(function(){e=u.event,l.isMouserover=!1,f(),i&&Q.emit(r)})).on("mousedown",(function(){1===u.event.which&&(s=!0,a=u.event)})).on("mouseup",(function(){u.event.stopPropagation();var e=u.event;a&&a.layerX!==e.layerX?(l.zoom.clearMarker(),l.zoom.onZoom(a,e,(function(t){l.handleZoom(t,[a,e])}))):p(),s=!1,a={}})).on("contextmenu",(function(){l.options.onRightClick(u.event,l.xScales.invert(u.event.offsetX),l.yScales.invert(u.event.offsetY)),u.event.preventDefault()})).on("touchstart",(function(){u.event.touches.length>1&&(s=!0)})).on("touchmove",(function(){var e=N(l.eventCanvas,u.event);1===u.event.touches.length&&l.tooltip.draw(e,l),s&&(a=e,c=N(l.eventCanvas,u.event,1),l.zoom.drawMarker(a,c))})).on("touchend",(function(){l.isMouserover=!1,f(),a&&a.layerX!==c.layerX?(l.zoom.clearMarker(),l.zoom.onZoom(a,c,(function(e){l.handleZoom(e,[a,c])}))):p(),s=!1,a={},c={}})),i&&(Q.on(o,this.showTooltip),Q.on(r,this.hideTooltip)),window.addEventListener("mouseup",(function(){if(!Object(d.isEmpty)(a)){var t=e;s=!1,l.zoom.clearMarker(),l.zoom.onZoom(a,t,(function(e){l.handleZoom(e,[a,t])})),a={}}})),x(this.options.chart.renderTo,this.handleResize)}},{key:"retinaScaled",value:function(e,t){var i=this.options,n=i.chart,o=i.ratio,r=e.getContext("2d"),s="front"===t?n.containerWidth:n.width,a="front"===t?n.containerHeight:n.height,c="front"===t?"0px":"".concat(n.marginLeft,"px"),l="front"===t?"0px":"".concat(n.marginTop,"px");e.width=s*o,e.height=a*o,e.style.width="".concat(s,"px"),e.style.height="".concat(a,"px"),e.style.position="absolute",e.style.left=c,e.style.top=l,"front"===t&&r.translate(n.marginLeft*o,n.marginTop*o),r.scale(o,o)}},{key:"createContainer",value:function(){var e=this.options.chart,t=document.createElement("div");t.style.position="relative",t.style.width="".concat(e.containerWidth,"px"),t.style.height="".concat(e.containerHeight,"px"),t.style.overflow="hidden",t.className="d3-graph-container",e.renderTo.appendChild(t),this.container=t}},{key:"createCanvas",value:function(){var e=this.options.chart.id;function t(t){var i=document.createElement("canvas"),n=i.getContext("2d");i.setAttribute("id","".concat(e,"-").concat(t,"Canvas")),this.container.appendChild(i),this["".concat(t,"Canvas")]=i,this["".concat(t,"Context")]=n,this.retinaScaled(i,t)}t.call(this,"back"),t.call(this,"front"),t.call(this,"event")}},{key:"initSeries",value:function(){var e=this.options,t=e.fillNull,i=e.series,n=e.xkey,o=e.ykey,r=e.ykey2,a=e.ykeyFormatter,c=e.oykey,l=e.xAxis,h=e.yAxis,u=e.stack,f=e.notDisplayedSeries,p=l.min||-1/0,v=l.max||1/0,y=h.min,m=h.max;if(Array.isArray(i)){var g=[];i.forEach((function(e,l){if(!(f.indexOf(e.name)>-1)){var b,x=Array.isArray(e.data)?e.data:[],_=[],k=!1,w=function(){var e,h=void 0!==x[b][c]?x[b][c]:D(x[b][o],a),f=(e={},s()(e,n,x[b][n]),s()(e,o,h),s()(e,c,h),e);if(r&&r in x[b]&&(f[r]=D(x[b][r],a)),u.enabled){void 0===f[c]&&(f[c]=D(f[o],a));var g=l;if(g>0)for(;g>0;){var w=Array.isArray(i[g-1].data)?i[g-1].data:[],O=Object(d.find)(w,(function(e){return e[n]===f[n]}));if(O){var C=isNaN(f[c])?0:f[c],S=D(O[o],a);S=isNaN(S)?0:S,f[o]=S+C;break}1===g&&(f[o]=f[c]),g--}else f[o]=f[c]}x[b]=f;var L=f[n],E=f[o],j=void 0;r&&r in x[b]&&(j=f[r]),void 0===t?!isNaN(E)&&(0===b||b===x.length-1||b>0&&b<x.length-1&&"number"==typeof E)?(_.push(f),k=!0):k&&(_.push(f),k=!1):_.push(f),(L<p||p===-1/0)&&(p=L),(L>v||v===1/0)&&(v=L),"number"!=typeof E||isNaN(E)?"number"==typeof t&&(t<y&&(y=t),t>m&&(m=t)):(("number"!=typeof y||E<y)&&(y=E),"number"==typeof j&&j<y&&(y=j),("number"!=typeof m||E>m)&&(m=E),"number"==typeof j&&j>m&&(m=j))};for(b=0;b<x.length;b++)w();"number"!=typeof h.min&&"number"!=typeof h.max||(_=Object(d.map)(_,(function(e){return"number"!=typeof e[o]||isNaN(e[o])?e:"number"==typeof h.min&&e[o]<h.min||"number"==typeof h.max&&e[o]>h.max?J(J({},e),{},s()({},o,null)):e}))),g.push(J(J({},e),{},{data:_,zIndex:u.enabled?i.length-l:l}))}})),this.options.series=g,this.options.xmin=p,this.options.xmax=v,this.options.ymin=y,this.options.ymax=m}}},{key:"initLine",value:function(){this.line=new Z(this.options,this.backContext)}},{key:"initBar",value:function(){this.bar=new Y(this.options,this.backContext)}},{key:"initTooltip",value:function(){this.tooltip=new H(this.options,this.frontContext,this.container,this.eventCanvas)}},{key:"initZoom",value:function(){this.zoom=new q(this.options,this.handleZoom,this.container,this.eventCanvas)}},{key:"initLegend",value:function(){this.legend=new V(this.options,this.handleLegendItemClick,this.container,this.eventCanvas)}},{key:"initScales",value:function(){var e=new X(this.options,this.backContext);this.yAxis=e,this.yScales=e.init();var t=new W(this.options,this.backContext,this.yAxis);this.xAxis=t;var i=t.init();this.transform&&(i=this.transform.rescaleX(i)),this.xScales=i}},{key:"initShapes",value:function(){var e=new G(this.options,this.container);this.shapes=e}},{key:"offEvents",value:function(){var e=this.options.tooltip,t=e.cascade,i=e.cascadeScope,n=i?"plotmove:".concat(i):"plotmove",o=i?"plotleave:".concat(i):"plotleave";u.select(this.eventCanvas).on("mousemove",null).on("mouseleave",null).on("mousedown",null).on("mouseup",null).on("touchmove",null),function(e,t){let i=e.__resize_listeners__;if(i){if(t&&i.splice(i.indexOf(t),1),!i.length||!t){if(e.detachEvent&&e.removeEventListener)return e.detachEvent("onresize",e.__resize_legacy_resize_handler__),void document.removeEventListener("DOMSubtreeModified",e.__resize_mutation_handler__);e.__resize_observer__?(e.__resize_observer__.unobserve(e),e.__resize_observer__.disconnect(),e.__resize_observer__=null):(e.__resize_mutation_observer__&&(e.__resize_mutation_observer__.disconnect(),e.__resize_mutation_observer__=null),e.removeEventListener("scroll",k),e.removeChild(e.__resize_triggers__.triggers),e.__resize_triggers__=null),e.__resize_listeners__=null}!--g&&b&&b.parentNode.removeChild(b)}}(this.options.chart.renderTo,this.handleResize),t&&(Q.off(n,this.showTooltip),Q.off(o,this.hideTooltip))}},{key:"destroy",value:function(){this.shapes.destroy(),this.tooltip.destroy(),this.offEvents(),u.select(this.container).remove()}}]),e}()}])}));
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("d3"),require("lodash"));else if("function"==typeof define&&define.amd)define([,],t);else{var i="object"==typeof exports?t(require("d3"),require("lodash")):t(e.d3,e._);for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(window,(function(e,t){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=13)}([function(t,i){t.exports=e},function(e,i){e.exports=t},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){function i(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,i){var n=i(8),o=i(9),r=i(10),s=i(11);e.exports=function(e){return n(e)||o(e)||r(e)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,i){"use strict";var n,o="object"==typeof Reflect?Reflect:null,r=o&&"function"==typeof o.apply?o.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};n=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,e.exports.once=function(e,t){return new Promise((function(i,n){function o(i){e.removeListener(t,r),n(i)}function r(){"function"==typeof e.removeListener&&e.removeListener("error",o),i([].slice.call(arguments))}y(e,t,r,{once:!0}),"error"!==t&&function(e,t,i){"function"==typeof e.on&&y(e,"error",t,i)}(e,o,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function u(e,t,i,n){var o,r,s,a;if(l(i),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),r=e._events),s=r[t]),void 0===s)s=r[t]=i,++e._eventsCount;else if("function"==typeof s?s=r[t]=n?[i,s]:[s,i]:n?s.unshift(i):s.push(i),(o=h(e))>0&&s.length>o&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return e}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},o=d.bind(n);return o.listener=i,n.wrapFn=o,o}function p(e,t,i){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(o):m(o,o.length)}function v(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function m(e,t){for(var i=new Array(t),n=0;n<t;++n)i[n]=e[n];return i}function y(e,t,i,n){if("function"==typeof e.on)n.once?e.once(t,i):e.on(t,i);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(r){n.once&&e.removeEventListener(t,o),i(r)}))}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return h(this)},a.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)r(c,this,t);else{var l=c.length,h=m(c,l);for(i=0;i<l;++i)r(h[i],this,t)}return!0},a.prototype.addListener=function(e,t){return u(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return u(this,e,t,!0)},a.prototype.once=function(e,t){return l(t),this.on(e,f(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,f(this,e,t)),this},a.prototype.removeListener=function(e,t){var i,n,o,r,s;if(l(t),void 0===(n=this._events))return this;if(void 0===(i=n[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(o=-1,r=i.length-1;r>=0;r--)if(i[r]===t||i[r].listener===t){s=i[r].listener,o=r;break}if(o<0)return this;0===o?i.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(i,o),1===i.length&&(n[e]=i[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,i,n;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var o,r=Object.keys(i);for(n=0;n<r.length;++n)"removeListener"!==(o=r[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},a.prototype.listenerCount=v,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,i){var n=i(6);e.exports=function(e){if(Array.isArray(e))return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,i){var n=i(6);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,i){},function(e,t,i){"use strict";i.r(t),i.d(t,"default",(function(){return ie}));var n=i(5),o=i.n(n),r=i(4),s=i.n(r),a=i(2),c=i.n(a),l=i(3),h=i.n(l),u=i(0),d=i(1);let f=null;let p=null;function v(e,t={}){let i=document.createElement(e);return Object.keys(t).forEach(e=>{i[e]=t[e]}),i}function m(e,t,i){return(window.getComputedStyle(e,i||null)||{display:"none"})[t]}function y(e){if(!document.documentElement.contains(e))return{detached:!0,rendered:!1};let t=e;for(;t!==document;){if("none"===m(t,"display"))return{detached:!1,rendered:!1};t=t.parentNode}return{detached:!1,rendered:!0}}let g=0,b=null;function x(e,t){if(e.__resize_mutation_handler__||(e.__resize_mutation_handler__=_.bind(e)),!e.__resize_listeners__)if(e.__resize_listeners__=[],window.ResizeObserver){let{offsetWidth:t,offsetHeight:i}=e,n=new ResizeObserver(()=>{(e.__resize_observer_triggered__||(e.__resize_observer_triggered__=!0,e.offsetWidth!==t||e.offsetHeight!==i))&&w(e)}),{detached:o,rendered:r}=y(e);e.__resize_observer_triggered__=!1===o&&!1===r,e.__resize_observer__=n,n.observe(e)}else if(e.attachEvent&&e.addEventListener)e.__resize_legacy_resize_handler__=function(){w(e)},e.attachEvent("onresize",e.__resize_legacy_resize_handler__),document.addEventListener("DOMSubtreeModified",e.__resize_mutation_handler__);else if(g||(b=function(e){var t=document.createElement("style");return t.type="text/css",t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e)),(document.querySelector("head")||document.body).appendChild(t),t}('.resize-triggers{visibility:hidden;opacity:0;pointer-events:none}.resize-contract-trigger,.resize-contract-trigger:before,.resize-expand-trigger,.resize-triggers{content:"";position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden}.resize-contract-trigger,.resize-expand-trigger{background:#eee;overflow:auto}.resize-contract-trigger:before{width:200%;height:200%}')),function(e){let t=m(e,"position");t&&"static"!==t||(e.style.position="relative");e.__resize_old_position__=t,e.__resize_last__={};let i=v("div",{className:"resize-triggers"}),n=v("div",{className:"resize-expand-trigger"}),o=v("div"),r=v("div",{className:"resize-contract-trigger"});n.appendChild(o),i.appendChild(n),i.appendChild(r),e.appendChild(i),e.__resize_triggers__={triggers:i,expand:n,expandChild:o,contract:r},O(e),e.addEventListener("scroll",k,!0),e.__resize_last__={width:e.offsetWidth,height:e.offsetHeight}}(e),e.__resize_rendered__=y(e).rendered,window.MutationObserver){let t=new MutationObserver(e.__resize_mutation_handler__);t.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0}),e.__resize_mutation_observer__=t}e.__resize_listeners__.push(t),g++}function _(){let{rendered:e,detached:t}=y(this);e!==this.__resize_rendered__&&(!t&&this.__resize_triggers__&&(O(this),this.addEventListener("scroll",k,!0)),this.__resize_rendered__=e,w(this))}function k(){var e,t;O(this),this.__resize_raf__&&(e=this.__resize_raf__,p||(p=(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||function(e){clearTimeout(e)}).bind(window)),p(e)),this.__resize_raf__=(t=()=>{let e=function(e){let{width:t,height:i}=e.__resize_last__,{offsetWidth:n,offsetHeight:o}=e;return n!==t||o!==i?{width:n,height:o}:null}(this);e&&(this.__resize_last__=e,w(this))},f||(f=(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e){return setTimeout(e,16)}).bind(window)),f(t))}function w(e){e&&e.__resize_listeners__&&e.__resize_listeners__.forEach(t=>{t.call(e,e)})}function O(e){let{expand:t,expandChild:i,contract:n}=e.__resize_triggers__,{scrollWidth:o,scrollHeight:r}=n,{offsetWidth:s,offsetHeight:a,scrollWidth:c,scrollHeight:l}=t;n.scrollLeft=o,n.scrollTop=r,i.style.width=s+1+"px",i.style.height=a+1+"px",t.scrollLeft=c,t.scrollTop=l}var S=i(7),C=i.n(S);function L(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function A(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?L(Object(i),!0).forEach((function(t){s()(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):L(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function j(e,t){return"X"===t?1e3*e:e}function E(e){var t,i=e.series,n=e.x,o=e.xkey,r=e.ykey,s=e.ykey2,a=e.oykey,c=e.timestamp,l=e.fillNull,h=(t=function(e,t){return(i=j(e[o],c))<(n=t)?-1:i>n?1:i>=n?0:NaN;var i,n},{left:function(e,i,n,o){for(null==n&&(n=0),null==o&&(o=e.length);n<o;){var r=n+o>>>1;t(e[r],i)<0?n=r+1:o=r}return n},right:function(e,i,n,o){for(null==n&&(n=0),null==o&&(o=e.length);n<o;){var r=n+o>>>1;t(e[r],i)>0?o=r:n=r+1}return n}}).left,u=new Date(n).getTime(),f=[];return"[object Array]"!==Object.prototype.toString.call(i)?[]:(i.forEach((function(e,t){if(!function(e,t){return Object(d.some)(e.data,(function(e){return t&&t in e}))}(e,s)&&!1!==e.visible){var i=e.name,p=e.color,v=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&"[object Function]"===Object.prototype.toString.call(t)&&t(n)&&(i[n]=e[n]);return i}(e,(function(e){return"data"!==e})),m=e.data,y=void 0===m?[]:m;if("[object Array]"===Object.prototype.toString.call(y)&&0!==(y=y.filter((function(e){return"number"==typeof e[r]||"number"==typeof l}))).length){var g,b=h(y,n),x=y[b-1],_=y[b];if(x&&_){var k=j(x[o],c),w=j(_[o],c),O=x[r],S=_[r];null===O&&void 0!==l&&(O=l),null===S&&void 0!==l&&(S=l),g=u-k<w-u?A(A({},x),{},{name:i,color:p,timestamp:k,value:O,origin:x[a],serieIndex:t,serieOptions:v}):A(A({},_),{},{name:i,color:p,timestamp:w,value:S,origin:_[a],serieIndex:t,serieOptions:v}),f.push(g)}else if(x){var C=j(x[o],c),L=x[r];null===L&&void 0!==l&&(L=l),g=A(A({},x),{},{name:i,color:p,timestamp:C,value:L,origin:x[a],serieIndex:t,serieOptions:v}),f.push(g)}else if(_){var E=j(_[o],c),z=_[r];null===z&&void 0!==l&&(z=l),g=A(A({},_),{},{name:i,color:p,timestamp:E,value:z,origin:_[a],serieIndex:t,serieOptions:v}),f.push(g)}}}})),f)}function z(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function M(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?z(Object(i),!0).forEach((function(t){s()(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):z(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function P(e,t){var i=e.length;return t<i?e[t]:P(e,t-i)}function T(e,t){return"X"===t?1e3*e:e}function N(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=e.getBoundingClientRect(),o=t.touches[i].clientX,r=t.touches[i].clientY,s=o-n.left,a=r-n.top;return{offsetX:s,offsetY:a,clientX:o,clientY:r}}function D(e){var t=String(e);if(e>=1e3){t=u.format(".5s")(e);var i=/[kMGTPEZY]$/;if(i.test(t)){var n=t[t.length-1];t=t.replace(i,""),t=parseFloat(t)+n}}return t}function I(e,t,i){var n=e.map((function(e){var n;return n="function"==typeof i?i(e):D(e),t.measureText(n).width}));return Object(d.max)(n)}function W(e,t){var i=e;return null!==e&&"function"==typeof t&&(i=t(e)),i}function B(e,t,i,n){var o=t.xkey,r=t.ykey,s=t.ykey2,a=t.oykey,c=t.timestamp,l=t.series,h=t.fillNull,u=e.offsetX||e.layerX,d=e.offsetY||e.layerY,f=i.invert(u);return{x:f,y:n.invert(d),nearestPoints:E({x:f,xkey:o,ykey:r,ykey2:s,oykey:a,timestamp:c,series:l,fillNull:h})}}var X=function(){function e(t,i,n,o){c()(this,e),this.options=void 0,this.ctx=void 0,this.yAxis=void 0,this.y2Axis=void 0,this.options=t,this.ctx=i,this.yAxis=n,this.y2Axis=o}return h()(e,[{key:"init",value:function(){var e,t=this.options,i=t.chart.width,n=t.timestamp,o=t.xmin,r=t.xmax,s=t.xAxis,a=(null===(e=this.y2Axis)||void 0===e?void 0:e.tickMaxWidth)||0,c=u.scaleTime().range([s.visible?this.yAxis.tickMaxWidth:0,i-a]);return c.domain([T(o,n)-(o===r?1e3:0),T(r,n)+(o===r?1e3:0)]),c}},{key:"draw",value:function(e){var t=this.ctx,i=this.options,n=i.chart,o=i.xAxis,r=i.time,s=e.ticks(Math.floor(n.width/90));o.ticks&&(s=o.ticks);var a=n.height-o.tickpadding-o.labels.fontSize;t.beginPath(),s.forEach((function(i){var n=e(i);n&&(t.moveTo(n,a),t.lineTo(n,a-o.tickLength))})),t.lineWidth=1,t.strokeStyle=o.tickColor,t.stroke(),t.closePath(),t.beginPath(),t.moveTo(this.yAxis.tickMaxWidth,a-o.tickLength),t.lineTo(n.width,a-o.tickLength),t.lineWidth=1,t.strokeStyle=o.lineColor,t.stroke(),t.closePath(),t.textAlign="center",t.textBaseline="bottom",t.fillStyle=o.labels.color,t.font="".concat(o.labels.fontSize,"px Palantino"),s.forEach((function(i,a){var c="%H:%M";0!==i.getSeconds()&&(c="%H:%M:%S"),0===i.getHours()&&0===i.getMinutes()&&0===i.getSeconds()&&(c="%m-%d"),o.labels.timeFormat&&(c=o.labels.timeFormat);var l=i;if(r&&void 0!==r.timezoneOffset){var h=i.getTimezoneOffset(),d=i.getTime()+60*h*1e3+60*r.timezoneOffset*1e3;l=new Date(d)}if(o.ticks&&o.ticks.length>1){var f=e(i);0===a?f+=c.length*o.labels.fontSize/4+1:a===s.length-1&&(f-=c.length*o.labels.fontSize/4-1),t.fillText(u.timeFormat(c)(l),f,n.height)}else e(i)&&t.fillText(u.timeFormat(c)(l),e(i),n.height)}))}},{key:"drawPlotLines",value:function(e){var t=this.ctx,i=this.options,n=i.chart,o=i.xAxis,r=i.xAxis.plotLines,s=n.height-o.tickpadding-o.labels.fontSize;Array.isArray(r)&&r.forEach((function(n){var r=e("X"===i.timestamp?1e3*n.value:n.value);t.setLineDash([5,3]),t.beginPath(),t.moveTo(r,0),t.lineTo(r,s-o.tickLength),t.strokeStyle=n.color,t.stroke(),t.setLineDash([])}))}}]),e}(),R=function(){function e(t,i){c()(this,e),this.options=void 0,this.ctx=void 0,this.tickLength=void 0,this.ticks=void 0,this.tickMaxWidth=void 0,this.options=t;var n=t.yAxis;i.font="".concat(n.labels.fontSize,"px Palantino"),this.ctx=i,this.tickLength=Math.floor(t.chart.height/50),this.ticks=[],this.tickMaxWidth=0}return h()(e,[{key:"init",value:function(){var e=this.options,t=e.chart,i=e.xAxis,n=e.yAxis,o=u.scaleLinear();n.scale&&"log"===n.scale.type&&(o=u.scaleLog().base(n.scale.log||10));var r=o.range([t.height-(i.labels.fontSize+i.tickpadding+i.tickLength),10]);return this.setDomain(r,this.options),r}},{key:"getPlotLinesMaxAbs",value:function(){var e,t=this.options.yAxis.plotLines;return Array.isArray(t)&&t.forEach((function(t){(!e||Math.abs(e)<Math.abs(t.value))&&(e=t.value)})),e}},{key:"setDomain",value:function(e,t){var i=t.ymin,n=t.ymax,o=this.options.yAxis,r=this.tickLength;if(i===n&&0!==i){var s=(n-i)/(this.tickLength-1),a=s/2||n||1;r=0===s?1:this.tickLength,i-=a,n+=a}if(i>n){var c=i;i=n,n=c}if(o.plotLinesFixed||i===n){var l=this.getPlotLinesMaxAbs();l&&(l<i&&(i=l),l>n&&(n=l))}var h=[];if("number"==typeof o.min||"number"==typeof o.max){var f="number"==typeof o.min?o.min:i,p="number"==typeof o.max?o.max:n;if(e.domain([f,p]),"number"==typeof o.min&&o.min>p)h=[o.min];else if("number"==typeof o.max&&o.max<f)h=[o.max];else{var v=u.tickStep(f,p,r);h=Object(d.map)(u.range(f,p,v),(function(e){return Object(d.floor)(e,2)}))}}else e.domain([i,n]),e.nice(r),h=e.ticks(r);var m=I(h,this.ctx,o.tickValueFormatter)+5;this.ticks=h,this.tickMaxWidth=m}},{key:"draw",value:function(e){var t=this,i=this.ctx,n=this.options,o=n.yAxis,r=n.chart;i.beginPath(),i.fillStyle=o.backgroundColor||"#fff",i.fillRect(0,0,this.tickMaxWidth,r.height-12),i.stroke(),i.closePath(),i.textAlign="right",i.textBaseline="middle",i.strokeStyle=o.labels.color,i.lineWidth=1,i.fillStyle=o.labels.color,this.ticks.forEach((function(n){var r;r="function"==typeof o.tickValueFormatter?o.tickValueFormatter(n):D(n);var s=e(n);i.fillText(r,t.tickMaxWidth-5,s)}))}},{key:"drawGridLine",value:function(e){var t=this,i=this.ctx,n=this.options,o=n.chart,r=n.yAxis;i.beginPath(),this.ticks.forEach((function(n){var r=e(n);i.moveTo(t.tickMaxWidth,r),i.lineTo(o.width,r)})),i.lineWidth=1,i.strokeStyle=r.gridLineColor,i.stroke(),i.closePath()}},{key:"drawPlotLines",value:function(e){var t=this,i=this.ctx,n=this.options,o=n.chart,r=n.yAxis,s=n.yAxis.plotLines;Array.isArray(s)&&s.forEach((function(n){var s=n.labelEnable,a=void 0===s||s,c=n.label,l=n.textAlign,h=void 0===l?"right":l,u=e(n.value);if(i.setLineDash([5,3]),i.beginPath(),i.moveTo(0,u),i.lineTo(o.width,u),i.strokeStyle=n.color,i.stroke(),i.setLineDash([]),a){var d=c||String(n.value),f="right"===h?o.width-8:t.tickMaxWidth+8;i.textAlign=h,i.textBaseline="top",i.shadowColor=n.shadowColor||"#fff",i.shadowBlur=1,i.lineWidth=1,i.fillStyle=n.color,i.font="".concat(r.labels.fontSize,"px Palantino"),i.strokeText(d,f,u),i.fillText(d,f,u)}}))}}]),e}(),F=function(){function e(t,i){c()(this,e),this.options=void 0,this.ctx=void 0,this.tickLength=void 0,this.ticks=void 0,this.tickMaxWidth=void 0,this.options=t;var n=t.yAxis;i.font="".concat(n.labels.fontSize,"px Palantino"),this.ctx=i,this.tickLength=Math.floor(t.chart.height/50),this.ticks=[],this.tickMaxWidth=0}return h()(e,[{key:"init",value:function(){var e=this.options,t=e.chart,i=e.xAxis,n=e.yAxis,o=u.scaleLinear();n.scale&&"log"===n.scale.type&&(o=u.scaleLog().base(n.scale.log||10));var r=o.range([t.height-(i.labels.fontSize+i.tickpadding+i.tickLength),10]);return this.setDomain(r,this.options),r}},{key:"getPlotLinesMaxAbs",value:function(){var e,t=this.options.yAxis.plotLines;return Array.isArray(t)&&t.forEach((function(t){(!e||Math.abs(e)<Math.abs(t.value))&&(e=t.value)})),e}},{key:"setDomain",value:function(e,t){var i=t.y2min,n=t.y2max,o=this.options,r=o.yAxis,s=o.yAxis2,a=this.tickLength;if(i===n&&0!==i){var c=(n-i)/(this.tickLength-1),l=c/2||n||1;a=0===c?1:this.tickLength,i-=l,n+=l}if(i>n){var h=i;i=n,n=h}if(r.plotLinesFixed||i===n){var f=this.getPlotLinesMaxAbs();f&&(f<i&&(i=f),f>n&&(n=f))}var p=[];if("number"==typeof r.min||"number"==typeof r.max){var v="number"==typeof r.min?r.min:i,m="number"==typeof r.max?r.max:n;if(e.domain([v,m]),"number"==typeof r.min&&r.min>m)p=[r.min];else if("number"==typeof r.max&&r.max<v)p=[r.max];else{var y=u.tickStep(v,m,a);p=Object(d.map)(u.range(v,m,y),(function(e){return Object(d.floor)(e,2)}))}}else e.domain([i,n]),e.nice(a),p=e.ticks(a);var g=I(p,this.ctx,s.tickValueFormatter)+10;this.ticks=p,this.tickMaxWidth=g}},{key:"draw",value:function(e){var t=this.ctx,i=this.options,n=i.yAxis,o=i.chart;t.beginPath(),t.fillStyle=n.backgroundColor||"#fff",t.fillRect(o.width-this.tickMaxWidth,0,this.tickMaxWidth,o.height-12),t.stroke(),t.closePath(),t.textAlign="right",t.textBaseline="middle",t.strokeStyle=n.labels.color,t.lineWidth=1,t.fillStyle=n.labels.color,this.ticks.forEach((function(i){var r;r="function"==typeof n.tickValueFormatter?n.tickValueFormatter(i):D(i);var s=e(i);t.fillText(r,o.width-5,s)}))}}]),e}();function H(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Z(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?H(Object(i),!0).forEach((function(t){s()(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):H(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var Y=function(){function e(t,i,n,o){c()(this,e),this.options=void 0,this.ctx=void 0,this.flag=void 0,this.container=void 0,this.isMouserover=void 0,this.options=t,this.ctx=i,this.flag=!1,this.container=n,this.init(n,o),this.isMouserover=!1}return h()(e,[{key:"init",value:function(e,t){var i=this.options.chart.id,n=document.createElement("div");n.id="".concat(i,"-tooltip"),n.className="ts-graph-tooltip",document.getElementById(n.id)||document.body.append(n)}},{key:"clear",value:function(){var e=this.options,t=e.ratio,i=e.chart,n=i.id,o=i.containerWidth,r=i.containerHeight,s=document.getElementById("".concat(n,"-tooltip"));this.isMouserover=!1,this.ctx.save(),this.ctx.setTransform(1*t,0,0,1*t,0,0),this.ctx.clearRect(0,0,o,r),this.ctx.restore(),s.style.top="-99999px",s.lastChild&&s.removeChild(s.lastChild)}},{key:"getNearestPoints",value:function(e,t,i,n,o,r){var s=this.options,a=s.series,c=void 0===a?[]:a,l=s.chart.colors,h=s.tooltip.shared,u=s.xkey,f=s.ykey,p=s.ykey2,v=s.oykey,m=s.timestamp,y=s.fillNull,g=s.yAxis2,b=e.offsetX||e.layerX,x=e.offsetY||e.layerY,_=t.invert(b),k=i.invert(x),w=[];if(!1!==this.isMouserover){var O=[];O=r?function(e,t){var i=t.series,n=void 0===i?[]:i,o=t.xkey,r=t.ykey,s=t.oykey,a=t.timestamp,c=[];return n.forEach((function(t,i){if(!1!==t.visible){var n=t.name,l=t.color,h=Object(d.pickBy)(t,(function(e,t){return"data"!==t})),u=t.data,f=void 0===u?[]:u;"[object Array]"===Object.prototype.toString.call(f)&&f.forEach((function(t){var u=T(t[o],a);u===e&&c.push(M(M({},t),{},{name:n,color:l,timestamp:u,value:t[r],origin:t[s],serieIndex:i,serieOptions:h}))}))}})),c}(r,this.options):E({x:_,xkey:u,ykey:f,ykey2:p,oykey:v,timestamp:m,series:c,fillNull:y});var S,C,L=function(e,t){var i=e.map((function(e){return A(A({},e),{},{distance:Math.abs(e.value-t)})})).sort((function(e,t){return e.distance-t.distance}))[0];return Object(d.omit)(i,["distance"])}(w=O.map((function(e){var o=g.visible&&g.matchName&&e.name===g.matchName?n:i;return Z(Z({},e),{},{x:t(e.timestamp),y:o(e.value),color:e.color||P(l,e.serieIndex)})})),k),j=Object(d.groupBy)(w,"x");if(Object(d.keys)(j).length>1){var z=Number.POSITIVE_INFINITY;for(var N in j)if(Object.prototype.hasOwnProperty.call(j,N)){var D=(S=e.offsetX,C=Number(N),Math.sqrt(Math.pow(C-S,2)));D<z&&(z=D,w=j[N])}}if(!h){var I=Number.POSITIVE_INFINITY;w.forEach((function(t){var i,n,o=(i={x:e.offsetX,y:e.offsetY},n=t,Math.sqrt(Math.pow(n.x-i.x,2)+Math.pow(n.y-i.y,2)));o<I&&(I=o,w=[t])}))}o(w,L)}}},{key:"draw",value:function(e,t,i,n,o){var r,s=this,a=t.xScales,c=t.yScales,l=t.y2Scales,h=t.yAxis,u=t.options,d=null==u||null===(r=u.tooltip)||void 0===r?void 0:r.cascadeMode;this.isMouserover=!0,this.getNearestPoints(e,a,c,l,(function(t,r){if(s.clear(),s.drawCrosshair(e,n,o),t.length){if(t[0].x<h.tickMaxWidth)return;(void 0===i||void 0!==i&&"sharedTooltip"===d)&&(s.drawSymbol(t),s.drawModal(t,r,e,n,o))}}),i)}},{key:"drawModal",value:function(e,t,i,n,r){var s=this.options,a=s.chart,c=a.id,l=a.renderTo,h=s.tooltip,f=s.time,p=s.notDisplayedSeries,v=s.oykey,m=l.offsetHeight,y=document.getElementById("".concat(c,"-tooltip")),g=document.createElement("div"),b=e,x=((m=window.innerHeight/1.5)-18-100)/15,_=!1;if(h.sharedSortDirection&&(e=Object(d.orderBy)(e,(function(e){return e[v]}),h.sharedSortDirection)),e.length>x&&(e=e.slice(0,x),_=!0),g.className="ts-graph-tooltip-content",y.appendChild(g),"[object Function]"===Object.prototype.toString.call(h.formatter))g.innerHTML=h.formatter(o()(e),o()(b),Object(d.clone)(t));else{var k=e[0],w=document.createDocumentFragment(),O=document.createElement("ul"),S=document.createElement("li"),C=new Date(k.timestamp);if(f&&void 0!==f.timezoneOffset){var L=C.getTimezoneOffset(),A=C.getTime()+60*L*1e3+60*f.timezoneOffset*1e3;C=new Date(A)}var j=document.createTextNode(u.timeFormat(h.timeFormat)(C));if(S.appendChild(j),S.style.color="#666",O.style.maxWidth="".concat(window.innerWidth/1.5,"px"),O.appendChild(S),w.appendChild(O),e.forEach((function(e){var i=e.color,n=e.name,o=e.origin,r=e.filledNull;if(!(p.indexOf(n)>-1)){var s=document.createElement("li");if(i){var a=document.createElement("span"),c=document.createTextNode("● ");a.style.color=i,a.appendChild(c),s.appendChild(a)}if(n){var l=document.createElement("span"),f=document.createTextNode("".concat(n,": "));(null==t?void 0:t.name)===n&&(l.style.fontWeight="bold"),l.appendChild(f),s.appendChild(l)}var v=o;if(Object(d.isNumber)(v)){var m,y=document.createElement("span");if((null==t?void 0:t.name)===n&&(y.style.fontWeight="bold"),"function"==typeof h.pointValueformatter)m=h.pointValueformatter(v);else if("origin"===h.precision)m=v;else if("short"===h.precision){m=function(e){e:for(var t,i=e.length,n=1,o=-1;n<i;++n)switch(e[n]){case".":o=t=n;break;case"0":0===o&&(o=n),t=n;break;default:if(o>0){if(!+e[n])break e;o=0}}return o>0?e.slice(0,o)+e.slice(t+1):e}(u.format(".5s")(v))}else m=h.precision>0?u.format(",."+h.precision+"f")(v):u.format(",.3f")(v);m+=r?"(空值填补,仅限看图使用)":"";var g=document.createTextNode(m);y.appendChild(g),s.appendChild(y)}O.appendChild(s)}})),_){var E=document.createElement("li"),z=document.createTextNode("......");E.appendChild(z),O.appendChild(E)}g.appendChild(w)}var M=g.offsetWidth,P=g.offsetHeight,T=this.container.getBoundingClientRect(),N=(n||i.layerX)+T.left,D=(r||i.layerY)+T.top;y.style.left="".concat(N-M-20,"px"),y.style.top="".concat(D+20,"px"),N-M-20<0&&(y.style.left="".concat(N+20,"px")),D+20+P>m&&(y.style.top=D-P-20<0?"0px":"".concat(D-P-20,"px")),y.style.zIndex="9999",y.style.visibility="visible"}},{key:"drawSymbol",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=this.ctx,i=this.options;e.forEach((function(e){var n=e.x,o=e.y,r=e.color,s=e.name;i.notDisplayedSeries.indexOf(s)>-1||(t.beginPath(),t.arc(n,o,5,0,360,!1),t.lineWidth=1,t.fillStyle=r,t.fill(),t.beginPath(),t.arc(n,o,3,0,360,!1),t.lineWidth=1,t.fillStyle="white",t.fill())}))}},{key:"drawCrosshair",value:function(e,t,i){var n=this.ctx,o=this.options,r=o.chart,s=o.xAxis,a=t||e.offsetX||e.layerX,c=i||e.offsetY||e.layerY,l=r.height-s.tickpadding-s.labels.fontSize-s.tickLength,h=r.width,u=[3,3];n.beginPath(),n.setLineDash(u),n.moveTo(a,0),n.lineTo(a,l),n.lineWidth=1,n.strokeStyle="#666",n.stroke(),n.closePath(),n.beginPath(),n.setLineDash(u),n.moveTo(0,c),n.lineTo(h,c),n.lineWidth=1,n.strokeStyle="#666",n.stroke(),n.closePath()}},{key:"destroy",value:function(){var e=this.options.chart.id,t=document.getElementById("".concat(e,"-tooltip"));t&&t.parentNode&&t.parentNode.removeChild(t)}}]),e}(),q=function(){function e(t,i){c()(this,e),this.options=void 0,this.ctx=void 0,this.options=t,this.ctx=i}return h()(e,[{key:"draw",value:function(e,t,i){var n=this.options,o=n.series,r=n.chart,s=r.colors,a=r.height,c=n.xAxis,l=n.yAxis2,h=n.xkey,f=n.ykey,p=n.ykey2,v=n.timestamp,m=n.fillNull,y=n.notDisplayedSeries,g=n.curve,b=this.options.line.width,x=this.options.area,_=x.opacity,k=x.gradientMode,w=x.gradientOpacityStopColor,O=this.ctx,S=function(t){var i="X"===v?1e3*t[h]:t[h];return e(new Date(i))},C=function(e,n,o){var r=e[n],s=l.visible&&l.matchName&&o===l.matchName?i:t;return"number"!=typeof r||isNaN(r)?"number"==typeof m?s(m):void 0:s(r)},L=function(e){return"number"==typeof e[f]||"number"==typeof m};Object(d.sortBy)(o,"zIndex").forEach((function(e,t){if(!1!==e.visible&&!(y.indexOf(e.name)>-1)){var i,n=e.color||P(s,t);if(e.color=n,"opacity"===k&&((i=O.createLinearGradient(0,0,0,a)).addColorStop(0,n),i.addColorStop(1,w)),_>0||e.opacity){O.beginPath();var o=u.area().x(S).y0((function(t){return p&&p in t?C(t,f,e.name):c.visible?a-c.tickpadding-c.labels.fontSize-5:a})).y1((function(t){return C(t,p&&p in t?p:f,e.name)})).defined(L).context(O);g.enabled&&"smooth"===g.mode&&o.curve(u.curveMonotoneX),o(e.data||[]),O.fillStyle="opacity"===k&&i?i:n,O.globalAlpha=_||(e.opacity?e.opacity:.5),O.fill(),O.closePath()}if(b>0&&void 0===e.opacity){O.beginPath();var r=u.line().x(S).y((function(t){return C(t,f,e.name)})).defined(L).context(O);g.enabled&&"smooth"===g.mode&&r.curve(u.curveMonotoneX),O.lineTo(0,0),r(e.data||[]),O.lineJoin="round",O.lineWidth=b,O.strokeStyle=n,O.lineCap="round",O.globalAlpha=1,O.setLineDash(e.lineDash||[]),O.stroke(),O.closePath()}}}))}}]),e}(),V=function(){function e(t,i){c()(this,e),this.options=void 0,this.ctx=void 0,this.options=t,this.ctx=i}return h()(e,[{key:"draw",value:function(e,t,i){var n=this.options,o=n.series,r=n.chart,s=r.colors,a=r.height,c=r.width,l=n.xAxis,h=n.timestamp,f=n.xkey,p=n.ykey,v=n.notDisplayedSeries,m=this.ctx,y=this.options.area.opacity;Object(d.sortBy)(o,"zIndex").forEach((function(n,o){if(!1!==n.visible&&!(v.indexOf(n.name)>-1)){var r=n.color||P(s,o);n.color=r,m.fillStyle=r,m.globalAlpha=y;var d=u.scaleBand().domain(n.data.map((function(e){return"X"===h?1e3*e[f]:e[f]}))).range([0,c]).padding(.3),g=(null==i?void 0:i.k)||1;n.data.forEach((function(i){var n="X"===h?1e3*i[f]:i[f];m.fillRect(e(n)-d.bandwidth()*g/2,t(i[p]),d.bandwidth()*g,a-t(i[p])-l.tickpadding-l.labels.fontSize-5)})),m.globalAlpha=1}}))}}]),e}(),G=function(){function e(t,i,n,o){c()(this,e),this.options=void 0,this.reset=void 0,this.options=t,this.init(n,o),this.reset=i}return h()(e,[{key:"init",value:function(e,t){var i=this.options.chart,n=i.id,o=i.containerHeight,r=document.getElementById("".concat(n,"-zoom"));r&&r.remove(),r=document.createElement("div");var s=document.createElement("div"),a=document.createElement("a"),c=document.createTextNode("Reset zoom");r.id="".concat(n,"-zoom"),r.className="ts-graph-zoom",s.id="".concat(n,"-zoom-marker"),s.className="ts-graph-zoom-marker",s.style.height="".concat(o,"px"),a.id="".concat(n,"-zoom-resetBtn"),a.className="ts-graph-zoom-resetBtn",a.appendChild(c),r.appendChild(s),r.appendChild(a),e.insertBefore(r,t),this.onReset()}},{key:"onReset",value:function(){var e=this,t=this.options.chart.id,i=document.getElementById("".concat(t,"-zoom-resetBtn"));null==i||i.addEventListener("click",(function(t){t.stopPropagation(),e.reset(),e.clearResetBtn()}))}},{key:"onZoom",value:function(e,t,i){var n=this.options.chart.width,o=t.layerX-e.layerX;if(o){var r=n/Math.abs(o),s=t.layerX>e.layerX?e.layerX:t.layerX,a=u.zoomIdentity.translate(-s*r,0).scale(r);this.options.onZoomWithoutDefult||this.drawResetBtn(),i(a)}}},{key:"clearMarker",value:function(){var e=this.options.chart.id,t=document.getElementById("".concat(e,"-zoom-marker"));t.style.display="none",t.style.width="0px",t.style.left="unset",t.style.right="unset"}},{key:"drawMarker",value:function(e,t){var i=this.options.chart.marginLeft,n=e.layerX,o=t.layerX,r=this.options.chart,s=r.id,a=r.containerWidth,c=document.getElementById("".concat(s,"-zoom-marker"));c.style.display="block",c.style.top="0px",n<o?(c.style.right="unset",c.style.left="".concat(n+i,"px"),c.style.width="".concat(o-n,"px")):(c.style.left="unset",c.style.right="".concat(a-n-i,"px"),c.style.width="".concat(n-o,"px"))}},{key:"clearResetBtn",value:function(){var e=this.options.chart.id;document.getElementById("".concat(e,"-zoom-resetBtn")).style.display="none"}},{key:"drawResetBtn",value:function(){var e=this.options.chart.id;document.getElementById("".concat(e,"-zoom-resetBtn")).style.display="block"}}]),e}(),U=function(){function e(t,i,n,o){var r=this;c()(this,e),this.options=void 0,this.onLegendItemClick=void 0,this.handelLegendItemClick=function(e){var t=e.currentTarget;if(t){t.classList.contains("ts-graph-legend-item-active")?t.classList.remove("ts-graph-legend-item-active"):t.classList.add("ts-graph-legend-item-active");var i=t.getAttribute("data-serie");i&&r.onLegendItemClick(i)}},this.options=t,this.init(n,o),this.onLegendItemClick=i}return h()(e,[{key:"init",value:function(e,t){var i=this.options.chart.id,n=document.createElement("div");n.id="".concat(i,"-legend"),n.className="ts-graph-legend",document.getElementById(n.id)||e.insertBefore(n,t)}},{key:"initEvent",value:function(){var e=this,t=this.options.chart.id;document.getElementById("".concat(t,"-legend")).querySelectorAll(".ts-graph-legend-item").forEach((function(t){t.removeEventListener("click",e.handelLegendItemClick),t.addEventListener("click",e.handelLegendItemClick)}))}},{key:"updateOptions",value:function(e){this.options=e}},{key:"draw",value:function(){var e=this.options,t=e.chart.id,i=e.series,n=e.legend,o=document.getElementById("".concat(t,"-legend"));if(n.enabled){if("[object Array]"===Object.prototype.toString.call(i)){o.innerHTML="";var r=document.createDocumentFragment();i.forEach((function(e){var t=document.createElement("span"),i=document.createElement("span"),n=document.createElement("span"),o=document.createElement("span"),s=document.createTextNode(e.name);t.className="ts-graph-legend-item",t.setAttribute("data-serie",e.name),i.className="ts-graph-legend-item-symbol",n.className="ts-graph-legend-item-symbol-line",n.style.borderColor=e.color,o.className="ts-graph-legend-item-symbol-point",o.style.backgroundColor=e.color,i.appendChild(n),i.appendChild(o),t.appendChild(i),t.appendChild(s),r.appendChild(t)})),o.appendChild(r)}this.initEvent()}}}]),e}(),$=function(){function e(t,i){c()(this,e),this.options=void 0,this.options=t,this.init(i)}return h()(e,[{key:"init",value:function(e){var t=this.options.chart.id,i=document.getElementById("".concat(t,"-shapes"));i&&i.remove(),(i=document.createElement("div")).id="".concat(t,"-shapes"),i.className="ts-graph-shapes",e.appendChild(i),i.addEventListener("mouseover",this.onMouseMove.bind(this)),i.addEventListener("click",this.onClick.bind(this))}},{key:"onMouseMove",value:function(e){var t=this.options,i=t.shapes,n=t.onShapeMouseOver;if("IMG"===e.target.tagName){var o=Object(d.find)(i,{id:e.target.dataset.id});o&&"function"==typeof n&&n(e,o)}}},{key:"onClick",value:function(e){var t=this.options,i=t.shapes,n=t.onShapeClick;if("IMG"===e.target.tagName){var o=Object(d.find)(i,{id:e.target.dataset.id});o&&"function"==typeof n&&n(e,o)}}},{key:"draw",value:function(e,t){var i=this.options,n=i.chart.id,o=i.shapes,r=document.getElementById("".concat(n,"-shapes"));r&&"[object Array]"===Object.prototype.toString.call(o)&&(r.innerHTML="",o.forEach((function(i){var n=document.createElement("img");n.src=i.imgData,n.dataset.id=i.id,n.style.position="absolute",n.onload=function(){n.style.left="".concat(e(i.x)+n.width/2,"px"),n.style.top="".concat(t(i.y)-n.height/2,"px")},r.appendChild(n)})))}},{key:"destroy",value:function(){var e=this.options.chart.id,t=document.getElementById("".concat(e,"-shapes"));t&&(t.removeEventListener("mouseover",this.onMouseMove),t.removeEventListener("click",this.onClick),t.parentNode&&(t.innerHTML=""))}}]),e}();i(12);function K(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return J(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return J(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}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,s=!0,a=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return s=e.done,e},e:function(e){a=!0,r=e},f:function(){try{s||null==i.return||i.return()}finally{if(a)throw r}}}}function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function Q(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function ee(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(i),!0).forEach((function(t){s()(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Q(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var te=new C.a,ie=function(){function e(t){var i=this;c()(this,e),this.options=void 0,this.container=void 0,this.frontContext=void 0,this.backContext=void 0,this.eventCanvas=void 0,this.frontCanvas=void 0,this.backCanvas=void 0,this.xAxis=void 0,this.xScales=void 0,this.yAxis=void 0,this.yAxis2=void 0,this.yScales=void 0,this.y2Scales=void 0,this.line=void 0,this.bar=void 0,this.legend=void 0,this.tooltip=void 0,this.zoom=void 0,this.transform=void 0,this.shapes=void 0,this.isMouserover=void 0,this.showTooltip=function(e,t,n,o){if(!i.isMouserover){var r=i.options.chart.width*n,s=i.options.chart.height*o;i.tooltip.draw(e,i,t,r,s)}},this.hideTooltip=function(){i.tooltip.clear()},this.getZoomedSeries=function(){var e=i.options,t=e.chart.renderTo,n=e.series,o=e.timestamp,r=e.xkey,s=t.offsetWidth;return n.map((function(e){if("[object Array]"===Object.prototype.toString.call(e.data)){var t=e.data.filter((function(e){var t="X"===o?1e3*e[r]:e[r],n=i.xScales(new Date(t));return n>=0&&n<=s}));return ee(ee({},e),{},{data:t})}return e}))},this.handleResize=function(){var e=i.options.chart,t=e.renderTo.offsetWidth,n=e.renderTo.offsetHeight;i.options.chart.width=t-e.marginLeft-e.marginRight,i.options.chart.height=n-e.marginTop-e.marginBottom,i.options.chart.containerWidth=t,i.options.chart.containerHeight=n,i.container.style.width="".concat(t,"px"),i.container.style.height="".concat(n,"px"),i.retinaScaled(i.backCanvas,"back"),i.retinaScaled(i.frontCanvas,"front"),i.retinaScaled(i.eventCanvas,"event"),i.initScales(),i.initZoom(),i.draw(!1)},this.handleZoom=function(e,t){if(i.options.onZoomWithoutDefult){var n;t&&(n=Object(d.sortBy)(t,"layerX").map((function(e){return i.xScales.invert(e.layerX)}))),i.options.onZoomWithoutDefult(n)}else{var o=i.options,r=o.ykey,s=o.ykey2,a=o.yAxis,c=o.yAxis2,l=o.ykeyFormatter,h=i.options.series;if(e?(i.transform=e,i.xScales=e.rescaleX(i.xScales),h=i.getZoomedSeries()):(i.transform=void 0,i.xScales=i.xAxis.init()),Array.isArray(h)){var u,f=a.min||-1/0,p=a.max||1/0,v=c.min||-1/0,m=c.max||1/0,y=K(h);try{for(y.s();!(u=y.n()).done;){var g=u.value,b=Array.isArray(g.data)?g.data:[],x=void 0;for(x=0;x<b.length;x++){var _=b[x],k=W(_[r],l);if(null!==k&&(c.visible&&c.matchName&&c.matchName===g.name?(v<k&&(v=k),m>k&&(m=k)):(f<k&&(f=k),p>k&&(p=k)),s)){var w=W(_[s],l);if(null===w)continue;f<w&&(f=w),p>w&&(p=w)}}}}catch(e){y.e(e)}finally{y.f()}f!==-1/0&&p!==1/0&&(i.yAxis.setDomain(i.yScales,{ymin:f,ymax:p}),c.visible&&c.matchName&&i.yAxis2.setDomain(i.y2Scales,{y2min:v,y2max:m}))}i.options.onZoom(i.getZoomedSeries)}i.draw(!1)},this.handleLegendItemClick=function(e){var t=i.options.notDisplayedSeries;-1===t.indexOf(e)?t.push(e):i.options.notDisplayedSeries=t.filter((function(t){return t!==e})),i.draw(!1)};var n={ratio:window.devicePixelRatio||1,xkey:0,ykey:1,ykey2:2,oykey:"__originValue",timestamp:"x",chart:{id:Object(d.uniqueId)("ts-graph-"),colors:["#3399CC","#CC9933","#9966CC","#66CC66","#CC3333","#99CCCC","#CCCC66","#CC99CC","#99CC99","#CC6666","#336699","#996633","#993399","#339966","#993333"],width:t.chart.renderTo.clientWidth,height:t.chart.renderTo.clientHeight||350,marginTop:10,marginRight:10,marginBottom:10,marginLeft:10},xAxis:{visible:!0,lineColor:"#ccc",lineWidth:1,tickLength:5,tickpadding:5,tickColor:"#ccc",labels:{color:"#999",fontSize:11}},yAxis:{scale:{type:"linear",log:10},visible:!0,lineColor:"#ccc",lineWidth:1,tickLength:5,tickpadding:5,tickColor:"#ccc",gridLineColor:"#f6f6f6",labels:{color:"#999",fontSize:11}},yAxis2:{scale:{type:"linear",log:10},visible:!1,lineColor:"#ccc",lineWidth:1,tickLength:5,tickpadding:5,tickColor:"#ccc",labels:{color:"#999",fontSize:11}},type:"line",line:{enable:!0,width:2},area:{opacity:0,gradientMode:"none",gradientOpacityStopColor:"rgba(255, 255, 255, 0)"},bars:{},stack:{enabled:!1},curve:{enabled:!1},tooltip:{shared:!0,cascade:!1,cascadeScope:void 0,cascadeMode:"sharedTooltip",timeFormat:"%Y-%m-%d %H:%M:%S"},series:[],legend:{align:"center",verticalAlign:"top",enabled:!1},fillNull:void 0,onClick:void 0,onRightClick:function(){},onZoom:function(){},onShapeMouseOver:function(){},onShapeClick:function(){}},o=Object(d.merge)({},n,t);void 0===t.chart.marginTop&&o.legend.enabled&&(o.chart.marginTop=20),this.handleResize=Object(d.debounce)(this.handleResize,300),this.init(o)}return h()(e,[{key:"init",value:function(e){var t=e.chart;this.isMouserover=!1,this.options=e,this.options.notDisplayedSeries=[],this.options.chart.containerWidth=t.width,this.options.chart.containerHeight=t.height,this.options.chart.width=t.width-t.marginLeft-t.marginRight,this.options.chart.height=t.height-t.marginTop-t.marginBottom,this.createContainer(),this.createCanvas(),this.initSeries(),this.initScales(),this.initEvent(),"line"===this.options.type&&this.initLine(),"bar"===this.options.type&&this.initBar(),this.initLegend(),this.initTooltip(),this.initZoom(),this.initShapes(),this.draw()}},{key:"clearRect",value:function(e){var t=this.options.chart,i=t.containerWidth,n=t.containerHeight;e.clearRect(0,0,i,n)}},{key:"draw",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.transform;this.clearRect(this.backContext),this.options.yAxis.visible&&this.yAxis.drawGridLine(this.yScales),this.options.xAxis.visible&&this.xAxis.draw(this.xScales),"line"===this.options.type&&this.line.draw(this.xScales,this.yScales,this.y2Scales),"bar"===this.options.type&&this.bar.draw(this.xScales,this.yScales,t),this.xAxis.drawPlotLines(this.xScales),this.yAxis.drawPlotLines(this.yScales),this.options.yAxis.visible&&this.yAxis.draw(this.yScales),this.options.yAxis2.visible&&this.options.yAxis2.matchName&&this.yAxis2.draw(this.y2Scales),e&&this.legend.draw(),this.shapes.draw(this.xScales,this.yScales)}},{key:"update",value:function(e){var t=Object(d.assign)({},this.options,e);e.series&&(t.series=e.series),this.options=t,this.offEvents(),this.initSeries(),this.initScales(),this.initEvent(),"line"===this.options.type&&this.initLine(),"bar"===this.options.type&&this.initBar(),this.initTooltip(),this.initShapes(),this.legend.updateOptions(t),this.draw()}},{key:"getSeries",value:function(){return o()(this.options.series)}},{key:"initEvent",value:function(){var e,t=this.options.tooltip,i=t.cascade,n=t.cascadeScope,o=n?"plotmove:".concat(n):"plotmove",r=n?"plotleave:".concat(n):"plotleave",s=!1,a={},c={},l=this;l.isMouserover=!1;var h=Object(d.debounce)((function(e){l.isMouserover&&(l.tooltip.draw(e,l),s&&l.zoom.drawMarker(a,e))}),5),f=Object(d.throttle)((function(){l.tooltip.clear()}),5),p=function(){if("function"==typeof l.options.onClick){var e=B(u.event,l.options,l.xScales,l.yScales),t=e.x,i=e.y,n=e.nearestPoints;l.options.onClick(u.event,t,i,n)}};u.select(this.eventCanvas).on("mousemove",(function(){if(l.isMouserover=!0,h(u.event),i){var e,t=B(u.event,l.options,l.xScales,l.yScales).nearestPoints;if(t.length)e=t[0].timestamp;var n=u.event.offsetX||u.event.layerX,r=u.event.offsetY||u.event.layerY,s=l.options.chart.width,a=l.options.chart.height;te.emit(o,u.event,e,n/s,r/a)}})).on("mouseleave",(function(){e=u.event,l.isMouserover=!1,f(),i&&te.emit(r)})).on("mousedown",(function(){1===u.event.which&&(s=!0,a=u.event)})).on("mouseup",(function(){u.event.stopPropagation();var e=u.event;a&&a.layerX!==e.layerX?(l.zoom.clearMarker(),l.zoom.onZoom(a,e,(function(t){l.handleZoom(t,[a,e])}))):p(),s=!1,a={}})).on("contextmenu",(function(){l.options.onRightClick(u.event,l.xScales.invert(u.event.offsetX),l.yScales.invert(u.event.offsetY)),u.event.preventDefault()})).on("touchstart",(function(){u.event.touches.length>1&&(s=!0)})).on("touchmove",(function(){var e=N(l.eventCanvas,u.event);1===u.event.touches.length&&l.tooltip.draw(e,l),s&&(a=e,c=N(l.eventCanvas,u.event,1),l.zoom.drawMarker(a,c))})).on("touchend",(function(){l.isMouserover=!1,f(),a&&a.layerX!==c.layerX?(l.zoom.clearMarker(),l.zoom.onZoom(a,c,(function(e){l.handleZoom(e,[a,c])}))):p(),s=!1,a={},c={}})),i&&(te.on(o,this.showTooltip),te.on(r,this.hideTooltip)),window.addEventListener("mouseup",(function(){if(!Object(d.isEmpty)(a)){var t=e;s=!1,l.zoom.clearMarker(),l.zoom.onZoom(a,t,(function(e){l.handleZoom(e,[a,t])})),a={}}})),x(this.options.chart.renderTo,this.handleResize)}},{key:"retinaScaled",value:function(e,t){var i=this.options,n=i.chart,o=i.ratio,r=e.getContext("2d"),s="front"===t?n.containerWidth:n.width,a="front"===t?n.containerHeight:n.height,c="front"===t?"0px":"".concat(n.marginLeft,"px"),l="front"===t?"0px":"".concat(n.marginTop,"px");e.width=s*o,e.height=a*o,e.style.width="".concat(s,"px"),e.style.height="".concat(a,"px"),e.style.position="absolute",e.style.left=c,e.style.top=l,"front"===t&&r.translate(n.marginLeft*o,n.marginTop*o),r.scale(o,o)}},{key:"createContainer",value:function(){var e=this.options.chart,t=document.createElement("div");t.style.position="relative",t.style.width="".concat(e.containerWidth,"px"),t.style.height="".concat(e.containerHeight,"px"),t.style.overflow="hidden",t.className="d3-graph-container",e.renderTo.appendChild(t),this.container=t}},{key:"createCanvas",value:function(){var e=this.options.chart.id;function t(t){var i=document.createElement("canvas"),n=i.getContext("2d");i.setAttribute("id","".concat(e,"-").concat(t,"Canvas")),this.container.appendChild(i),this["".concat(t,"Canvas")]=i,this["".concat(t,"Context")]=n,this.retinaScaled(i,t)}t.call(this,"back"),t.call(this,"front"),t.call(this,"event")}},{key:"initSeries",value:function(){var e=this.options,t=e.fillNull,i=e.series,n=e.xkey,o=e.ykey,r=e.ykey2,a=e.ykeyFormatter,c=e.oykey,l=e.xAxis,h=e.yAxis,u=e.yAxis2,f=e.stack,p=e.notDisplayedSeries,v=l.min||-1/0,m=l.max||1/0,y=h.min,g=h.max,b=u.min,x=u.max;if(Array.isArray(i)){var _=[];i.forEach((function(e,l){if(!(p.indexOf(e.name)>-1)){var k,w=Array.isArray(e.data)?e.data:[],O=[],S=!1,C=function(){var h,p=void 0!==w[k][c]?w[k][c]:W(w[k][o],a),_=(h={},s()(h,n,w[k][n]),s()(h,o,p),s()(h,c,p),h);if(r&&r in w[k]&&(_[r]=W(w[k][r],a)),f.enabled){void 0===_[c]&&(_[c]=W(_[o],a));var C=l;if(C>0)for(;C>0;){var L=Array.isArray(i[C-1].data)?i[C-1].data:[],A=Object(d.find)(L,(function(e){return e[n]===_[n]}));if(A){var j=isNaN(_[c])?0:_[c],E=W(A[o],a);E=isNaN(E)?0:E,_[o]=E+j;break}1===C&&(_[o]=_[c]),C--}else _[o]=_[c]}w[k]=_;var z=_[n],M=_[o],P=void 0;r&&r in w[k]&&(P=_[r]),void 0===t?!isNaN(M)&&(0===k||k===w.length-1||k>0&&k<w.length-1&&"number"==typeof M)?(O.push(_),S=!0):S&&(O.push(_),S=!1):O.push(_),(z<v||v===-1/0)&&(v=z),(z>m||m===1/0)&&(m=z),"number"!=typeof M||isNaN(M)?"number"==typeof t&&(t<y&&(y=t),t>g&&(g=t)):u.visible&&u.matchName&&u.matchName===e.name?(("number"!=typeof b||M<b)&&(b=M),("number"!=typeof x||M>x)&&(x=M)):(("number"!=typeof y||M<y)&&(y=M),"number"==typeof P&&P<y&&(y=P),("number"!=typeof g||M>g)&&(g=M),"number"==typeof P&&P>g&&(g=P))};for(k=0;k<w.length;k++)C();"number"!=typeof h.min&&"number"!=typeof h.max||(O=Object(d.map)(O,(function(e){return"number"!=typeof e[o]||isNaN(e[o])?e:"number"==typeof h.min&&e[o]<h.min||"number"==typeof h.max&&e[o]>h.max?ee(ee({},e),{},s()({},o,null)):e}))),_.push(ee(ee({},e),{},{data:O,zIndex:f.enabled?i.length-l:l}))}})),this.options.series=_,this.options.xmin=v,this.options.xmax=m,this.options.ymin=y,this.options.ymax=g,this.options.y2min=b,this.options.y2max=x}}},{key:"initLine",value:function(){this.line=new q(this.options,this.backContext)}},{key:"initBar",value:function(){this.bar=new V(this.options,this.backContext)}},{key:"initTooltip",value:function(){this.tooltip=new Y(this.options,this.frontContext,this.container,this.eventCanvas)}},{key:"initZoom",value:function(){this.zoom=new G(this.options,this.handleZoom,this.container,this.eventCanvas)}},{key:"initLegend",value:function(){this.legend=new U(this.options,this.handleLegendItemClick,this.container,this.eventCanvas)}},{key:"initScales",value:function(){var e=new R(this.options,this.backContext);if(this.yAxis=e,this.yScales=e.init(),this.options.yAxis2.visible&&this.options.yAxis2.matchName){var t=new F(this.options,this.backContext);this.yAxis2=t,this.y2Scales=t.init()}var i=new X(this.options,this.backContext,this.yAxis,this.yAxis2);this.xAxis=i;var n=i.init();this.transform&&(n=this.transform.rescaleX(n)),this.xScales=n}},{key:"initShapes",value:function(){var e=new $(this.options,this.container);this.shapes=e}},{key:"offEvents",value:function(){var e=this.options.tooltip,t=e.cascade,i=e.cascadeScope,n=i?"plotmove:".concat(i):"plotmove",o=i?"plotleave:".concat(i):"plotleave";u.select(this.eventCanvas).on("mousemove",null).on("mouseleave",null).on("mousedown",null).on("mouseup",null).on("touchmove",null),function(e,t){let i=e.__resize_listeners__;if(i){if(t&&i.splice(i.indexOf(t),1),!i.length||!t){if(e.detachEvent&&e.removeEventListener)return e.detachEvent("onresize",e.__resize_legacy_resize_handler__),void document.removeEventListener("DOMSubtreeModified",e.__resize_mutation_handler__);e.__resize_observer__?(e.__resize_observer__.unobserve(e),e.__resize_observer__.disconnect(),e.__resize_observer__=null):(e.__resize_mutation_observer__&&(e.__resize_mutation_observer__.disconnect(),e.__resize_mutation_observer__=null),e.removeEventListener("scroll",k),e.removeChild(e.__resize_triggers__.triggers),e.__resize_triggers__=null),e.__resize_listeners__=null}!--g&&b&&b.parentNode.removeChild(b)}}(this.options.chart.renderTo,this.handleResize),t&&(te.off(n,this.showTooltip),te.off(o,this.hideTooltip))}},{key:"destroy",value:function(){this.shapes.destroy(),this.tooltip.destroy(),this.offEvents(),u.select(this.container).remove()}}]),e}()}])}));
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/examples/index.js
CHANGED
|
@@ -39,13 +39,12 @@ newSeries.push({
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
newSeries.push(origin);
|
|
42
|
-
console.log(newSeries);
|
|
43
42
|
|
|
44
43
|
function random(m, n) {
|
|
45
44
|
return Math.floor(Math.random() * (n - m + 1));
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
function generateSeries(idx, seriesCount =
|
|
47
|
+
function generateSeries(idx, seriesCount = 2) {
|
|
49
48
|
const series = [];
|
|
50
49
|
|
|
51
50
|
for (let n = 1; n <= seriesCount; n++) {
|
|
@@ -56,7 +55,8 @@ function generateSeries(idx, seriesCount = 3) {
|
|
|
56
55
|
seriesData.push({
|
|
57
56
|
timestamp:
|
|
58
57
|
1609430399 + m * (m < 100 ? (idx === 0 ? 1000 : 1001) : 1000),
|
|
59
|
-
value:
|
|
58
|
+
value: random(0, n === 1 ? 100 : 1000000),
|
|
59
|
+
// value: m < 100 ? random(0, 100000000) : random(0, 1000000000),
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -65,18 +65,19 @@ function generateSeries(idx, seriesCount = 3) {
|
|
|
65
65
|
data: seriesData,
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
+
console.log("series", series);
|
|
68
69
|
return series;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
const graphsCount =
|
|
72
|
+
const graphsCount = 1;
|
|
72
73
|
const charts = [];
|
|
73
74
|
|
|
74
75
|
for (let i = 0; i < graphsCount; i++) {
|
|
75
76
|
const id = `c${i}`;
|
|
76
77
|
const renderTo = document.createElement("div");
|
|
77
78
|
renderTo.id = id;
|
|
78
|
-
renderTo.style.width = `${(i + 1) *
|
|
79
|
-
renderTo.style.height = `${(i + 1) *
|
|
79
|
+
renderTo.style.width = `${(i + 1) * 1000}px`;
|
|
80
|
+
renderTo.style.height = `${(i + 1) * 400}px`;
|
|
80
81
|
renderTo.style.margin = "20px";
|
|
81
82
|
renderTo.style.border = "1px solid #ccc";
|
|
82
83
|
document.body.appendChild(renderTo);
|
|
@@ -98,6 +99,10 @@ for (let i = 0; i < graphsCount; i++) {
|
|
|
98
99
|
line: {
|
|
99
100
|
width: 1,
|
|
100
101
|
},
|
|
102
|
+
yAxis2: {
|
|
103
|
+
visible: true,
|
|
104
|
+
matchName: "series_2",
|
|
105
|
+
},
|
|
101
106
|
// xAxis: {
|
|
102
107
|
// visible: false,
|
|
103
108
|
// },
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { addListener, removeListener } from "resize-detector";
|
|
|
14
14
|
import EventEmitter from "events";
|
|
15
15
|
import XAxis from "./xAxis";
|
|
16
16
|
import YAxis from "./yAxis";
|
|
17
|
+
import YAxis2 from "./yAxis2";
|
|
17
18
|
import Tooltip from "./tooltip";
|
|
18
19
|
import Line from "./line";
|
|
19
20
|
import Bar from "./bar";
|
|
@@ -49,7 +50,9 @@ export default class TsGraph {
|
|
|
49
50
|
xAxis!: XAxis;
|
|
50
51
|
xScales!: XScales;
|
|
51
52
|
yAxis!: YAxis;
|
|
53
|
+
yAxis2!: YAxis2;
|
|
52
54
|
yScales!: YScales;
|
|
55
|
+
y2Scales!: YScales;
|
|
53
56
|
line!: Line;
|
|
54
57
|
bar!: Bar;
|
|
55
58
|
legend!: Legend;
|
|
@@ -85,8 +88,8 @@ export default class TsGraph {
|
|
|
85
88
|
"#339966",
|
|
86
89
|
"#993333",
|
|
87
90
|
],
|
|
88
|
-
width: userOptions.chart.renderTo.
|
|
89
|
-
height: userOptions.chart.renderTo.
|
|
91
|
+
width: userOptions.chart.renderTo.clientWidth,
|
|
92
|
+
height: userOptions.chart.renderTo.clientHeight || 350,
|
|
90
93
|
marginTop: 10,
|
|
91
94
|
marginRight: 10,
|
|
92
95
|
marginBottom: 10,
|
|
@@ -123,6 +126,22 @@ export default class TsGraph {
|
|
|
123
126
|
fontSize: 11,
|
|
124
127
|
},
|
|
125
128
|
},
|
|
129
|
+
yAxis2: {
|
|
130
|
+
scale: {
|
|
131
|
+
type: "linear",
|
|
132
|
+
log: 10,
|
|
133
|
+
},
|
|
134
|
+
visible: false,
|
|
135
|
+
lineColor: "#ccc",
|
|
136
|
+
lineWidth: 1,
|
|
137
|
+
tickLength: 5,
|
|
138
|
+
tickpadding: 5,
|
|
139
|
+
tickColor: "#ccc",
|
|
140
|
+
labels: {
|
|
141
|
+
color: "#999",
|
|
142
|
+
fontSize: 11,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
126
145
|
type: "line",
|
|
127
146
|
line: {
|
|
128
147
|
enable: true,
|
|
@@ -218,7 +237,7 @@ export default class TsGraph {
|
|
|
218
237
|
this.xAxis.draw(this.xScales);
|
|
219
238
|
}
|
|
220
239
|
if (this.options.type === "line") {
|
|
221
|
-
this.line.draw(this.xScales, this.yScales);
|
|
240
|
+
this.line.draw(this.xScales, this.yScales, this.y2Scales);
|
|
222
241
|
}
|
|
223
242
|
if (this.options.type === "bar") {
|
|
224
243
|
this.bar.draw(this.xScales, this.yScales, transform);
|
|
@@ -228,6 +247,9 @@ export default class TsGraph {
|
|
|
228
247
|
if (this.options.yAxis.visible) {
|
|
229
248
|
this.yAxis.draw(this.yScales);
|
|
230
249
|
}
|
|
250
|
+
if (this.options.yAxis2.visible && this.options.yAxis2.matchName) {
|
|
251
|
+
this.yAxis2.draw(this.y2Scales);
|
|
252
|
+
}
|
|
231
253
|
if (redrawLegend) {
|
|
232
254
|
this.legend.draw();
|
|
233
255
|
}
|
|
@@ -520,7 +542,7 @@ export default class TsGraph {
|
|
|
520
542
|
}
|
|
521
543
|
this.options.onZoomWithoutDefult(times);
|
|
522
544
|
} else {
|
|
523
|
-
const { ykey, ykey2, yAxis, ykeyFormatter } = this.options;
|
|
545
|
+
const { ykey, ykey2, yAxis, yAxis2, ykeyFormatter } = this.options;
|
|
524
546
|
let { series } = this.options;
|
|
525
547
|
if (transform) {
|
|
526
548
|
this.transform = transform;
|
|
@@ -534,6 +556,8 @@ export default class TsGraph {
|
|
|
534
556
|
if (Array.isArray(series)) {
|
|
535
557
|
let ymin = yAxis.min || -Infinity;
|
|
536
558
|
let ymax = yAxis.max || Infinity;
|
|
559
|
+
let y2min = yAxis2.min || -Infinity;
|
|
560
|
+
let y2max = yAxis2.max || Infinity;
|
|
537
561
|
for (const serie of series) {
|
|
538
562
|
const data = Array.isArray(serie.data) ? serie.data : [];
|
|
539
563
|
let dataIdx;
|
|
@@ -543,11 +567,24 @@ export default class TsGraph {
|
|
|
543
567
|
|
|
544
568
|
if (y === null) continue;
|
|
545
569
|
// get axis domain
|
|
546
|
-
if (
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
570
|
+
if (
|
|
571
|
+
yAxis2.visible &&
|
|
572
|
+
yAxis2.matchName &&
|
|
573
|
+
yAxis2.matchName === serie.name
|
|
574
|
+
) {
|
|
575
|
+
if (y2min < y) {
|
|
576
|
+
y2min = y;
|
|
577
|
+
}
|
|
578
|
+
if (y2max > y) {
|
|
579
|
+
y2max = y;
|
|
580
|
+
}
|
|
581
|
+
} else {
|
|
582
|
+
if (ymin < y) {
|
|
583
|
+
ymin = y;
|
|
584
|
+
}
|
|
585
|
+
if (ymax > y) {
|
|
586
|
+
ymax = y;
|
|
587
|
+
}
|
|
551
588
|
}
|
|
552
589
|
if (ykey2) {
|
|
553
590
|
const y2 = getYkeyValue(item[ykey2], ykeyFormatter);
|
|
@@ -564,6 +601,9 @@ export default class TsGraph {
|
|
|
564
601
|
// 如果缩放至没有数据点(无法计算出 ymin 和 ymax),则不更新 domain
|
|
565
602
|
if (ymin !== -Infinity && ymax !== Infinity) {
|
|
566
603
|
this.yAxis.setDomain(this.yScales, { ymin, ymax });
|
|
604
|
+
if (yAxis2.visible && yAxis2.matchName) {
|
|
605
|
+
this.yAxis2.setDomain(this.y2Scales, { y2min, y2max });
|
|
606
|
+
}
|
|
567
607
|
}
|
|
568
608
|
}
|
|
569
609
|
this.options.onZoom(this.getZoomedSeries);
|
|
@@ -649,6 +689,7 @@ export default class TsGraph {
|
|
|
649
689
|
oykey,
|
|
650
690
|
xAxis,
|
|
651
691
|
yAxis,
|
|
692
|
+
yAxis2,
|
|
652
693
|
stack,
|
|
653
694
|
notDisplayedSeries,
|
|
654
695
|
} = this.options;
|
|
@@ -656,6 +697,8 @@ export default class TsGraph {
|
|
|
656
697
|
let xmax = xAxis.max || Infinity;
|
|
657
698
|
let ymin = yAxis.min;
|
|
658
699
|
let ymax = yAxis.max;
|
|
700
|
+
let y2min = yAxis2.min;
|
|
701
|
+
let y2max = yAxis2.max;
|
|
659
702
|
|
|
660
703
|
if (Array.isArray(series)) {
|
|
661
704
|
const newSeries: Serie[] = [];
|
|
@@ -745,17 +788,30 @@ export default class TsGraph {
|
|
|
745
788
|
xmax = x;
|
|
746
789
|
}
|
|
747
790
|
if (typeof y === "number" && !isNaN(y)) {
|
|
748
|
-
if (
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
791
|
+
if (
|
|
792
|
+
yAxis2.visible &&
|
|
793
|
+
yAxis2.matchName &&
|
|
794
|
+
yAxis2.matchName === serie.name
|
|
795
|
+
) {
|
|
796
|
+
if (typeof y2min !== "number" || y < y2min) {
|
|
797
|
+
y2min = y;
|
|
798
|
+
}
|
|
799
|
+
if (typeof y2max !== "number" || y > y2max) {
|
|
800
|
+
y2max = y;
|
|
801
|
+
}
|
|
802
|
+
} else {
|
|
803
|
+
if (typeof ymin !== "number" || y < ymin) {
|
|
804
|
+
ymin = y;
|
|
805
|
+
}
|
|
806
|
+
if (typeof y2 === "number" && y2 < ymin) {
|
|
807
|
+
ymin = y2;
|
|
808
|
+
}
|
|
809
|
+
if (typeof ymax !== "number" || y > ymax) {
|
|
810
|
+
ymax = y;
|
|
811
|
+
}
|
|
812
|
+
if (typeof y2 === "number" && y2 > ymax) {
|
|
813
|
+
ymax = y2;
|
|
814
|
+
}
|
|
759
815
|
}
|
|
760
816
|
} else if (typeof fillNull === "number") {
|
|
761
817
|
if (fillNull < ymin) {
|
|
@@ -795,6 +851,8 @@ export default class TsGraph {
|
|
|
795
851
|
this.options.xmax = xmax;
|
|
796
852
|
this.options.ymin = ymin;
|
|
797
853
|
this.options.ymax = ymax;
|
|
854
|
+
this.options.y2min = y2min;
|
|
855
|
+
this.options.y2max = y2max;
|
|
798
856
|
}
|
|
799
857
|
}
|
|
800
858
|
|
|
@@ -838,7 +896,18 @@ export default class TsGraph {
|
|
|
838
896
|
this.yAxis = yAxis;
|
|
839
897
|
this.yScales = yAxis.init();
|
|
840
898
|
|
|
841
|
-
|
|
899
|
+
if (this.options.yAxis2.visible && this.options.yAxis2.matchName) {
|
|
900
|
+
const yAxis2 = new YAxis2(this.options, this.backContext);
|
|
901
|
+
this.yAxis2 = yAxis2;
|
|
902
|
+
this.y2Scales = yAxis2.init();
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
const xAxis = new XAxis(
|
|
906
|
+
this.options,
|
|
907
|
+
this.backContext,
|
|
908
|
+
this.yAxis,
|
|
909
|
+
this.yAxis2
|
|
910
|
+
);
|
|
842
911
|
this.xAxis = xAxis;
|
|
843
912
|
let xScales = xAxis.init();
|
|
844
913
|
if (this.transform) {
|
package/src/interface.ts
CHANGED
|
@@ -82,6 +82,7 @@ export type YAxis = {
|
|
|
82
82
|
plotLines: PlotLine[];
|
|
83
83
|
plotLinesFixed?: boolean;
|
|
84
84
|
tickValueFormatter?: (value: number) => string;
|
|
85
|
+
matchName?: string; // 用于匹配 y 轴,如果不填则默认匹配第一个 y 轴
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
export type SerieDataItemMarker = {
|
|
@@ -178,6 +179,7 @@ export interface Options extends BaseOptions {
|
|
|
178
179
|
chart: Chart;
|
|
179
180
|
xAxis: XAxis;
|
|
180
181
|
yAxis: YAxis;
|
|
182
|
+
yAxis2: YAxis;
|
|
181
183
|
tooltip: Tooltip;
|
|
182
184
|
type: "line" | "bar";
|
|
183
185
|
line: {
|
|
@@ -204,6 +206,8 @@ export interface Options extends BaseOptions {
|
|
|
204
206
|
xmax: number;
|
|
205
207
|
ymin: number;
|
|
206
208
|
ymax: number;
|
|
209
|
+
y2min: number;
|
|
210
|
+
y2max: number;
|
|
207
211
|
shapes: any[];
|
|
208
212
|
onClick: (
|
|
209
213
|
d3Event: any,
|
package/src/line.ts
CHANGED
|
@@ -11,11 +11,12 @@ export default class Line {
|
|
|
11
11
|
this.ctx = ctx;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
draw(xScales: XScales, yScales: YScales) {
|
|
14
|
+
draw(xScales: XScales, yScales: YScales, y2Scales: YScales) {
|
|
15
15
|
const {
|
|
16
16
|
series,
|
|
17
17
|
chart: { colors, height },
|
|
18
18
|
xAxis,
|
|
19
|
+
yAxis2,
|
|
19
20
|
xkey,
|
|
20
21
|
ykey,
|
|
21
22
|
ykey2,
|
|
@@ -37,12 +38,16 @@ export default class Line {
|
|
|
37
38
|
const x = xScales(new Date(xVal));
|
|
38
39
|
return x;
|
|
39
40
|
};
|
|
40
|
-
const yAccessor = (d: SerieDataItem, ykey: any) => {
|
|
41
|
+
const yAccessor = (d: SerieDataItem, ykey: any, serieName: string) => {
|
|
41
42
|
const val = d[ykey];
|
|
43
|
+
const yScalesFunc =
|
|
44
|
+
yAxis2.visible && yAxis2.matchName && serieName === yAxis2.matchName
|
|
45
|
+
? y2Scales
|
|
46
|
+
: yScales;
|
|
42
47
|
if (typeof val === "number" && !isNaN(val)) {
|
|
43
|
-
return
|
|
48
|
+
return yScalesFunc(val);
|
|
44
49
|
} else if (typeof fillNull === "number") {
|
|
45
|
-
return
|
|
50
|
+
return yScalesFunc(fillNull);
|
|
46
51
|
}
|
|
47
52
|
return undefined;
|
|
48
53
|
};
|
|
@@ -73,7 +78,7 @@ export default class Line {
|
|
|
73
78
|
.x(xAccessor)
|
|
74
79
|
.y0((d: SerieDataItem) => {
|
|
75
80
|
if (ykey2 && ykey2 in d) {
|
|
76
|
-
return yAccessor(d, ykey);
|
|
81
|
+
return yAccessor(d, ykey, serie.name);
|
|
77
82
|
}
|
|
78
83
|
if (xAxis.visible) {
|
|
79
84
|
return height - xAxis.tickpadding - xAxis.labels.fontSize - 5;
|
|
@@ -82,9 +87,9 @@ export default class Line {
|
|
|
82
87
|
})
|
|
83
88
|
.y1((d: SerieDataItem) => {
|
|
84
89
|
if (ykey2 && ykey2 in d) {
|
|
85
|
-
return yAccessor(d, ykey2);
|
|
90
|
+
return yAccessor(d, ykey2, serie.name);
|
|
86
91
|
}
|
|
87
|
-
return yAccessor(d, ykey);
|
|
92
|
+
return yAccessor(d, ykey, serie.name);
|
|
88
93
|
})
|
|
89
94
|
.defined(definedAccessor)
|
|
90
95
|
.context(ctx);
|
|
@@ -110,7 +115,7 @@ export default class Line {
|
|
|
110
115
|
.line()
|
|
111
116
|
.x(xAccessor)
|
|
112
117
|
.y((d: SerieDataItem) => {
|
|
113
|
-
return yAccessor(d, ykey);
|
|
118
|
+
return yAccessor(d, ykey, serie.name);
|
|
114
119
|
})
|
|
115
120
|
.defined(definedAccessor)
|
|
116
121
|
.context(ctx);
|
package/src/tooltip.ts
CHANGED
|
@@ -68,6 +68,7 @@ export default class Tooltip {
|
|
|
68
68
|
eventPosition: EventPosition,
|
|
69
69
|
xScales: XScales,
|
|
70
70
|
yScales: YScales,
|
|
71
|
+
y2Scales: YScales,
|
|
71
72
|
cbk: (nearestPoints: Point[], nearestPoint: Point) => void,
|
|
72
73
|
forceTimestamp?: number
|
|
73
74
|
) {
|
|
@@ -81,6 +82,7 @@ export default class Tooltip {
|
|
|
81
82
|
oykey,
|
|
82
83
|
timestamp,
|
|
83
84
|
fillNull,
|
|
85
|
+
yAxis2,
|
|
84
86
|
} = this.options;
|
|
85
87
|
const offsetX = eventPosition.offsetX || eventPosition.layerX;
|
|
86
88
|
const offsetY = eventPosition.offsetY || eventPosition.layerY;
|
|
@@ -106,10 +108,14 @@ export default class Tooltip {
|
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
nearestPoints = tempNearestPoints.map((item: any) => {
|
|
111
|
+
const yScalesFunc =
|
|
112
|
+
yAxis2.visible && yAxis2.matchName && item.name === yAxis2.matchName
|
|
113
|
+
? y2Scales
|
|
114
|
+
: yScales;
|
|
109
115
|
return {
|
|
110
116
|
...item,
|
|
111
117
|
x: xScales(item.timestamp),
|
|
112
|
-
y:
|
|
118
|
+
y: yScalesFunc(item.value),
|
|
113
119
|
color: item.color || getColor(colors, item.serieIndex),
|
|
114
120
|
};
|
|
115
121
|
});
|
|
@@ -163,13 +169,14 @@ export default class Tooltip {
|
|
|
163
169
|
crosshairX?: number,
|
|
164
170
|
crosshairY?: number
|
|
165
171
|
) {
|
|
166
|
-
const { xScales, yScales, yAxis, options } = instance;
|
|
172
|
+
const { xScales, yScales, y2Scales, yAxis, options } = instance;
|
|
167
173
|
const cascadeMode = options?.tooltip?.cascadeMode;
|
|
168
174
|
this.isMouserover = true;
|
|
169
175
|
this.getNearestPoints(
|
|
170
176
|
eventPosition,
|
|
171
177
|
xScales,
|
|
172
178
|
yScales,
|
|
179
|
+
y2Scales,
|
|
173
180
|
(nearestPoints, nearestPoint) => {
|
|
174
181
|
this.clear();
|
|
175
182
|
this.drawCrosshair(eventPosition, crosshairX, crosshairY);
|
package/src/utils.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as d3 from "d3";
|
|
2
|
-
import { max, pickBy } from "lodash";
|
|
2
|
+
import { max, pickBy, map, find } from "lodash";
|
|
3
3
|
import {
|
|
4
4
|
Timestamp,
|
|
5
5
|
Options,
|
|
6
6
|
XScales,
|
|
7
7
|
YScales,
|
|
8
8
|
NearestPoint,
|
|
9
|
+
Serie,
|
|
10
|
+
SerieDataItem,
|
|
9
11
|
} from "./interface";
|
|
12
|
+
|
|
10
13
|
import getNearestPoints from "./getNearestPoints";
|
|
11
14
|
|
|
12
15
|
type Point = {
|
package/src/xAxis.ts
CHANGED
|
@@ -2,19 +2,23 @@ import * as d3 from "d3";
|
|
|
2
2
|
import { getMsTs } from "./utils";
|
|
3
3
|
import { Options, XScales } from "./interface";
|
|
4
4
|
import YAxis from "./yAxis";
|
|
5
|
+
import Y2Axis from "./yAxis2";
|
|
5
6
|
|
|
6
7
|
export default class XAxis {
|
|
7
8
|
options: Options;
|
|
8
9
|
ctx: CanvasRenderingContext2D;
|
|
9
10
|
yAxis: YAxis;
|
|
11
|
+
y2Axis: Y2Axis;
|
|
10
12
|
constructor(
|
|
11
13
|
userOptions: Options,
|
|
12
14
|
ctx: CanvasRenderingContext2D,
|
|
13
|
-
yAxis: YAxis
|
|
15
|
+
yAxis: YAxis,
|
|
16
|
+
y2Axis: Y2Axis
|
|
14
17
|
) {
|
|
15
18
|
this.options = userOptions;
|
|
16
19
|
this.ctx = ctx;
|
|
17
20
|
this.yAxis = yAxis;
|
|
21
|
+
this.y2Axis = y2Axis;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
init() {
|
|
@@ -25,9 +29,13 @@ export default class XAxis {
|
|
|
25
29
|
xmax,
|
|
26
30
|
xAxis,
|
|
27
31
|
} = this.options;
|
|
32
|
+
const y2AxisTickMaxWidth = this.y2Axis?.tickMaxWidth || 0;
|
|
28
33
|
const xScales = d3
|
|
29
34
|
.scaleTime()
|
|
30
|
-
.range([
|
|
35
|
+
.range([
|
|
36
|
+
xAxis.visible ? this.yAxis.tickMaxWidth : 0,
|
|
37
|
+
width - y2AxisTickMaxWidth,
|
|
38
|
+
]);
|
|
31
39
|
|
|
32
40
|
xScales.domain([
|
|
33
41
|
getMsTs(xmin, timestamp) - (xmin === xmax ? 1000 : 0),
|
|
@@ -62,7 +70,7 @@ export default class XAxis {
|
|
|
62
70
|
|
|
63
71
|
// draw line
|
|
64
72
|
ctx.beginPath();
|
|
65
|
-
ctx.moveTo(
|
|
73
|
+
ctx.moveTo(this.yAxis.tickMaxWidth, tickBottom - xAxis.tickLength);
|
|
66
74
|
ctx.lineTo(chart.width, tickBottom - xAxis.tickLength);
|
|
67
75
|
ctx.lineWidth = 1;
|
|
68
76
|
ctx.strokeStyle = xAxis.lineColor;
|
package/src/yAxis.ts
CHANGED
|
@@ -3,10 +3,6 @@ import { map, floor } from "lodash";
|
|
|
3
3
|
import { Options, YScales } from "./interface";
|
|
4
4
|
import { shortUint, getMaxWidthByYAxisTicks } from "./utils";
|
|
5
5
|
|
|
6
|
-
interface RealData {
|
|
7
|
-
[index: string]: any;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
6
|
export default class YAxis {
|
|
11
7
|
options: Options;
|
|
12
8
|
ctx: CanvasRenderingContext2D;
|
|
@@ -40,38 +36,6 @@ export default class YAxis {
|
|
|
40
36
|
return yScales;
|
|
41
37
|
}
|
|
42
38
|
|
|
43
|
-
/**
|
|
44
|
-
* 返回真实的数据,其中包含 plotLines
|
|
45
|
-
* @param {Array} data [description]
|
|
46
|
-
* @return {Array} [description]
|
|
47
|
-
*/
|
|
48
|
-
getRealData(data: RealData) {
|
|
49
|
-
const {
|
|
50
|
-
yAxis: { plotLines },
|
|
51
|
-
ykey,
|
|
52
|
-
fillNull,
|
|
53
|
-
} = this.options;
|
|
54
|
-
|
|
55
|
-
if (Array.isArray(data)) {
|
|
56
|
-
if (Array.isArray(plotLines)) {
|
|
57
|
-
plotLines.forEach((plotLine) => {
|
|
58
|
-
if (typeof plotLine.value === "number") {
|
|
59
|
-
data.push({
|
|
60
|
-
[ykey]: plotLine.value,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if (typeof fillNull === "number") {
|
|
66
|
-
data.push({
|
|
67
|
-
[ykey]: fillNull,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return data;
|
|
71
|
-
}
|
|
72
|
-
return [];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
39
|
getPlotLinesMaxAbs() {
|
|
76
40
|
const {
|
|
77
41
|
yAxis: { plotLines },
|
|
@@ -187,7 +151,7 @@ export default class YAxis {
|
|
|
187
151
|
ctx.beginPath();
|
|
188
152
|
this.ticks.forEach((d) => {
|
|
189
153
|
const yValue = yScales(d);
|
|
190
|
-
ctx.moveTo(
|
|
154
|
+
ctx.moveTo(this.tickMaxWidth, yValue);
|
|
191
155
|
ctx.lineTo(chart.width, yValue);
|
|
192
156
|
});
|
|
193
157
|
ctx.lineWidth = 1;
|
package/src/yAxis2.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import * as d3 from "d3";
|
|
2
|
+
import { map, floor } from "lodash";
|
|
3
|
+
import { Options, YScales } from "./interface";
|
|
4
|
+
import { shortUint, getMaxWidthByYAxisTicks } from "./utils";
|
|
5
|
+
|
|
6
|
+
export default class YAxis {
|
|
7
|
+
options: Options;
|
|
8
|
+
ctx: CanvasRenderingContext2D;
|
|
9
|
+
tickLength: number;
|
|
10
|
+
ticks: number[];
|
|
11
|
+
tickMaxWidth: number; // 刻度文字最大宽度
|
|
12
|
+
|
|
13
|
+
constructor(userOptions: Options, ctx: CanvasRenderingContext2D) {
|
|
14
|
+
this.options = userOptions;
|
|
15
|
+
const { yAxis } = userOptions;
|
|
16
|
+
ctx.font = `${yAxis.labels.fontSize}px Palantino`;
|
|
17
|
+
this.ctx = ctx;
|
|
18
|
+
this.tickLength = Math.floor(userOptions.chart.height / 50);
|
|
19
|
+
this.ticks = [];
|
|
20
|
+
this.tickMaxWidth = 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
init() {
|
|
24
|
+
const { chart, xAxis, yAxis } = this.options;
|
|
25
|
+
let scale = d3.scaleLinear();
|
|
26
|
+
if (yAxis.scale && yAxis.scale.type === "log") {
|
|
27
|
+
scale = d3.scaleLog().base(yAxis.scale.log || 10);
|
|
28
|
+
}
|
|
29
|
+
const yScales = scale.range([
|
|
30
|
+
chart.height -
|
|
31
|
+
(xAxis.labels.fontSize + xAxis.tickpadding + xAxis.tickLength),
|
|
32
|
+
10,
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
this.setDomain(yScales, this.options);
|
|
36
|
+
return yScales;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getPlotLinesMaxAbs() {
|
|
40
|
+
const {
|
|
41
|
+
yAxis: { plotLines },
|
|
42
|
+
} = this.options;
|
|
43
|
+
let maxAbs: undefined | number;
|
|
44
|
+
if (Array.isArray(plotLines)) {
|
|
45
|
+
plotLines.forEach((plotLine) => {
|
|
46
|
+
if (!maxAbs || Math.abs(maxAbs) < Math.abs(plotLine.value)) {
|
|
47
|
+
maxAbs = plotLine.value;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return maxAbs;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setDomain(
|
|
55
|
+
yScales: YScales,
|
|
56
|
+
{ y2min, y2max }: { y2min: number; y2max: number }
|
|
57
|
+
) {
|
|
58
|
+
const { options } = this;
|
|
59
|
+
const { yAxis, yAxis2 } = options;
|
|
60
|
+
let realTickLength = this.tickLength;
|
|
61
|
+
|
|
62
|
+
// TODO: 只有在唯一值不为 0 的时候才做居中处理
|
|
63
|
+
if (y2min === y2max && y2min !== 0) {
|
|
64
|
+
const increment = (y2max - y2min) / (this.tickLength - 1);
|
|
65
|
+
const halfIncrement = increment / 2 || y2max || 1;
|
|
66
|
+
realTickLength = increment === 0 ? 1 : this.tickLength;
|
|
67
|
+
|
|
68
|
+
y2min -= halfIncrement;
|
|
69
|
+
y2max += halfIncrement;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (y2min > y2max) {
|
|
73
|
+
const cachemin = y2min;
|
|
74
|
+
y2min = y2max;
|
|
75
|
+
y2max = cachemin;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 开了固定显示 plotLines 或是单一值的时候,需要计算出最大的 plotLines 的绝对值
|
|
79
|
+
if (yAxis.plotLinesFixed || y2min === y2max) {
|
|
80
|
+
const plotLinesMaxAbs = this.getPlotLinesMaxAbs();
|
|
81
|
+
if (plotLinesMaxAbs) {
|
|
82
|
+
if (plotLinesMaxAbs < y2min) {
|
|
83
|
+
y2min = plotLinesMaxAbs;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (plotLinesMaxAbs > y2max) {
|
|
87
|
+
y2max = plotLinesMaxAbs;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let ticks = [];
|
|
93
|
+
|
|
94
|
+
// 如果用户设置了 min 或者 max,则不用默认的 tick 计算
|
|
95
|
+
if (typeof yAxis.min === "number" || typeof yAxis.max === "number") {
|
|
96
|
+
const realMin = typeof yAxis.min === "number" ? yAxis.min : y2min;
|
|
97
|
+
const realMax = typeof yAxis.max === "number" ? yAxis.max : y2max;
|
|
98
|
+
|
|
99
|
+
yScales.domain([realMin, realMax]);
|
|
100
|
+
if (typeof yAxis.min === "number" && yAxis.min > realMax) {
|
|
101
|
+
ticks = [yAxis.min];
|
|
102
|
+
} else if (typeof yAxis.max === "number" && yAxis.max < realMin) {
|
|
103
|
+
ticks = [yAxis.max];
|
|
104
|
+
} else {
|
|
105
|
+
const step = d3.tickStep(realMin, realMax, realTickLength);
|
|
106
|
+
ticks = map(d3.range(realMin, realMax, step), (d: number) => {
|
|
107
|
+
return floor(d, 2);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
yScales.domain([y2min, y2max]);
|
|
112
|
+
yScales.nice(realTickLength);
|
|
113
|
+
ticks = yScales.ticks(realTickLength);
|
|
114
|
+
}
|
|
115
|
+
const yAxisTickMaxWidth =
|
|
116
|
+
getMaxWidthByYAxisTicks(ticks, this.ctx, yAxis2.tickValueFormatter) + 10;
|
|
117
|
+
this.ticks = ticks;
|
|
118
|
+
this.tickMaxWidth = yAxisTickMaxWidth;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
draw(yScales: YScales) {
|
|
122
|
+
const { ctx, options } = this;
|
|
123
|
+
const { yAxis, chart } = options;
|
|
124
|
+
|
|
125
|
+
// draw background 用于遮挡 gridline
|
|
126
|
+
ctx.beginPath();
|
|
127
|
+
ctx.fillStyle = yAxis.backgroundColor || "#fff";
|
|
128
|
+
ctx.fillRect(
|
|
129
|
+
chart.width - this.tickMaxWidth,
|
|
130
|
+
0,
|
|
131
|
+
this.tickMaxWidth,
|
|
132
|
+
chart.height - 12
|
|
133
|
+
);
|
|
134
|
+
ctx.stroke();
|
|
135
|
+
ctx.closePath();
|
|
136
|
+
|
|
137
|
+
// draw labels
|
|
138
|
+
ctx.textAlign = "right";
|
|
139
|
+
ctx.textBaseline = "middle";
|
|
140
|
+
ctx.strokeStyle = yAxis.labels.color;
|
|
141
|
+
ctx.lineWidth = 1;
|
|
142
|
+
ctx.fillStyle = yAxis.labels.color;
|
|
143
|
+
this.ticks.forEach((d) => {
|
|
144
|
+
let text;
|
|
145
|
+
if (typeof yAxis.tickValueFormatter === "function") {
|
|
146
|
+
text = yAxis.tickValueFormatter(d);
|
|
147
|
+
} else {
|
|
148
|
+
text = shortUint(d);
|
|
149
|
+
}
|
|
150
|
+
const y = yScales(d);
|
|
151
|
+
ctx.fillText(text, chart.width - 5, y);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|