UNPKG

maxlinekchart

Version:

Lightweight k-line chart built with html5 canvas

7 lines 223 kB
/** * @license * KLineChart v10.0.0-alpha9 * Copyright (c) 2019 lihu. * Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0 */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).klinecharts={})}(this,(function(t){"use strict";function e(t,r){if(o(t)||o(r))for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n)){var a=t[n],l=r[n];o(l)&&o(a)?e(a,l):s(r[n])&&(t[n]=i(r[n]))}}function i(t){if(!o(t))return t;var e=null;for(var n in e=r(t)?[]:{},t)if(Object.prototype.hasOwnProperty.call(t,n)){var a=t[n];o(a)?e[n]=i(a):e[n]=a}return e}function r(t){return"[object Array]"===Object.prototype.toString.call(t)}function n(t){return"function"==typeof t}function o(t){return"object"==typeof t&&s(t)}function a(t){return"number"==typeof t&&Number.isFinite(t)}function s(t){return null!=t}function l(t){return"boolean"==typeof t}function u(t){return"string"==typeof t}var c=/\\(\\)?/g,h=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");function d(t,e,i){if(s(t)){var r=[];e.replace(h,(function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=t;return s(e[1])?n=e[2].replace(c,"$1"):s(e[0])&&(n=e[0].trim()),r.push(n),""}));for(var n=t,o=0,a=r.length;s(n)&&o<a;)n=null==n?void 0:n[r[o++]];return s(n)?n:null!=i?i:"--"}return null!=i?i:"--"}function g(t,e,i){var r=function(t,e){var i={};return t.formatToParts(new Date(e)).forEach((function(t){var e=t.type,r=t.value;switch(e){case"year":i.YYYY=r;break;case"month":i.MM=r;break;case"day":i.DD=r;break;case"hour":i.HH="24"===r?"00":r;break;case"minute":i.mm=r;break;case"second":i.ss=r}})),i}(t,e);return i.replace(/YYYY|MM|DD|HH|mm|ss/g,(function(t){return r[t]}))}function p(t,e){var i=+t;return a(i)?i.toFixed(null!=e?e:2):"".concat(t)}function v(t){var e=+t;if(a(e)){if(e>1e9)return"".concat(+(e/1e9).toFixed(3),"B");if(e>1e6)return"".concat(+(e/1e6).toFixed(3),"M");if(e>1e3)return"".concat(+(e/1e3).toFixed(3),"K")}return"".concat(t)}function f(t,e){var i="".concat(t);if(0===e.length)return i;if(i.includes(".")){var r=i.split(".");return"".concat(r[0].replace(/(\d)(?=(\d{3})+$)/g,(function(t){return"".concat(t).concat(e)})),".").concat(r[1])}return i.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return"".concat(t).concat(e)}))}function y(t,e){var i="".concat(t);if(new RegExp("\\.0{"+e+",}[1-9][0-9]*$").test(i)){var r=i.split("."),n=r.length-1,o=r[n],a=/0*/.exec(o);if(s(a)){var l=a[0].length;return r[n]=o.replace(/0*/,"0{".concat(l,"}")),r.join(".")}}return i}function m(t,e){return t.replace(/\{(\w+)\}/g,(function(t,i){var r=e[i];return s(r)?r:"{".concat(i,"}")}))}var _=null;function x(t){var e,i;return null!==(i=null===(e=t.ownerDocument.defaultView)||void 0===e?void 0:e.devicePixelRatio)&&void 0!==i?i:1}function M(t,e,i){return"".concat(null!=e?e:"normal"," ").concat(null!=t?t:12,"px ").concat(null!=i?i:"Helvetica Neue")}function C(t,e,i,r){if(!s(_)){var n=document.createElement("canvas"),o=x(n);(_=n.getContext("2d")).scale(o,o)}return _.font=M(e,i,r),Math.round(_.measureText(t).width)}var T=function(t,e){return T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},T(t,e)};function E(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}T(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var w=function(){return w=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},w.apply(this,arguments)};function b(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]])}return i}function I(t,e,i,r){return new(i||(i=Promise))((function(n,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,s)}l((r=r.apply(t,e||[])).next())}))}function S(t,e){var i,r,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(i=1,r&&(n=2&s[0]?r.return:s[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;switch(r=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){o.label=s[1];break}if(6===s[0]&&o.label<n[1]){o.label=n[1],n=s;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(s);break}n[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{i=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function D(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],r=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function P(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var r,n,o=i.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return a}function A(t,e,i){if(i||2===arguments.length)for(var r,n=0,o=e.length;n<o;n++)!r&&n in e||(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))}function k(t){var i={width:0,height:0,left:0,right:0,top:0,bottom:0};return s(t)&&e(i,t),i}"function"==typeof SuppressedError&&SuppressedError;function L(t){return n(window.requestAnimationFrame)?window.requestAnimationFrame(t):window.setTimeout(t,20)}function N(t){n(window.cancelAnimationFrame)?window.cancelAnimationFrame(t):window.clearTimeout(t)}var O=function(){function t(t){this._options={duration:500,iterationCount:1},this._currentIterationCount=0,this._running=!1,this._time=0,e(this._options,t)}return t.prototype._loop=function(){var t=this;this._running=!0;var e=function(){var i;if(t._running){var r=(new Date).getTime()-t._time;r<t._options.duration?(null===(i=t._doFrameCallback)||void 0===i||i.call(t,r),L(e)):(t.stop(),t._currentIterationCount++,t._currentIterationCount<t._options.iterationCount&&t.start())}};L(e)},t.prototype.doFrame=function(t){return this._doFrameCallback=t,this},t.prototype.setDuration=function(t){return this._options.duration=t,this},t.prototype.setIterationCount=function(t){return this._options.iterationCount=t,this},t.prototype.start=function(){this._running||(this._time=(new Date).getTime(),this._loop())},t.prototype.stop=function(){var t;this._running&&(null===(t=this._doFrameCallback)||void 0===t||t.call(this,this._options.duration)),this._running=!1},t}(),F=1,B=(new Date).getTime();function R(t){var e=(new Date).getTime();return e===B?++F:F=1,B=e,"".concat(null!=t?t:"").concat(e,"_").concat(F)}function z(t,e){var i,r=document.createElement(t),n=null!=e?e:{};for(var o in n)r.style[o]=null!==(i=n[o])&&void 0!==i?i:"";return r}function j(t,e,i){var r=0,n=0;for(n=t.length-1;r!==n;){var o=Math.floor((n+r)/2),a=n-r,s=t[o][e];if(i===t[r][e])return r;if(i===t[n][e])return n;if(i===s)return o;if(i>s?r=o:n=o,a<=2)break}return r}function Y(t,e){e=Math.max(0,null!=e?e:0);var i=Math.pow(10,e);return Math.round(t*i)/i}function W(t,e,i){for(var r,n,o=[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],a=t.length,s=0;s<a;){var l=t[s];o[0]=Math.max(null!==(r=l[e])&&void 0!==r?r:Number.MIN_SAFE_INTEGER,o[0]),o[1]=Math.min(null!==(n=l[i])&&void 0!==n?n:Number.MAX_SAFE_INTEGER,o[1]),++s}return o}function V(t){return 0===t?0:Math.log10(t)}function H(t){return Math.pow(10,t)}function U(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.join("_")}var G=function(){function t(t){this._running=0,this._queue=[],this._taskMap=new Map,this._limit=null!=t?t:5}return t.prototype.add=function(t){return I(this,void 0,void 0,(function(){var e=this;return S(this,(function(i){switch(i.label){case 0:return[4,new Promise((function(i,r){var n=t.id,o=t.handler,a=function(){e._running++,o().then((function(t){i(t)})).catch((function(){r("failed")})).finally((function(){e._running--,e._taskMap.delete(n),e._next()}))},l=e._taskMap.get(n);if(s(l)){l.reject("canceled");var u=e._queue.indexOf(l.run);u>-1&&e._queue.splice(u,1)}e._taskMap.set(n,{run:a,reject:r}),e._queue.push(a),e._next()}))];case 1:return[2,i.sent()]}}))}))},t.prototype._next=function(){for(;this._running<this._limit&&this._queue.length>0;){var t=this._queue.shift();null==t||t()}},t.prototype.remove=function(t){var e=this._taskMap.get(t);if(s(e)){this._taskMap.delete(t);var i=this._queue.indexOf(e.run);i>-1&&this._queue.splice(i,1),e.reject("canceled")}},t.prototype.clear=function(){var t,e;try{for(var i=D(this._taskMap),r=i.next();!r.done;r=i.next()){(0,P(r.value,2)[1].reject)("canceled")}}catch(e){t={error:e}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}this._taskMap.clear(),this._queue=[]},t}(),Q=2,X=0,Z=function(){function t(){this._callbacks=[]}return t.prototype.subscribe=function(t){this._callbacks.indexOf(t)<0&&this._callbacks.push(t)},t.prototype.unsubscribe=function(t){if(n(t)){var e=this._callbacks.indexOf(t);e>-1&&this._callbacks.splice(e,1)}else this._callbacks=[]},t.prototype.execute=function(t){this._callbacks.forEach((function(e){e(t)}))},t.prototype.isEmpty=function(){return 0===this._callbacks.length},t}();function q(t){return"transparent"===t||"none"===t||/^[rR][gG][Bb][Aa]\(([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\s]*,){3}[\s]*0[\s]*\)$/.test(t)||/^[hH][Ss][Ll][Aa]\(([\s]*(360|3[0-5][0-9]|[012]?[0-9][0-9]?)[\s]*,)([\s]*((100|[0-9][0-9]?)%|0)[\s]*,){2}([\s]*0[\s]*)\)$/.test(t)}function J(t,e){var i=t.replace(/^#/,""),r=parseInt(i,16),n=r>>8&255,o=255&r;return"rgba(".concat(r>>16&255,", ").concat(n,", ").concat(o,", ").concat(null!=e?e:1,")")}var K={RED:"#F92855",GREEN:"#2DC08E",WHITE:"#FFFFFF",GREY:"#76808F",BLUE:"#1677FF"};function $(){return{show:!0,size:"auto",axisLine:{show:!0,color:"#DDDDDD",size:1},tickText:{show:!0,color:K.GREY,size:12,family:"Helvetica Neue",weight:"normal",marginStart:4,marginEnd:6},tickLine:{show:!0,size:1,length:3,color:"#DDDDDD"}}}function tt(t,e,i,r){var n,o=t.result,a=t.figures,l=t.styles,u=d(l,"circles",i.circles),c=u.length,h=d(l,"bars",i.bars),g=h.length,p=d(l,"lines",i.lines),v=p.length,f=0,y=0,m=0,_=0;a.forEach((function(a){var l,d,x,M;switch(a.type){case"circle":_=f;var C=u[f%c];n=w(w({},C),{color:C.noChangeColor}),f++;break;case"bar":_=y;var T=h[y%g];n=w(w({},T),{color:T.noChangeColor}),y++;break;case"line":_=m,n=p[m%v],m++}if(s(a.type)){var E=null===(l=a.styles)||void 0===l?void 0:l.call(a,{data:{prev:o[null!==(d=e.prev)&&void 0!==d?d:""],current:o[null!==(x=e.current)&&void 0!==x?x:""],next:o[null!==(M=e.next)&&void 0!==M?M:""]},indicator:t,defaultStyles:i});r(a,w(w({},n),E),_)}}))}var et=function(){function t(t){this.precision=4,this.calcParams=[],this.shouldOhlc=!1,this.shouldFormatBigNumber=!1,this.visible=!0,this.zLevel=0,this.series="normal",this.figures=[],this.minValue=null,this.maxValue=null,this.styles=null,this.shouldUpdate=function(t,e){var i=JSON.stringify(t.calcParams)!==JSON.stringify(e.calcParams)||t.figures!==e.figures||t.calc!==e.calc;return{calc:i,draw:i||t.shortName!==e.shortName||t.series!==e.series||t.minValue!==e.minValue||t.maxValue!==e.maxValue||t.precision!==e.precision||t.shouldOhlc!==e.shouldOhlc||t.shouldFormatBigNumber!==e.shouldFormatBigNumber||t.visible!==e.visible||t.zLevel!==e.zLevel||t.extendData!==e.extendData||t.regenerateFigures!==e.regenerateFigures||t.createTooltipDataSource!==e.createTooltipDataSource||t.draw!==e.draw}},this.calc=function(){return{}},this.regenerateFigures=null,this.createTooltipDataSource=null,this.draw=null,this.onDataStateChange=null,this.result={},this._lockSeriesPrecision=!1,this.override(t),this._lockSeriesPrecision=!1}return t.prototype.override=function(t){var r,o,l=this.result,c=b(this,["result"]);this._prevIndicator=w(w({},i(c)),{result:l});var h=t.id,d=t.name,g=t.shortName,p=t.precision,v=t.styles,f=t.figures,y=t.calcParams,m=b(t,["id","name","shortName","precision","styles","figures","calcParams"]);!u(this.id)&&u(h)&&(this.id=h),u(this.name)||(this.name=null!=d?d:""),this.shortName=null!==(r=null!=g?g:this.shortName)&&void 0!==r?r:this.name,a(p)&&(this.precision=p,this._lockSeriesPrecision=!0),s(v)&&(null!==(o=this.styles)&&void 0!==o||(this.styles={}),e(this.styles,v)),e(this,m),s(y)&&(this.calcParams=y,n(this.regenerateFigures)&&(this.figures=this.regenerateFigures(this.calcParams))),this.figures=null!=f?f:this.figures},t.prototype.setSeriesPrecision=function(t){this._lockSeriesPrecision||(this.precision=t)},t.prototype.shouldUpdateImp=function(){var t=this._prevIndicator.zLevel!==this.zLevel,e=this.shouldUpdate(this._prevIndicator,this);return l(e)?{calc:e,draw:e,sort:t}:w(w({},e),{sort:t})},t.prototype.calcImp=function(t){return I(this,void 0,void 0,(function(){var e;return S(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.calc(t,this)];case 1:return e=i.sent(),this.result=e,[2,!0];case 2:return i.sent(),[2,!1];case 3:return[2]}}))}))},t.extend=function(e){return function(t){function i(){return t.call(this,e)||this}return E(i,t),i}(t)},t}(),it={name:"AO",shortName:"AO",calcParams:[5,34],figures:[{key:"ao",title:"AO: ",type:"bar",baseValue:0,styles:function(t){var e,i,r=t.data,n=t.indicator,o=t.defaultStyles,a=r.prev,s=r.current,l=null!==(e=null==a?void 0:a.ao)&&void 0!==e?e:Number.MIN_SAFE_INTEGER,u=null!==(i=null==s?void 0:s.ao)&&void 0!==i?i:Number.MIN_SAFE_INTEGER,c="";return{color:c=u>l?d(n.styles,"bars[0].upColor",o.bars[0].upColor):d(n.styles,"bars[0].downColor",o.bars[0].downColor),style:u>l?"stroke":"fill",borderColor:c}}}],calc:function(t,e){var i=e.calcParams,r=Math.max(i[0],i[1]),n=0,o=0,a=0,s=0;return t.reduce((function(e,l,u){var c={},h=(l.low+l.high)/2;if(n+=h,o+=h,u>=i[0]-1){a=n/i[0];var d=t[u-(i[0]-1)];n-=(d.low+d.high)/2}if(u>=i[1]-1){s=o/i[1];d=t[u-(i[1]-1)];o-=(d.low+d.high)/2}return u>=r-1&&(c.ao=a-s),e[l.timestamp]=c,e}),{})}};var rt={name:"BOLL",shortName:"BOLL",series:"price",calcParams:[20,2],precision:2,shouldOhlc:!0,figures:[{key:"up",title:"UP: ",type:"line"},{key:"mid",title:"MID: ",type:"line"},{key:"dn",title:"DN: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=i[0]-1,n=0;return t.reduce((function(e,o,a){var s=o.close,l={};if(n+=s,a>=r){l.mid=n/i[0];var u=function(t,e){var i=t.length,r=0;return t.forEach((function(t){var i=t.close-e;r+=i*i})),r=Math.abs(r),Math.sqrt(r/i)}(t.slice(a-r,a+1),l.mid);l.up=l.mid+i[1]*u,l.dn=l.mid-i[1]*u,n-=t[a-r].close}return e[o.timestamp]=l,e}),{})}},nt={name:"BBI",shortName:"BBI",series:"price",precision:2,calcParams:[3,6,12,24],shouldOhlc:!0,figures:[{key:"bbi",title:"BBI: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=Math.max.apply(Math,A([],P(i),!1)),n=[],o=[];return t.reduce((function(e,a,s){var l={},u=a.close;if(i.forEach((function(e,i){var r;n[i]=(null!==(r=n[i])&&void 0!==r?r:0)+u,s>=e-1&&(o[i]=n[i]/e,n[i]-=t[s-(e-1)].close)})),s>=r-1){var c=0;o.forEach((function(t){c+=t})),l.bbi=c/4}return e[a.timestamp]=l,e}),{})}},ot={name:"CCI",shortName:"CCI",calcParams:[20],figures:[{key:"cci",title:"CCI: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=i[0]-1,n=0,o=[];return t.reduce((function(e,a,s){var l={},u=(a.high+a.low+a.close)/3;if(n+=u,o.push(u),s>=r){var c=n/i[0],h=o.slice(s-r,s+1),d=0;h.forEach((function(t){d+=Math.abs(t-c)}));var g=d/i[0];l.cci=0!==g?(u-c)/g/.015:0;var p=(t[s-r].high+t[s-r].low+t[s-r].close)/3;n-=p}return e[a.timestamp]=l,e}),{})}},at={name:"CR",shortName:"CR",calcParams:[26,10,20,40,60],figures:[{key:"cr",title:"CR: ",type:"line"},{key:"ma1",title:"MA1: ",type:"line"},{key:"ma2",title:"MA2: ",type:"line"},{key:"ma3",title:"MA3: ",type:"line"},{key:"ma4",title:"MA4: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=Math.ceil(i[1]/2.5+1),n=Math.ceil(i[2]/2.5+1),o=Math.ceil(i[3]/2.5+1),a=Math.ceil(i[4]/2.5+1),s=0,l=[],u=0,c=[],h=0,d=[],g=0,p=[],v=[],f={};return t.forEach((function(e,y){var m,_,x,M,C,T={},E=null!==(m=t[y-1])&&void 0!==m?m:e,w=(E.high+E.close+E.low+E.open)/4,b=Math.max(0,e.high-w),I=Math.max(0,w-e.low);y>=i[0]-1&&(T.cr=0!==I?b/I*100:0,s+=T.cr,u+=T.cr,h+=T.cr,g+=T.cr,y>=i[0]+i[1]-2&&(l.push(s/i[1]),y>=i[0]+i[1]+r-3&&(T.ma1=l[l.length-1-r]),s-=null!==(_=v[y-(i[1]-1)].cr)&&void 0!==_?_:0),y>=i[0]+i[2]-2&&(c.push(u/i[2]),y>=i[0]+i[2]+n-3&&(T.ma2=c[c.length-1-n]),u-=null!==(x=v[y-(i[2]-1)].cr)&&void 0!==x?x:0),y>=i[0]+i[3]-2&&(d.push(h/i[3]),y>=i[0]+i[3]+o-3&&(T.ma3=d[d.length-1-o]),h-=null!==(M=v[y-(i[3]-1)].cr)&&void 0!==M?M:0),y>=i[0]+i[4]-2&&(p.push(g/i[4]),y>=i[0]+i[4]+a-3&&(T.ma4=p[p.length-1-a]),g-=null!==(C=v[y-(i[4]-1)].cr)&&void 0!==C?C:0)),v.push(T),f[e.timestamp]=T})),f}},st={name:"DMA",shortName:"DMA",calcParams:[10,50,10],figures:[{key:"dma",title:"DMA: ",type:"line"},{key:"ama",title:"AMA: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=Math.max(i[0],i[1]),n=0,o=0,a=0,s=[],l={};return t.forEach((function(e,u){var c,h={},d=e.close;n+=d,o+=d;var g=0,p=0;if(u>=i[0]-1&&(g=n/i[0],n-=t[u-(i[0]-1)].close),u>=i[1]-1&&(p=o/i[1],o-=t[u-(i[1]-1)].close),u>=r-1){var v=g-p;h.dma=v,a+=v,u>=r+i[2]-2&&(h.ama=a/i[2],a-=null!==(c=s[u-(i[2]-1)].dma)&&void 0!==c?c:0)}s.push(h),l[e.timestamp]=h})),l}},lt={name:"DMI",shortName:"DMI",calcParams:[14,6],figures:[{key:"pdi",title:"PDI: ",type:"line"},{key:"mdi",title:"MDI: ",type:"line"},{key:"adx",title:"ADX: ",type:"line"},{key:"adxr",title:"ADXR: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=0,a=0,s=0,l=0,u=0,c=0,h=[],d={};return t.forEach((function(e,g){var p,v,f={},y=null!==(p=t[g-1])&&void 0!==p?p:e,m=y.close,_=e.high,x=e.low,M=_-x,C=Math.abs(_-m),T=Math.abs(m-x),E=_-y.high,w=y.low-x,b=Math.max(Math.max(M,C),T),I=E>0&&E>w?E:0,S=w>0&&w>E?w:0;if(r+=b,n+=I,o+=S,g>=i[0]-1){g>i[0]-1?(a=a-a/i[0]+b,s=s-s/i[0]+I,l=l-l/i[0]+S):(a=r,s=n,l=o);var D=0,P=0;0!==a&&(D=100*s/a,P=100*l/a),f.pdi=D,f.mdi=P;var A=0;P+D!==0&&(A=Math.abs(P-D)/(P+D)*100),u+=A,g>=2*i[0]-2&&(c=g>2*i[0]-2?(c*(i[0]-1)+A)/i[0]:u/i[0],f.adx=c,g>=2*i[0]+i[1]-3&&(f.adxr=((null!==(v=h[g-(i[1]-1)].adx)&&void 0!==v?v:0)+c)/2))}h.push(f),d[e.timestamp]=f})),d}},ut={name:"MACD",shortName:"MACD",calcParams:[12,26,9],figures:[{key:"dif",title:"DIF: ",type:"line"},{key:"dea",title:"DEA: ",type:"line"},{key:"macd",title:"MACD: ",type:"bar",baseValue:0,styles:function(t){var e,i,r=t.data,n=t.indicator,o=t.defaultStyles,a=r.prev,s=r.current,l=null!==(e=null==a?void 0:a.macd)&&void 0!==e?e:Number.MIN_SAFE_INTEGER,u=null!==(i=null==s?void 0:s.macd)&&void 0!==i?i:Number.MIN_SAFE_INTEGER,c="";return{style:l<u?"stroke":"fill",color:c=u>0?d(n.styles,"bars[0].upColor",o.bars[0].upColor):u<0?d(n.styles,"bars[0].downColor",o.bars[0].downColor):d(n.styles,"bars[0].noChangeColor",o.bars[0].noChangeColor),borderColor:c}}}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=0,a=0,s=0,l=0,u=Math.max(i[0],i[1]);return t.reduce((function(t,e,c){var h={},d=e.close;return r+=d,c>=i[0]-1&&(n=c>i[0]-1?(2*d+(i[0]-1)*n)/(i[0]+1):r/i[0]),c>=i[1]-1&&(o=c>i[1]-1?(2*d+(i[1]-1)*o)/(i[1]+1):r/i[1]),c>=u-1&&(a=n-o,h.dif=a,s+=a,c>=u+i[2]-2&&(l=c>u+i[2]-2?(2*a+l*(i[2]-1))/(i[2]+1):s/i[2],h.macd=2*(a-l),h.dea=l)),t[e.timestamp]=h,t}),{})}},ct={name:"RSI",shortName:"RSI",calcParams:[6,12,24],figures:[{key:"rsi1",title:"RSI1: ",type:"line"},{key:"rsi2",title:"RSI2: ",type:"line"},{key:"rsi3",title:"RSI3: ",type:"line"}],regenerateFigures:function(t){return t.map((function(t,e){var i=e+1;return{key:"rsi".concat(i),title:"RSI".concat(i,": "),type:"line"}}))},calc:function(t,e){var i=e.calcParams,r=e.figures,n=[],o=[];return t.reduce((function(e,a,s){var l,u={},c=(null!==(l=t[s-1])&&void 0!==l?l:a).close,h=a.close-c;return i.forEach((function(e,i){var a,l,c;if(h>0?n[i]=(null!==(a=n[i])&&void 0!==a?a:0)+h:o[i]=(null!==(l=o[i])&&void 0!==l?l:0)+Math.abs(h),s>=e-1){0!==o[i]?u[r[i].key]=100-100/(1+n[i]/o[i]):u[r[i].key]=0;var d=t[s-(e-1)],g=null!==(c=t[s-e])&&void 0!==c?c:d,p=d.close-g.close;p>0?n[i]-=p:o[i]-=Math.abs(p)}})),e[a.timestamp]=u,e}),{})}},ht={name:"KDJ",shortName:"KDJ",calcParams:[9,3,3],figures:[{key:"k",title:"K: ",type:"line"},{key:"d",title:"D: ",type:"line"},{key:"j",title:"J: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=[],n={};return t.forEach((function(e,o){var a,s,l,u,c={},h=e.close;if(o>=i[0]-1){var d=W(t.slice(o-(i[0]-1),o+1),"high","low"),g=d[0],p=d[1],v=g-p,f=(h-p)/(0===v?1:v)*100;c.k=((i[1]-1)*(null!==(s=null===(a=r[o-1])||void 0===a?void 0:a.k)&&void 0!==s?s:50)+f)/i[1],c.d=((i[2]-1)*(null!==(u=null===(l=r[o-1])||void 0===l?void 0:l.d)&&void 0!==u?u:50)+c.k)/i[2],c.j=3*c.k-2*c.d}r.push(c),n[e.timestamp]=c})),n}},dt={name:"SAR",shortName:"SAR",series:"price",calcParams:[2,2,20],precision:2,shouldOhlc:!0,figures:[{key:"sar",title:"SAR: ",type:"circle",styles:function(t){var e,i,r,n=t.data,o=t.indicator,a=t.defaultStyles,s=n.current;return{color:(null!==(e=null==s?void 0:s.sar)&&void 0!==e?e:Number.MIN_SAFE_INTEGER)<((null!==(i=null==s?void 0:s.high)&&void 0!==i?i:0)+(null!==(r=null==s?void 0:s.low)&&void 0!==r?r:0))/2?d(o.styles,"circles[0].upColor",a.circles[0].upColor):d(o.styles,"circles[0].downColor",a.circles[0].downColor)}}}],calc:function(t,e){var i=e.calcParams,r=i[0]/100,n=i[1]/100,o=i[2]/100,a=r,s=-100,l=!1,u=0;return t.reduce((function(e,i,c){var h=u,d=i.high,g=i.low;if(l){(-100===s||s<d)&&(s=d,a=Math.min(a+n,o)),u=h+a*(s-h);var p=Math.min(t[Math.max(1,c)-1].low,g);u>i.low?(u=s,a=r,s=-100,l=!l):u>p&&(u=p)}else{(-100===s||s>g)&&(s=g,a=Math.min(a+n,o)),u=h+a*(s-h);var v=Math.max(t[Math.max(1,c)-1].high,d);u<i.high?(u=s,a=0,s=-100,l=!l):u<v&&(u=v)}return e[i.timestamp]={high:d,low:g,sar:u},e}),{})}};function gt(){return{key:"volume",title:"VOLUME: ",type:"bar",baseValue:0,styles:function(t){var e=t.data,i=t.indicator,r=t.defaultStyles,n=e.current,o=d(i.styles,"bars[0].noChangeColor",r.bars[0].noChangeColor);return s(n)&&(n.close>n.open?o=d(i.styles,"bars[0].upColor",r.bars[0].upColor):n.close<n.open&&(o=d(i.styles,"bars[0].downColor",r.bars[0].downColor))),{color:o}}}}var pt={name:"VOL",shortName:"VOL",series:"volume",calcParams:[5,10,20],shouldFormatBigNumber:!0,precision:0,minValue:0,figures:[{key:"ma1",title:"MA5: ",type:"line"},{key:"ma2",title:"MA10: ",type:"line"},{key:"ma3",title:"MA20: ",type:"line"},gt()],regenerateFigures:function(t){var e=t.map((function(t,e){return{key:"ma".concat(e+1),title:"MA".concat(t,": "),type:"line"}}));return e.push(gt()),e},calc:function(t,e){var i=e.calcParams,r=e.figures,n=[];return t.reduce((function(e,o,a){var s,l=null!==(s=o.volume)&&void 0!==s?s:0,u={volume:l,open:o.open,close:o.close};return i.forEach((function(e,i){var o,s;n[i]=(null!==(o=n[i])&&void 0!==o?o:0)+l,a>=e-1&&(u[r[i].key]=n[i]/e,n[i]-=null!==(s=t[a-(e-1)].volume)&&void 0!==s?s:0)})),e[o.timestamp]=u,e}),{})}},vt={name:"WR",shortName:"WR",calcParams:[6,10,14],figures:[{key:"wr1",title:"WR1: ",type:"line"},{key:"wr2",title:"WR2: ",type:"line"},{key:"wr3",title:"WR3: ",type:"line"}],regenerateFigures:function(t){return t.map((function(t,e){return{key:"wr".concat(e+1),title:"WR".concat(e+1,": "),type:"line"}}))},calc:function(t,e){var i=e.calcParams,r=e.figures;return t.reduce((function(e,n,o){var a={},s=n.close;return i.forEach((function(e,i){var n=e-1;if(o>=n){var l=W(t.slice(o-n,o+1),"high","low"),u=l[0],c=u-l[1];a[r[i].key]=0===c?0:(s-u)/c*100}})),e[n.timestamp]=a,e}),{})}},ft={},yt=[{name:"AVP",shortName:"AVP",series:"price",precision:2,figures:[{key:"avp",title:"AVP: ",type:"line"}],calc:function(t){var e=0,i=0;return t.reduce((function(t,r){var n,o,a={},s=null!==(n=r.turnover)&&void 0!==n?n:0,l=null!==(o=r.volume)&&void 0!==o?o:0;return e+=s,0!==(i+=l)&&(a.avp=e/i),t[r.timestamp]=a,t}),{})}},it,{name:"BIAS",shortName:"BIAS",calcParams:[6,12,24],figures:[{key:"bias1",title:"BIAS6: ",type:"line"},{key:"bias2",title:"BIAS12: ",type:"line"},{key:"bias3",title:"BIAS24: ",type:"line"}],regenerateFigures:function(t){return t.map((function(t,e){return{key:"bias".concat(e+1),title:"BIAS".concat(t,": "),type:"line"}}))},calc:function(t,e){var i=e.calcParams,r=e.figures,n=[];return t.reduce((function(e,o,a){var s={},l=o.close;return i.forEach((function(e,o){var u;if(n[o]=(null!==(u=n[o])&&void 0!==u?u:0)+l,a>=e-1){var c=n[o]/i[o];s[r[o].key]=(l-c)/c*100,n[o]-=t[a-(e-1)].close}})),e[o.timestamp]=s,e}),{})}},rt,{name:"BRAR",shortName:"BRAR",calcParams:[26],figures:[{key:"br",title:"BR: ",type:"line"},{key:"ar",title:"AR: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=0,a=0;return t.reduce((function(e,s,l){var u,c,h={},d=s.high,g=s.low,p=s.open,v=(null!==(u=t[l-1])&&void 0!==u?u:s).close;if(o+=d-p,a+=p-g,r+=d-v,n+=v-g,l>=i[0]-1){h.ar=0!==a?o/a*100:0,h.br=0!==n?r/n*100:0;var f=t[l-(i[0]-1)],y=f.high,m=f.low,_=f.open,x=(null!==(c=t[l-i[0]])&&void 0!==c?c:t[l-(i[0]-1)]).close;r-=y-x,n-=x-m,o-=y-_,a-=_-m}return e[s.timestamp]=h,e}),{})}},nt,ot,at,st,lt,{name:"EMV",shortName:"EMV",calcParams:[14,9],figures:[{key:"emv",title:"EMV: ",type:"line"},{key:"maEmv",title:"MAEMV: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=[];return t.reduce((function(e,o,a){var s,l={};if(a>0){var u=t[a-1],c=o.high,h=o.low,d=null!==(s=o.volume)&&void 0!==s?s:0,g=(c+h)/2-(u.high+u.low)/2;if(0===d||c-h==0)l.emv=0;else{var p=d/1e8/(c-h);l.emv=g/p}r+=l.emv,n.push(l.emv),a>=i[0]&&(l.maEmv=r/i[0],r-=n[a-i[0]])}return e[o.timestamp]=l,e}),{})}},{name:"EMA",shortName:"EMA",series:"price",calcParams:[6,12,20],precision:2,shouldOhlc:!0,figures:[{key:"ema1",title:"EMA6: ",type:"line"},{key:"ema2",title:"EMA12: ",type:"line"},{key:"ema3",title:"EMA20: ",type:"line"}],regenerateFigures:function(t){return t.map((function(t,e){return{key:"ema".concat(e+1),title:"EMA".concat(t,": "),type:"line"}}))},calc:function(t,e){var i=e.calcParams,r=e.figures,n=0,o=[];return t.reduce((function(t,e,a){var s={},l=e.close;return n+=l,i.forEach((function(t,e){a>=t-1&&(o[e]=a>t-1?(2*l+(t-1)*o[e])/(t+1):n/t,s[r[e].key]=o[e])})),t[e.timestamp]=s,t}),{})}},{name:"MTM",shortName:"MTM",calcParams:[12,6],figures:[{key:"mtm",title:"MTM: ",type:"line"},{key:"maMtm",title:"MAMTM: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=[],o={};return t.forEach((function(e,a){var s,l={};if(a>=i[0]){var u=e.close,c=t[a-i[0]].close;l.mtm=u-c,r+=l.mtm,a>=i[0]+i[1]-1&&(l.maMtm=r/i[1],r-=null!==(s=n[a-(i[1]-1)].mtm)&&void 0!==s?s:0)}n.push(l),o[e.timestamp]=l})),o}},{name:"MA",shortName:"MA",series:"price",calcParams:[5,10,30,60],precision:2,shouldOhlc:!0,figures:[{key:"ma1",title:"MA5: ",type:"line"},{key:"ma2",title:"MA10: ",type:"line"},{key:"ma3",title:"MA30: ",type:"line"},{key:"ma4",title:"MA60: ",type:"line"}],regenerateFigures:function(t){return t.map((function(t,e){return{key:"ma".concat(e+1),title:"MA".concat(t,": "),type:"line"}}))},calc:function(t,e){var i=e.calcParams,r=e.figures,n=[];return t.reduce((function(e,o,a){var s={},l=o.close;return i.forEach((function(e,i){var o;n[i]=(null!==(o=n[i])&&void 0!==o?o:0)+l,a>=e-1&&(s[r[i].key]=n[i]/e,n[i]-=t[a-(e-1)].close)})),e[o.timestamp]=s,e}),{})}},ut,{name:"OBV",shortName:"OBV",calcParams:[30],figures:[{key:"obv",title:"OBV: ",type:"line"},{key:"maObv",title:"MAOBV: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=[],a={};return t.forEach((function(e,s){var l,u,c,h,d=null!==(l=t[s-1])&&void 0!==l?l:e;e.close<d.close?n-=null!==(u=e.volume)&&void 0!==u?u:0:e.close>d.close&&(n+=null!==(c=e.volume)&&void 0!==c?c:0);var g={obv:n};r+=n,s>=i[0]-1&&(g.maObv=r/i[0],r-=null!==(h=o[s-(i[0]-1)].obv)&&void 0!==h?h:0),o.push(g),a[e.timestamp]=g})),a}},{name:"PVT",shortName:"PVT",figures:[{key:"pvt",title:"PVT: ",type:"line"}],calc:function(t){var e=0;return t.reduce((function(i,r,n){var o,a,s={},l=r.close,u=null!==(o=r.volume)&&void 0!==o?o:1,c=(null!==(a=t[n-1])&&void 0!==a?a:r).close,h=0,d=c*u;return 0!==d&&(h=(l-c)/d),e+=h,s.pvt=e,i[r.timestamp]=s,i}),{})}},{name:"PSY",shortName:"PSY",calcParams:[12,6],figures:[{key:"psy",title:"PSY: ",type:"line"},{key:"maPsy",title:"MAPSY: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=[],a=[],s={};return t.forEach((function(e,l){var u,c,h={},d=(null!==(u=t[l-1])&&void 0!==u?u:e).close,g=e.close-d>0?1:0;o.push(g),r+=g,l>=i[0]-1&&(h.psy=r/i[0]*100,n+=h.psy,l>=i[0]+i[1]-2&&(h.maPsy=n/i[1],n-=null!==(c=a[l-(i[1]-1)].psy)&&void 0!==c?c:0),r-=o[l-(i[0]-1)]),a.push(h),s[e.timestamp]=h})),s}},{name:"ROC",shortName:"ROC",calcParams:[12,6],figures:[{key:"roc",title:"ROC: ",type:"line"},{key:"maRoc",title:"MAROC: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=[],n={},o=0;return t.forEach((function(e,a){var s,l,u={};if(a>=i[0]-1){var c=e.close,h=(null!==(s=t[a-i[0]])&&void 0!==s?s:t[a-(i[0]-1)]).close;u.roc=0!==h?(c-h)/h*100:0,o+=u.roc,a>=i[0]-1+i[1]-1&&(u.maRoc=o/i[1],o-=null!==(l=r[a-(i[1]-1)].roc)&&void 0!==l?l:0)}r.push(u),n[e.timestamp]=u})),n}},ct,{name:"SMA",shortName:"SMA",series:"price",calcParams:[12,2],precision:2,figures:[{key:"sma",title:"SMA: ",type:"line"}],shouldOhlc:!0,calc:function(t,e){var i=e.calcParams,r=0,n=0;return t.reduce((function(t,e,o){var a={},s=e.close;return r+=s,o>=i[0]-1&&(n=o>i[0]-1?(s*i[1]+n*(i[0]-i[1]+1))/(i[0]+1):r/i[0],a.sma=n),t[e.timestamp]=a,t}),{})}},ht,dt,{name:"TRIX",shortName:"TRIX",calcParams:[12,9],figures:[{key:"trix",title:"TRIX: ",type:"line"},{key:"maTrix",title:"MATRIX: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=0,a=0,s=0,l=0,u=0,c=[],h={};return t.forEach((function(t,e){var d,g={},p=t.close;if(r+=p,e>=i[0]-1&&(n=e>i[0]-1?(2*p+(i[0]-1)*n)/(i[0]+1):r/i[0],s+=n,e>=2*i[0]-2&&(o=e>2*i[0]-2?(2*n+(i[0]-1)*o)/(i[0]+1):s/i[0],l+=o,e>=3*i[0]-3))){var v=0,f=0;e>3*i[0]-3?f=((v=(2*o+(i[0]-1)*a)/(i[0]+1))-a)/a*100:v=l/i[0],a=v,g.trix=f,u+=f,e>=3*i[0]+i[1]-4&&(g.maTrix=u/i[1],u-=null!==(d=c[e-(i[1]-1)].trix)&&void 0!==d?d:0)}c.push(g),h[t.timestamp]=g})),h}},pt,{name:"VR",shortName:"VR",calcParams:[26,6],figures:[{key:"vr",title:"VR: ",type:"line"},{key:"maVr",title:"MAVR: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=0,a=0,s=[],l={};return t.forEach((function(e,u){var c,h,d,g,p,v={},f=e.close,y=(null!==(c=t[u-1])&&void 0!==c?c:e).close,m=null!==(h=e.volume)&&void 0!==h?h:0;if(f>y?r+=m:f<y?n+=m:o+=m,u>=i[0]-1){var _=o/2;v.vr=n+_===0?0:(r+_)/(n+_)*100,a+=v.vr,u>=i[0]+i[1]-2&&(v.maVr=a/i[1],a-=null!==(d=s[u-(i[1]-1)].vr)&&void 0!==d?d:0);var x=t[u-(i[0]-1)],M=null!==(g=t[u-i[0]])&&void 0!==g?g:x,C=x.close,T=null!==(p=x.volume)&&void 0!==p?p:0;C>M.close?r-=T:C<M.close?n-=T:o-=T}s.push(v),l[e.timestamp]=v})),l}},vt];function mt(t){var e;return null!==(e=ft[t])&&void 0!==e?e:null}function _t(t,e){var i,r=null!==(i=null==e?void 0:e.ignoreEvent)&&void 0!==i&&i;return l(r)?!r:!r.includes(t)}yt.forEach((function(t){ft[t.name]=et.extend(t)}));var xt="overlay_figure_",Mt=function(){function t(t){this.groupId="",this.totalStep=1,this.currentStep=1,this.lock=!1,this.visible=!0,this.zLevel=0,this.needDefaultPointFigure=!1,this.needDefaultXAxisFigure=!1,this.needDefaultYAxisFigure=!1,this.mode="normal",this.modeSensitivity=8,this.points=[],this.styles=null,this.createPointFigures=null,this.createXAxisFigures=null,this.createYAxisFigures=null,this.performEventPressedMove=null,this.performEventMoveForDrawing=null,this.onDrawStart=null,this.onDrawing=null,this.onDrawEnd=null,this.onClick=null,this.onDoubleClick=null,this.onRightClick=null,this.onPressedMoveStart=null,this.onPressedMoving=null,this.onPressedMoveEnd=null,this.onMouseMove=null,this.onMouseEnter=null,this.onMouseLeave=null,this.onRemoved=null,this.onSelected=null,this.onDeselected=null,this._prevZLevel=0,this._prevPressedPoint=null,this._prevPressedPoints=[],this.override(t)}return t.prototype.override=function(t){var o,a;this._prevOverlay=i(this);var l=t.id,c=t.name;t.currentStep;var h=t.points,d=t.styles;if(e(this,b(t,["id","name","currentStep","points","styles"])),u(this.name)||(this.name=null!=c?c:""),!u(this.id)&&u(l)&&(this.id=l),s(d)&&(null!==(o=this.styles)&&void 0!==o||(this.styles={}),e(this.styles,d)),r(h)&&h.length>0){var g=0;if(this.points=A([],P(h),!1),h.length>=this.totalStep-1?(this.currentStep=-1,g=this.totalStep-1):(this.currentStep=h.length+1,g=h.length),n(this.performEventMoveForDrawing))for(var p=0;p<g;p++)this.performEventMoveForDrawing({currentStep:p+2,mode:this.mode,points:this.points,performPointIndex:p,performPoint:this.points[p]});-1===this.currentStep&&(null===(a=this.performEventPressedMove)||void 0===a||a.call(this,{currentStep:this.currentStep,mode:this.mode,points:this.points,performPointIndex:this.points.length-1,performPoint:this.points[this.points.length-1]}))}},t.prototype.getPrevZLevel=function(){return this._prevZLevel},t.prototype.setPrevZLevel=function(t){this._prevZLevel=t},t.prototype.shouldUpdate=function(){var t=this._prevOverlay.zLevel!==this.zLevel;return{sort:t,draw:t||JSON.stringify(this._prevOverlay.points)!==JSON.stringify(this.points)||this._prevOverlay.visible!==this.visible||this._prevOverlay.extendData!==this.extendData||this._prevOverlay.styles!==this.styles}},t.prototype.nextStep=function(){this.currentStep===this.totalStep-1?this.currentStep=-1:this.currentStep++},t.prototype.forceComplete=function(){this.currentStep=-1},t.prototype.isDrawing=function(){return-1!==this.currentStep},t.prototype.isStart=function(){return 1===this.currentStep},t.prototype.eventMoveForDrawing=function(t){var e,i=this.currentStep-1,r={};a(t.timestamp)&&(r.timestamp=t.timestamp),a(t.dataIndex)&&(r.dataIndex=t.dataIndex),a(t.value)&&(r.value=t.value),this.points[i]=r,null===(e=this.performEventMoveForDrawing)||void 0===e||e.call(this,{currentStep:this.currentStep,mode:this.mode,points:this.points,performPointIndex:i,performPoint:r})},t.prototype.eventPressedPointMove=function(t,e){var i;this.points[e].timestamp=t.timestamp,a(t.value)&&(this.points[e].value=t.value),null===(i=this.performEventPressedMove)||void 0===i||i.call(this,{currentStep:this.currentStep,points:this.points,mode:this.mode,performPointIndex:e,performPoint:this.points[e]})},t.prototype.startPressedMove=function(t){this._prevPressedPoint=w({},t),this._prevPressedPoints=i(this.points)},t.prototype.eventPressedOtherMove=function(t,e){if(null!==this._prevPressedPoint){var i=null;a(t.dataIndex)&&a(this._prevPressedPoint.dataIndex)&&(i=t.dataIndex-this._prevPressedPoint.dataIndex);var r=null;a(t.value)&&a(this._prevPressedPoint.value)&&(r=t.value-this._prevPressedPoint.value),this.points=this._prevPressedPoints.map((function(t){var n;a(t.timestamp)&&(t.dataIndex=e.timestampToDataIndex(t.timestamp));var o=w({},t);return a(i)&&a(t.dataIndex)&&(o.dataIndex=t.dataIndex+i,o.timestamp=null!==(n=e.dataIndexToTimestamp(o.dataIndex))&&void 0!==n?n:void 0),a(r)&&a(t.value)&&(o.value=t.value+r),o}))}},t.extend=function(e){return function(t){function i(){return t.call(this,e)||this}return E(i,t),i}(t)},t}(),Ct={name:"fibonacciLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e,i,r,n=t.chart,o=t.coordinates,s=t.bounding,l=t.overlay,u=t.yAxis,c=l.points;if(o.length>0){var h=0;if(null===(e=null==u?void 0:u.isInCandle())||void 0===e||e)h=null!==(r=null===(i=n.getSymbol())||void 0===i?void 0:i.pricePrecision)&&void 0!==r?r:Q;else n.getIndicators({paneId:l.paneId}).forEach((function(t){h=Math.max(h,t.precision)}));var d=[],g=[],p=s.width;if(o.length>1&&a(c[0].value)&&a(c[1].value)){var v=o[0].y-o[1].y,f=c[0].value-c[1].value;[1,.786,.618,.5,.382,.236,0].forEach((function(t){var e,i=o[1].y+v*t,r=n.getDecimalFold().format(n.getThousandsSeparator().format(((null!==(e=c[1].value)&&void 0!==e?e:0)+f*t).toFixed(h)));d.push({coordinates:[{x:0,y:i},{x:p,y:i}]}),g.push({x:0,y:i,text:"".concat(r," (").concat((100*t).toFixed(1),"%)"),baseline:"bottom"})}))}return[{type:"line",attrs:d},{type:"text",isCheckEvent:!1,attrs:g}]}return[]}},Tt={name:"horizontalRayLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=t.bounding,r={x:0,y:e[0].y};return s(e[1])&&e[0].x<e[1].x&&(r.x=i.width),[{type:"line",attrs:{coordinates:[e[0],r]}}]},performEventPressedMove:function(t){var e=t.points,i=t.performPoint;e[0].value=i.value,e[1].value=i.value},performEventMoveForDrawing:function(t){var e=t.currentStep,i=t.points,r=t.performPoint;2===e&&(i[0].value=r.value)}},Et=function(){function t(){this._children=[],this._callbacks=new Map}return t.prototype.registerEvent=function(t,e){return this._callbacks.set(t,e),this},t.prototype.onEvent=function(t,e){var i=this._callbacks.get(t);return!(!s(i)||!this.checkEventOn(e))&&i(e)},t.prototype.dispatchEventToChildren=function(t,e){var i=this._children.length-1;if(i>-1)for(var r=i;r>-1;r--)if(this._children[r].dispatchEvent(t,e))return!0;return!1},t.prototype.dispatchEvent=function(t,e){return!!this.dispatchEventToChildren(t,e)||this.onEvent(t,e)},t.prototype.addChild=function(t){return this._children.push(t),this},t.prototype.clear=function(){this._children=[]},t}(),wt=function(t){function e(e){var i=t.call(this)||this;return i.attrs=e.attrs,i.styles=e.styles,i}return E(e,t),e.prototype.checkEventOn=function(t){return this.checkEventOnImp(t,this.attrs,this.styles)},e.prototype.setAttrs=function(t){return this.attrs=t,this},e.prototype.setStyles=function(t){return this.styles=t,this},e.prototype.draw=function(t){this.drawImp(t,this.attrs,this.styles)},e.extend=function(t){var i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return E(i,e),i.prototype.checkEventOnImp=function(e,i,r){return t.checkEventOn(e,i,r)},i.prototype.drawImp=function(e,i,r){t.draw(e,i,r)},i}(e);return i},e}(Et);function bt(t,e){var i,r,n=[];n=n.concat(e);try{for(var o=D(n),a=o.next();!a.done;a=o.next()){var s=a.value.coordinates;if(s.length>1)for(var l=1;l<s.length;l++){var u=s[l-1],c=s[l];if(u.x===c.x){if(Math.abs(u.y-t.y)+Math.abs(c.y-t.y)-Math.abs(u.y-c.y)<4&&Math.abs(t.x-u.x)<2)return!0}else{var h=Dt(u,c),d=It(h,t),g=Math.abs(d-t.y);if(Math.abs(u.x-t.x)+Math.abs(c.x-t.x)-Math.abs(u.x-c.x)<4&&g*g/(h[0]*h[0]+1)<4)return!0}}}}catch(t){i={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return!1}function It(t,e){return null!==t?e.x*t[0]+t[1]:e.y}function St(t,e,i){return It(Dt(t,e),i)}function Dt(t,e){var i=t.x-e.x;if(0!==i){var r=(t.y-e.y)/i;return[r,t.y-r*t.x]}return null}function Pt(t,e,i){var r=e.length,n=a(i)?i>0&&i<1?i:0:i?.5:0;if(n>0&&r>2){for(var o=e[0].x,s=e[0].y,l=1;l<r-1;l++){var u=e[l-1],c=e[l],h=e[l+1],d=c.x-u.x,g=c.y-u.y,p=h.x-c.x,v=h.y-c.y,f=h.x-u.x,y=h.y-u.y,m=Math.sqrt(d*d+g*g),_=Math.sqrt(p*p+v*v),x=_/(_+m),M=c.x+f*n*x,C=c.y+y*n*x;M=Math.min(M,Math.max(h.x,c.x)),C=Math.min(C,Math.max(h.y,c.y)),M=Math.max(M,Math.min(h.x,c.x)),C=Math.max(C,Math.min(h.y,c.y)),f=M-c.x,y=C-c.y;var T=c.x-f*m/_,E=c.y-y*m/_;T=Math.min(T,Math.max(u.x,c.x)),E=Math.min(E,Math.max(u.y,c.y)),T=Math.max(T,Math.min(u.x,c.x)),E=Math.max(E,Math.min(u.y,c.y)),f=c.x-T,y=c.y-E,M=c.x+f*_/m,C=c.y+y*_/m,t.bezierCurveTo(o,s,T,E,c.x,c.y),o=M,s=C}var w=e[r-1];t.bezierCurveTo(o,s,w.x,w.y,w.x,w.y)}else for(l=1;l<r;l++)t.lineTo(e[l].x,e[l].y)}var At={name:"line",checkEventOn:bt,draw:function(t,e,i){!function(t,e,i){var r=[];r=r.concat(e);var n=i.style,o=void 0===n?"solid":n,a=i.smooth,s=void 0!==a&&a,l=i.size,u=void 0===l?1:l,c=i.color,h=void 0===c?"currentColor":c,d=i.dashedValue,g=void 0===d?[2,2]:d;t.lineWidth=u,t.strokeStyle=h,"dashed"===o?t.setLineDash(g):t.setLineDash([]);var p=u%2==1?.5:0;r.forEach((function(e){var i=e.coordinates;i.length>1&&(2!==i.length||i[0].x!==i[1].x&&i[0].y!==i[1].y?(t.save(),u%2==1&&t.translate(.5,.5),t.beginPath(),t.moveTo(i[0].x,i[0].y),Pt(t,i,s),t.stroke(),t.closePath(),t.restore()):(t.beginPath(),i[0].x===i[1].x?(t.moveTo(i[0].x+p,i[0].y),t.lineTo(i[1].x+p,i[1].y)):(t.moveTo(i[0].x,i[0].y+p),t.lineTo(i[1].x,i[1].y+p)),t.stroke(),t.closePath()))}))}(t,e,i)}};function kt(t,e,i){var r=null!=i?i:0,n=[];if(t.length>1)if(t[0].x===t[1].x){var o=e.height;if(n.push({coordinates:[{x:t[0].x,y:0},{x:t[0].x,y:o}]}),t.length>2){n.push({coordinates:[{x:t[2].x,y:0},{x:t[2].x,y:o}]});for(var a=t[0].x-t[2].x,s=0;s<r;s++){var l=a*(s+1);n.push({coordinates:[{x:t[0].x+l,y:0},{x:t[0].x+l,y:o}]})}}}else{var u=e.width,c=Dt(t[0],t[1]),h=c[0],d=c[1];if(n.push({coordinates:[{x:0,y:0*h+d},{x:u,y:u*h+d}]}),t.length>2){var g=t[2].y-h*t[2].x;n.push({coordinates:[{x:0,y:0*h+g},{x:u,y:u*h+g}]});for(a=d-g,s=0;s<r;s++){var p=d+a*(s+1);n.push({coordinates:[{x:0,y:0*h+p},{x:u,y:u*h+p}]})}}}return n}function Lt(t,e){if(t.length>1){var i={x:0,y:0};return i=t[0].x===t[1].x&&t[0].y!==t[1].y?t[0].y<t[1].y?{x:t[0].x,y:e.height}:{x:t[0].x,y:0}:t[0].x>t[1].x?{x:0,y:St(t[0],t[1],{x:0,y:t[0].y})}:{x:e.width,y:St(t[0],t[1],{x:e.width,y:t[0].y})},{coordinates:[t[0],i]}}return[]}var Nt={name:"simpleAnnotation",totalStep:2,styles:{line:{style:"dashed"}},createPointFigures:function(t){var e,i=t.overlay,r=t.coordinates,o="";s(i.extendData)&&(o=n(i.extendData)?i.extendData(i):null!==(e=i.extendData)&&void 0!==e?e:"");var a=r[0].x,l=r[0].y-6,u=l-50,c=u-5;return[{type:"line",attrs:{coordinates:[{x:a,y:l},{x:a,y:u}]},ignoreEvent:!0},{type:"polygon",attrs:{coordinates:[{x:a,y:u},{x:a-4,y:c},{x:a+4,y:c}]},ignoreEvent:!0},{type:"text",attrs:{x:a,y:c,text:o,align:"center",baseline:"bottom"},ignoreEvent:!0}]}},Ot={name:"simpleTag",totalStep:2,styles:{line:{style:"dashed"}},createPointFigures:function(t){var e=t.bounding,i=t.coordinates;return{type:"line",attrs:{coordinates:[{x:0,y:i[0].y},{x:e.width,y:i[0].y}]},ignoreEvent:!0}},createYAxisFigures:function(t){var e,i,r,o,l=t.chart,u=t.overlay,c=t.coordinates,h=t.bounding,d=t.yAxis,g="left",v=0;null!==(e=null==d?void 0:d.isFromZero())&&void 0!==e&&e?(g="left",v=0):(g="right",v=h.width);var f="";return s(u.extendData)&&(f=n(u.extendData)?u.extendData(u):null!==(i=u.extendData)&&void 0!==i?i:""),!s(f)&&a(u.points[0].value)&&(f=p(u.points[0].value,null!==(o=null===(r=l.getSymbol())||void 0===r?void 0:r.pricePrecision)&&void 0!==o?o:Q)),{type:"text",attrs:{x:v,y:c[0].y,text:f,align:g,baseline:"middle"}}}},Ft={};function Bt(t){var e;return null!==(e=Ft[t])&&void 0!==e?e:null}[Ct,Tt,{name:"horizontalSegment",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=[];return 2===e.length&&i.push({coordinates:e}),[{type:"line",attrs:i}]},performEventPressedMove:function(t){var e=t.points,i=t.performPoint;e[0].value=i.value,e[1].value=i.value},performEventMoveForDrawing:function(t){var e=t.currentStep,i=t.points,r=t.performPoint;2===e&&(i[0].value=r.value)}},{name:"horizontalStraightLine",totalStep:2,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=t.bounding;return[{type:"line",attrs:{coordinates:[{x:0,y:e[0].y},{x:i.width,y:e[0].y}]}}]}},{name:"parallelStraightLine",totalStep:4,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){return[{type:"line",attrs:kt(t.coordinates,t.bounding)}]}},{name:"priceChannelLine",totalStep:4,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){return[{type:"line",attrs:kt(t.coordinates,t.bounding,1)}]}},{name:"priceLine",totalStep:2,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e,i,r,n=t.chart,o=t.coordinates,a=t.bounding,s=t.overlay,l=t.yAxis,u=0;null===(e=null==l?void 0:l.isInCandle())||void 0===e||e?u=null!==(r=null===(i=n.getSymbol())||void 0===i?void 0:i.pricePrecision)&&void 0!==r?r:Q:n.getIndicators({paneId:s.paneId}).forEach((function(t){u=Math.max(u,t.precision)}));var c=s.points[0].value,h=void 0===c?0:c;return[{type:"line",attrs:{coordinates:[o[0],{x:a.width,y:o[0].y}]}},{type:"text",ignoreEvent:!0,attrs:{x:o[0].x,y:o[0].y,text:n.getDecimalFold().format(n.getThousandsSeparator().format(h.toFixed(u))),baseline:"bottom"}}]}},{name:"rayLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){return[{type:"line",attrs:Lt(t.coordinates,t.bounding)}]}},{name:"segment",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates;return 2===e.length?[{type:"line",attrs:{coordinates:e}}]:[]}},{name:"straightLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=t.bounding;return 2===e.length?e[0].x===e[1].x?[{type:"line",attrs:{coordinates:[{x:e[0].x,y:0},{x:e[0].x,y:i.height}]}}]:[{type:"line",attrs:{coordinates:[{x:0,y:St(e[0],e[1],{x:0,y:e[0].y})},{x:i.width,y:St(e[0],e[1],{x:i.width,y:e[0].y})}]}}]:[]}},{name:"verticalRayLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=t.bounding;if(2===e.length){var r={x:e[0].x,y:0};return e[0].y<e[1].y&&(r.y=i.height),[{type:"line",attrs:{coordinates:[e[0],r]}}]}return[]},performEventPressedMove:function(t){var e=t.points,i=t.performPoint;e[0].timestamp=i.timestamp,e[0].dataIndex=i.dataIndex,e[1].timestamp=i.timestamp,e[1].dataIndex=i.dataIndex},performEventMoveForDrawing:function(t){var e=t.currentStep,i=t.points,r=t.performPoint;2===e&&(i[0].timestamp=r.timestamp,i[0].dataIndex=r.dataIndex)}},{name:"verticalSegment",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates;return 2===e.length?[{type:"line",attrs:{coordinates:e}}]:[]},performEventPressedMove:function(t){var e=t.points,i=t.performPoint;e[0].timestamp=i.timestamp,e[0].dataIndex=i.dataIndex,e[1].timestamp=i.timestamp,e[1].dataIndex=i.dataIndex},performEventMoveForDrawing:function(t){var e=t.currentStep,i=t.points,r=t.performPoint;2===e&&(i[0].timestamp=r.timestamp,i[0].dataIndex=r.dataIndex)}},{name:"verticalStraightLine",totalStep:2,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=t.bounding;return[{type:"line",attrs:{coordinates:[{x:e[0].x,y:0},{x:e[0].x,y:i.height}]}}]}},Nt,Ot].forEach((function(t){Ft[t.name]=Mt.extend(t)}));var Rt={light:{grid:{horizontal:{color:"#EDEDED"},vertical:{color:"#EDEDED"}},candle:{priceMark:{high:{color:"#76808F"},low:{color:"#76808F"}},tooltip:{rect:{color:"#FEFEFE",borderColor:"#F2F3F5"},title:{color:"#76808F"},legend:{color:"#76808F"}}},indicator:{tooltip:{title:{color:"#76808F"},legend:{color:"#76808F"}}},xAxis:{axisLine:{color:"#DDDDDD"},tickText:{color:"#76808F"},tickLine:{color:"#DDDDDD"}},yAxis:{axisLine:{color:"#DDDDDD"},tickText:{color:"#76808F"},tickLine:{color:"#DDDDDD"}},separator:{color:"#DDDDDD"},crosshair:{horizontal:{line:{color:"#76808F"},text:{borderColor:"#686D76",backgroundColor:"#686D76"}},vertical:{line:{color:"#76808F"},text:{borderColor:"#686D76",backgroundColor:"#686D76"}}}},dark:{grid:{horizontal:{color:"#292929"},vertical:{color:"#292929"}},candle:{priceMark:{high:{color:"#929AA5"},low:{color:"#929AA5"}},tooltip:{rect:{color:"rgba(10, 10, 10, .6)",borderColor:"rgba(10, 10, 10, .6)"},title:{color:"#929AA5"},legend:{color:"#929AA5"}}},indicator:{tooltip:{title:{color:"#929AA5"},legend:{color:"#929AA5"}}},xAxis:{axisLine:{color:"#333333"},tickText:{color:"#929AA5"},tickLine:{color:"#333333"}},yAxis:{axisLine:{color:"#333333"},tickText:{color:"#929AA5"},tickLine:{color:"#333333"}},separator:{color:"#333333"},crosshair:{horizontal:{line:{color:"#929AA5"},text:{borderColor:"#373a40",backgroundColor:"#373a40"}},vertical:{line:{color:"#929AA5"},text:{borderColor:"#373a40",backgroundColor:"#373a40"}}}}};function zt(t){var e;return null!==(e=Rt[t])&&void 0!==e?e:null}var jt="candle_pane",Yt="indicator_pane_",Wt="x_axis_pane",Vt=1,Ht=50,Ut=function(){function t(t,e){var i,r,n,o,a,l=this;this._styles={grid:{show:!0,horizontal:{show:!0,size:1,color:"#EDEDED",style:"dashed",dashedValue:[2,2]},vertical:{show:!0,size:1,color:"#EDEDED",style:"dashed",dashedValue:[2,2]}},candle:(a={show:!0,color:K.GREY,textOffset:5,textSize:10,textFamily:"Helvetica Neue",textWeight:"normal"},{type:"candle_solid",bar:{compareRule:"current_open",upColor:K.GREEN,downColor:K.RED,noChangeColor:K.GREY,upBorderColor:K.GREEN,downBorderColor:K.RED,noChangeBorderColor:K.GREY,upWickColor:K.GREEN,downWickColor:K.RED,noChangeWickColor:K.GREY},area:{lineSize:2,lineColor:K.BLUE,smooth:!1,value:"close",backgroundColor:[{offset:0,color:J(K.BLUE,.01)},{offset:1,color:J(K.BLUE,.2)}],point:{show:!0,color:K.BLUE,radius:4,rippleColor:J(K.BLUE,.3),rippleRadius:8,animation:!0,animationDuration:1e3}},priceMark:{show:!0,high:w({},a),low:w({},a),last:{show:!0,compareRule:"current_open",upColor:K.GREEN,downColor:K.RED,noChangeColor:K.GREY,line:{show: