UNPKG

highcharts

Version:
22 lines (19 loc) 5.99 kB
/* Highstock JS v10.0.0 (2022-03-07) Indicator series type for Highcharts Stock (c) 2010-2021 Pawel Fus, Sebastian Bochan License: www.highcharts.com/license */ (function(a){"object"===typeof module&&module.exports?(a["default"]=a,module.exports=a):"function"===typeof define&&define.amd?define("highcharts/indicators/indicators",["highcharts","highcharts/modules/stock"],function(k){a(k);a.Highcharts=k;return a}):a("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(a){function k(a,g,e,k){a.hasOwnProperty(g)||(a[g]=k.apply(null,e),"function"===typeof CustomEvent&&window.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:g,module:a[g]}})))} a=a?a._modules:{};k(a,"Stock/Indicators/SMA/SMAComposition.js",[a["Core/Series/SeriesRegistry.js"],a["Core/Utilities.js"]],function(a,g){});k(a,"Stock/Indicators/SMA/SMAIndicator.js",[a["Core/Chart/Chart.js"],a["Core/Series/SeriesRegistry.js"],a["Core/Utilities.js"]],function(a,g,e){var k=this&&this.__extends||function(){var a=function(h,b){a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,d){b.__proto__=d}||function(b,d){for(var c in d)d.hasOwnProperty(c)&&(b[c]=d[c])};return a(h, b)};return function(h,b){function c(){this.constructor=h}a(h,b);h.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)}}(),n=g.seriesTypes.line,p=e.addEvent,t=e.error,u=e.extend,v=e.isArray,h=e.merge,f=e.pick,q=e.splat;e=function(m){function l(){var b=null!==m&&m.apply(this,arguments)||this;b.data=void 0;b.dataEventsToUnbind=void 0;b.linkedParent=void 0;b.options=void 0;b.points=void 0;return b}k(l,m);l.prototype.destroy=function(){this.dataEventsToUnbind.forEach(function(b){b()}); m.prototype.destroy.apply(this,arguments)};l.prototype.getName=function(){var b=this.name,c=[];b||((this.nameComponents||[]).forEach(function(b,a){c.push(this.options.params[b]+f(this.nameSuffixes[a],""))},this),b=(this.nameBase||this.type.toUpperCase())+(this.nameComponents?" ("+c.join(", ")+")":""));return b};l.prototype.getValues=function(b,c){var d=c.period,a=b.xData;b=b.yData;var h=b.length,f=0,q=0,l=[],m=[],g=[],e=-1;if(!(a.length<d)){for(v(b[0])&&(e=c.index?c.index:0);f<d-1;)q+=0>e?b[f]:b[f][e], f++;for(c=f;c<h;c++){q+=0>e?b[c]:b[c][e];var k=[a[c],q/d];l.push(k);m.push(k[0]);g.push(k[1]);q-=0>e?b[c-f]:b[c-f][e]}return{values:l,xData:m,yData:g}}};l.prototype.init=function(b,c){var d=this;m.prototype.init.call(d,b,c);c=p(a,"afterLinkSeries",function(){var c=!!d.dataEventsToUnbind.length;if(d.linkedParent)if(c||(d.dataEventsToUnbind.push(p(d.linkedParent,"updatedData",function(){d.recalculateValues()})),d.calculateOn.xAxis&&d.dataEventsToUnbind.push(p(d.linkedParent.xAxis,d.calculateOn.xAxis, function(){d.recalculateValues()}))),"init"===d.calculateOn.chart)d.processedYData||d.recalculateValues();else{if(!c)var a=p(d.chart,d.calculateOn.chart,function(){d.recalculateValues();a()})}else return t("Series "+d.options.linkedTo+" not found! Check `linkedTo`.",!1,b)},{order:0});d.dataEventsToUnbind=[];d.eventsToUnbind.push(c)};l.prototype.recalculateValues=function(){var b=this.points||[],c=(this.xData||[]).length,d={values:[],xData:[],yData:[]},a=[],h=!0;d=this.linkedParent.options?this.getValues(this.linkedParent, this.options.params)||d:d;if(c&&!this.hasGroupedData&&this.visible&&this.points)if(this.cropped){if(this.xAxis){var f=this.xAxis.min;var e=this.xAxis.max}c=this.cropData(d.xData,d.yData,f,e);for(f=0;f<c.xData.length;f++)a.push([c.xData[f]].concat(q(c.yData[f])));c=d.xData.indexOf(this.xData[0]);f=d.xData.indexOf(this.xData[this.xData.length-1]);-1===c&&f===d.xData.length-2&&a[0][0]===b[0].x&&a.shift();this.updateData(a)}else d.xData.length!==c-1&&d.xData.length!==c+1&&(h=!1,this.updateData(d.values)); h&&(this.xData=d.xData,this.yData=d.yData,this.options.data=d.values);this.calculateOn.xAxis&&this.processedXData&&(delete this.processedXData,this.isDirty=!0,this.redraw());this.isDirtyData=!1};l.prototype.processData=function(){var b=this.options.compareToMain,c=this.linkedParent;m.prototype.processData.apply(this,arguments);this.dataModify&&c&&c.dataModify&&c.dataModify.compareValue&&b&&(this.dataModify.compareValue=c.dataModify.compareValue)};l.defaultOptions=h(n.defaultOptions,{name:void 0,tooltip:{valueDecimals:4}, linkedTo:void 0,compareToMain:!1,params:{index:3,period:14}});return l}(n);u(e.prototype,{calculateOn:{chart:"init"},hasDerivedData:!0,nameComponents:["period"],nameSuffixes:[],useCommonDataGrouping:!0});g.registerSeriesType("sma",e);"";return e});k(a,"Stock/Indicators/EMA/EMAIndicator.js",[a["Core/Series/SeriesRegistry.js"],a["Core/Utilities.js"]],function(a,g){var e=this&&this.__extends||function(){var a=function(e,h){a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,h){a.__proto__= h}||function(a,h){for(var f in h)h.hasOwnProperty(f)&&(a[f]=h[f])};return a(e,h)};return function(e,h){function f(){this.constructor=e}a(e,h);e.prototype=null===h?Object.create(h):(f.prototype=h.prototype,new f)}}(),k=a.seriesTypes.sma,n=g.correctFloat,p=g.isArray,t=g.merge;g=function(a){function g(){var h=null!==a&&a.apply(this,arguments)||this;h.data=void 0;h.options=void 0;h.points=void 0;return h}e(g,a);g.prototype.accumulatePeriodPoints=function(a,f,e){for(var h=0,g=0,b;g<a;)b=0>f?e[g]:e[g][f], h+=b,g++;return h};g.prototype.calculateEma=function(a,f,e,g,k,b,c){a=a[e-1];f=0>b?f[e-1]:f[e-1][b];g="undefined"===typeof k?c:n(f*g+k*(1-g));return[a,g]};g.prototype.getValues=function(a,f){var e=f.period,g=a.xData,h=(a=a.yData)?a.length:0,b=2/(e+1),c=[],d=[],k=[],n=-1;if(!(h<e)){p(a[0])&&(n=f.index?f.index:0);f=this.accumulatePeriodPoints(e,n,a);for(f/=e;e<h+1;e++){var r=this.calculateEma(g,a,e,b,r,n,f);c.push(r);d.push(r[0]);k.push(r[1]);r=r[1]}return{values:c,xData:d,yData:k}}};g.defaultOptions= t(k.defaultOptions,{params:{index:3,period:9}});return g}(k);a.registerSeriesType("ema",g);"";return g});k(a,"masters/indicators/indicators.src.js",[],function(){})}); //# sourceMappingURL=indicators.js.map