UNPKG

tradingraph

Version:

Based on rpiontik chart https://github.com/rpiontik/crypto-chart

1 lines 17.6 kB
(function(t){var e={};function n(a){if(e[a])return e[a].exports;var r=e[a]={i:a,l:!1,exports:{}};return t[a].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,a){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(a,r,function(e){return t[e]}.bind(null,r));return a},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="eb28")})({"01f9":function(t,e,n){"use strict";var a=n("2d00"),r=n("5ca1"),i=n("2aba"),o=n("32e9"),s=n("84f2"),c=n("41a0"),u=n("7f20"),f=n("38fd"),l=n("2b4c")("iterator"),h=!([].keys&&"next"in[].keys()),d="@@iterator",p="keys",v="values",m=function(){return this};t.exports=function(t,e,n,g,y,b,x){c(n,e,g);var w,P,E,O=function(t){if(!h&&t in D)return D[t];switch(t){case p:return function(){return new n(this,t)};case v:return function(){return new n(this,t)}}return function(){return new n(this,t)}},S=e+" Iterator",M=y==v,k=!1,D=t.prototype,j=D[l]||D[d]||y&&D[y],T=j||O(y),L=y?M?O("entries"):T:void 0,A="Array"==e&&D.entries||j;if(A&&(E=f(A.call(new t)),E!==Object.prototype&&E.next&&(u(E,S,!0),a||"function"==typeof E[l]||o(E,l,m))),M&&j&&j.name!==v&&(k=!0,T=function(){return j.call(this)}),a&&!x||!h&&!k&&D[l]||o(D,l,T),s[e]=T,s[S]=m,y)if(w={values:M?T:O(v),keys:b?T:O(p),entries:L},x)for(P in w)P in D||i(D,P,w[P]);else r(r.P+r.F*(h||k),e,w);return w}},"0d58":function(t,e,n){var a=n("ce10"),r=n("e11e");t.exports=Object.keys||function(t){return a(t,r)}},1495:function(t,e,n){var a=n("86cc"),r=n("cb7c"),i=n("0d58");t.exports=n("9e1e")?Object.defineProperties:function(t,e){r(t);var n,o=i(e),s=o.length,c=0;while(s>c)a.f(t,n=o[c++],e[n]);return t}},"230e":function(t,e,n){var a=n("d3f4"),r=n("7726").document,i=a(r)&&a(r.createElement);t.exports=function(t){return i?r.createElement(t):{}}},2621:function(t,e){e.f=Object.getOwnPropertySymbols},"2aba":function(t,e,n){var a=n("7726"),r=n("32e9"),i=n("69a8"),o=n("ca5a")("src"),s="toString",c=Function[s],u=(""+c).split(s);n("8378").inspectSource=function(t){return c.call(t)},(t.exports=function(t,e,n,s){var c="function"==typeof n;c&&(i(n,"name")||r(n,"name",e)),t[e]!==n&&(c&&(i(n,o)||r(n,o,t[e]?""+t[e]:u.join(String(e)))),t===a?t[e]=n:s?t[e]?t[e]=n:r(t,e,n):(delete t[e],r(t,e,n)))})(Function.prototype,s,function(){return"function"==typeof this&&this[o]||c.call(this)})},"2aeb":function(t,e,n){var a=n("cb7c"),r=n("1495"),i=n("e11e"),o=n("613b")("IE_PROTO"),s=function(){},c="prototype",u=function(){var t,e=n("230e")("iframe"),a=i.length,r="<",o=">";e.style.display="none",n("fab2").appendChild(e),e.src="javascript:",t=e.contentWindow.document,t.open(),t.write(r+"script"+o+"document.F=Object"+r+"/script"+o),t.close(),u=t.F;while(a--)delete u[c][i[a]];return u()};t.exports=Object.create||function(t,e){var n;return null!==t?(s[c]=a(t),n=new s,s[c]=null,n[o]=t):n=u(),void 0===e?n:r(n,e)}},"2b4c":function(t,e,n){var a=n("5537")("wks"),r=n("ca5a"),i=n("7726").Symbol,o="function"==typeof i,s=t.exports=function(t){return a[t]||(a[t]=o&&i[t]||(o?i:r)("Symbol."+t))};s.store=a},"2d00":function(t,e){t.exports=!1},"2d95":function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},"2f21":function(t,e,n){"use strict";var a=n("79e5");t.exports=function(t,e){return!!t&&a(function(){e?t.call(null,function(){},1):t.call(null)})}},"32e9":function(t,e,n){var a=n("86cc"),r=n("4630");t.exports=n("9e1e")?function(t,e,n){return a.f(t,e,r(1,n))}:function(t,e,n){return t[e]=n,t}},"38fd":function(t,e,n){var a=n("69a8"),r=n("4bf8"),i=n("613b")("IE_PROTO"),o=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=r(t),a(t,i)?t[i]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?o:null}},"41a0":function(t,e,n){"use strict";var a=n("2aeb"),r=n("4630"),i=n("7f20"),o={};n("32e9")(o,n("2b4c")("iterator"),function(){return this}),t.exports=function(t,e,n){t.prototype=a(o,{next:r(1,n)}),i(t,e+" Iterator")}},"456d":function(t,e,n){var a=n("4bf8"),r=n("0d58");n("5eda")("keys",function(){return function(t){return r(a(t))}})},4588:function(t,e){var n=Math.ceil,a=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?a:n)(t)}},4630:function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},"4bf8":function(t,e,n){var a=n("be13");t.exports=function(t){return Object(a(t))}},"52a7":function(t,e){e.f={}.propertyIsEnumerable},5537:function(t,e,n){var a=n("8378"),r=n("7726"),i="__core-js_shared__",o=r[i]||(r[i]={});(t.exports=function(t,e){return o[t]||(o[t]=void 0!==e?e:{})})("versions",[]).push({version:a.version,mode:n("2d00")?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},"55dd":function(t,e,n){"use strict";var a=n("5ca1"),r=n("d8e8"),i=n("4bf8"),o=n("79e5"),s=[].sort,c=[1,2,3];a(a.P+a.F*(o(function(){c.sort(void 0)})||!o(function(){c.sort(null)})||!n("2f21")(s)),"Array",{sort:function(t){return void 0===t?s.call(i(this)):s.call(i(this),r(t))}})},"5ca1":function(t,e,n){var a=n("7726"),r=n("8378"),i=n("32e9"),o=n("2aba"),s=n("9b43"),c="prototype",u=function(t,e,n){var f,l,h,d,p=t&u.F,v=t&u.G,m=t&u.S,g=t&u.P,y=t&u.B,b=v?a:m?a[e]||(a[e]={}):(a[e]||{})[c],x=v?r:r[e]||(r[e]={}),w=x[c]||(x[c]={});for(f in v&&(n=e),n)l=!p&&b&&void 0!==b[f],h=(l?b:n)[f],d=y&&l?s(h,a):g&&"function"==typeof h?s(Function.call,h):h,b&&o(b,f,h,t&u.U),x[f]!=h&&i(x,f,d),g&&w[f]!=h&&(w[f]=h)};a.core=r,u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u},"5eda":function(t,e,n){var a=n("5ca1"),r=n("8378"),i=n("79e5");t.exports=function(t,e){var n=(r.Object||{})[t]||Object[t],o={};o[t]=e(n),a(a.S+a.F*i(function(){n(1)}),"Object",o)}},"613b":function(t,e,n){var a=n("5537")("keys"),r=n("ca5a");t.exports=function(t){return a[t]||(a[t]=r(t))}},"626a":function(t,e,n){var a=n("2d95");t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==a(t)?t.split(""):Object(t)}},6821:function(t,e,n){var a=n("626a"),r=n("be13");t.exports=function(t){return a(r(t))}},"69a8":function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},"6a99":function(t,e,n){var a=n("d3f4");t.exports=function(t,e){if(!a(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!a(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!a(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!a(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")}},7333:function(t,e,n){"use strict";var a=n("0d58"),r=n("2621"),i=n("52a7"),o=n("4bf8"),s=n("626a"),c=Object.assign;t.exports=!c||n("79e5")(function(){var t={},e={},n=Symbol(),a="abcdefghijklmnopqrst";return t[n]=7,a.split("").forEach(function(t){e[t]=t}),7!=c({},t)[n]||Object.keys(c({},e)).join("")!=a})?function(t,e){var n=o(t),c=arguments.length,u=1,f=r.f,l=i.f;while(c>u){var h,d=s(arguments[u++]),p=f?a(d).concat(f(d)):a(d),v=p.length,m=0;while(v>m)l.call(d,h=p[m++])&&(n[h]=d[h])}return n}:c},7726:function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},"77f1":function(t,e,n){var a=n("4588"),r=Math.max,i=Math.min;t.exports=function(t,e){return t=a(t),t<0?r(t+e,0):i(t,e)}},"79e5":function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},"7f20":function(t,e,n){var a=n("86cc").f,r=n("69a8"),i=n("2b4c")("toStringTag");t.exports=function(t,e,n){t&&!r(t=n?t:t.prototype,i)&&a(t,i,{configurable:!0,value:e})}},8378:function(t,e){var n=t.exports={version:"2.5.7"};"number"==typeof __e&&(__e=n)},"84f2":function(t,e){t.exports={}},"86cc":function(t,e,n){var a=n("cb7c"),r=n("c69a"),i=n("6a99"),o=Object.defineProperty;e.f=n("9e1e")?Object.defineProperty:function(t,e,n){if(a(t),e=i(e,!0),a(n),r)try{return o(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},"9b43":function(t,e,n){var a=n("d8e8");t.exports=function(t,e,n){if(a(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,a){return t.call(e,n,a)};case 3:return function(n,a,r){return t.call(e,n,a,r)}}return function(){return t.apply(e,arguments)}}},"9c6c":function(t,e,n){var a=n("2b4c")("unscopables"),r=Array.prototype;void 0==r[a]&&n("32e9")(r,a,{}),t.exports=function(t){r[a][t]=!0}},"9def":function(t,e,n){var a=n("4588"),r=Math.min;t.exports=function(t){return t>0?r(a(t),9007199254740991):0}},"9e1e":function(t,e,n){t.exports=!n("79e5")(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},ac6a:function(t,e,n){for(var a=n("cadf"),r=n("0d58"),i=n("2aba"),o=n("7726"),s=n("32e9"),c=n("84f2"),u=n("2b4c"),f=u("iterator"),l=u("toStringTag"),h=c.Array,d={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},p=r(d),v=0;v<p.length;v++){var m,g=p[v],y=d[g],b=o[g],x=b&&b.prototype;if(x&&(x[f]||s(x,f,h),x[l]||s(x,l,g),c[g]=h,y))for(m in a)x[m]||i(x,m,a[m],!0)}},be13:function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},c366:function(t,e,n){var a=n("6821"),r=n("9def"),i=n("77f1");t.exports=function(t){return function(e,n,o){var s,c=a(e),u=r(c.length),f=i(o,u);if(t&&n!=n){while(u>f)if(s=c[f++],s!=s)return!0}else for(;u>f;f++)if((t||f in c)&&c[f]===n)return t||f||0;return!t&&-1}}},c69a:function(t,e,n){t.exports=!n("9e1e")&&!n("79e5")(function(){return 7!=Object.defineProperty(n("230e")("div"),"a",{get:function(){return 7}}).a})},ca5a:function(t,e){var n=0,a=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+a).toString(36))}},cadf:function(t,e,n){"use strict";var a=n("9c6c"),r=n("d53b"),i=n("84f2"),o=n("6821");t.exports=n("01f9")(Array,"Array",function(t,e){this._t=o(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,n=this._i++;return!t||n>=t.length?(this._t=void 0,r(1)):r(0,"keys"==e?n:"values"==e?t[n]:[n,t[n]])},"values"),i.Arguments=i.Array,a("keys"),a("values"),a("entries")},cb7c:function(t,e,n){var a=n("d3f4");t.exports=function(t){if(!a(t))throw TypeError(t+" is not an object!");return t}},ce10:function(t,e,n){var a=n("69a8"),r=n("6821"),i=n("c366")(!1),o=n("613b")("IE_PROTO");t.exports=function(t,e){var n,s=r(t),c=0,u=[];for(n in s)n!=o&&a(s,n)&&u.push(n);while(e.length>c)a(s,n=e[c++])&&(~i(u,n)||u.push(n));return u}},d3f4:function(t,e){t.exports=function(t){return"object"===typeof t?null!==t:"function"===typeof t}},d53b:function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},d8e8:function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},e11e:function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},eb28:function(t,e,n){"use strict";n.r(e);n("f751"),n("55dd"),n("ac6a"),n("cadf"),n("456d");function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var a=e[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}var o=10,s=.3,c=function(){function t(){a(this,t),this.data={treeReady:!1,raw:[],start:null,width:null,tree:[]},this.averageData=[],this.params={empty:!1,noMoreData:!1,dataRequestPending:!1,candleWidths:[],firstTimestamp:0,lastTimestamp:0,defaultExposition:2592e3},this.requestParams()}return i(t,[{key:"sendMessage",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;postMessage({type:t,body:e})}},{key:"messageHandler",value:function(t){switch(t.data.task){case"SET-PARAMS":this.setParams(t.data.params),this.params.lastTimestamp>0&&!this.params.dataRequestPending&&!this.data.raw.length&&this.initialLoading();break;case"APPEND":this.append(t.data.data);break;case"APPEND_AVERAGE":this.appendAverage(t.data.data);break;case"RENDER":this.renderCandles(t.data.offset,t.data.exposition,t.data.viewWidth,t.data.viewHeight);break;case"RENDER_AVERAGE":this.renderAverage(t.data.offset,t.data.exposition,t.data.viewWidth,t.data.viewHeight);break;case"RELOAD":this.params.empty=!1,this.params.noMoreData=!1,this.resetData(),this.requestParams();break;default:break}}},{key:"resetData",value:function(){this.data.treeReady=!1,this.data.raw=[],this.data.start=null,this.data.width=null,this.data.tree=[],this.averageData=[],this.params.dataRequestPending=!1}},{key:"setParams",value:function(t){var e=this;Object.keys(t).map(function(n){e.params[n]=t[n]}),this.data.treeReady=!1}},{key:"requestParams",value:function(){this.sendMessage("NEED_PARAMS",{inner:{candleWidths:null},outer:{firstTimestamp:null,lastTimestamp:null}})}},{key:"initialLoading",value:function(){var t=this.params.defaultExposition,e=this.params.lastTimestamp-t;e=e>this.params.firstTimestamp?e:this.params.firstTimestamp,this.params.dataRequestPending=!0,this.sendMessage("NEED_DATA",{offset:e,exposition:t})}},{key:"append",value:function(t){this.params.dataRequestPending=!1,t.length>0?(this.data.treeReady=!1,this.data.raw.splice(0),this.data.raw=t.slice(),this.data.raw.sort(function(t,e){return t.date-e.date})):this.params.empty||this.params.noMoreData||this.resetData(),this.sendMessage("APPENDED")}},{key:"appendAverage",value:function(t){this.averageData.splice(0),this.averageData=t.slice(),this.sendMessage("APPENDED_AVERAGE")}},{key:"makeTree",value:function(){var t=this;this.data.raw.length>0&&(this.data.start=this.data.raw[0].date,this.data.end=this.data.raw[this.data.raw.length-1].date,this.params.candleWidths.map(function(e){t.data.tree[e]=[];var n=null;t.data.raw.map(function(a){var r=a.date-a.date%e;n&&r===n.id?(n.low=a.low<n.low?a.low:n.low,n.high=a.high>n.high?a.high:n.high,n.close=a.close,n.volume+=a.volume):(n&&t.data.tree[e].push(n),n={id:r,timestamp:a.date,open:a.open,low:a.low,high:a.high,close:a.close,volume:a.volume})}),n&&t.data.tree[e].push(n)}),this.data.treeReady=!0)}},{key:"findCandleWidthForUse",value:function(t,e){var n=e/o,a=null,r=0;return this.params.candleWidths.map(function(e){if(a){var i=Math.abs(Math.round(n-t/e));i<r&&(r=i,a=e)}else a=e,r=Math.abs(Math.round(n-t/e))}),a}},{key:"renderCandles",value:function(t,e,n,a){this.data.treeReady||this.makeTree();var r={low:null,high:null,maxVolume:null,width:null,candles:[],candlesPositivePath:[],candlesNegativePath:[],volumePath:[]},i=this.findCandleWidthForUse(e,n),o=this.data.tree[i],c=n/e;r.width=i*c;var u=0,f=o.length;t>this.data.start&&(u=-Math.floor((t-this.data.start)/i));for(var l=-u;l<f;l++){var h=o[l];if(!(h.timestamp<=t)){if(h.timestamp>t+e){f=l;break}u<0&&(u=l),(null==r.low||r.low>h.low)&&(r.low=h.low),(null==r.high||r.high<h.high)&&(r.high=h.high),(null==r.maxVolume||r.maxVolume<h.volume)&&(r.maxVolume=h.volume)}}u=Math.abs(u),null==f&&(f=o.length);for(var d=a/(r.high-r.low),p=a*s/r.maxVolume,v=i*c*.25,m=u;m<f;m++){var g=o[m],y=(g.timestamp-t)*c,b="M".concat(y," ").concat((r.high-g.low)*d," L").concat(y," ").concat((r.high-g.high)*d," "),x="M".concat(y-v," ").concat((r.high-g.close)*d," L").concat(y+v," ").concat((r.high-g.close)*d," ")+"L".concat(y+v," ").concat((r.high-g.open)*d," L").concat(y-v," ").concat((r.high-g.open)*d," "),w=Object.assign({},g);g.open<=g.close?(w.class="positive",w.candlePathIndex=r.candlesPositivePath.push(b+x)-1):(w.class="negative",w.candlePathIndex=r.candlesNegativePath.push(b+x)-1),w.volumePathIndex=r.volumePath.push("M".concat(y-v," ").concat(a-g.volume*p," L").concat(y+v," ").concat(a-g.volume*p," ")+"L".concat(y+v," ").concat(a," L").concat(y-v," ").concat(a," "))-1,w.x=y,r.candles.push(w)}this.data.start>0&&this.data.start<t||this.params.dataRequestPending||(this.params.dataRequestPending=!0,this.sendMessage("NEED_DATA",{offset:t,exposition:this.params.defaultExposition})),this.sendMessage("RENDERED",r)}},{key:"renderAverage",value:function(t,e,n,a){if(this.averageData.length){var r=this.averageData.length,i=n/this.averageData.length,o={minTimestamp:this.averageData[0].date,maxTimestamp:this.averageData[r-1].date,path:[]},s=this.averageData.slice().sort(function(t,e){return t.average-e.average}),c=s[r-1].average,u=s[0].average,f=a/(c-u);o.path.push("M6 ".concat(f*(c-this.averageData[0].average)));for(var l=1;l<r;l++)o.path.push("L".concat(i*l," ").concat(f*(c-this.averageData[l].average)));this.sendMessage("RENDERED_AVERAGE",o)}}}]),t}(),u=new c;onmessage=function(t){u.messageHandler(t)}},f751:function(t,e,n){var a=n("5ca1");a(a.S+a.F,"Object",{assign:n("7333")})},fab2:function(t,e,n){var a=n("7726").document;t.exports=a&&a.documentElement}});