highcharts
Version:
JavaScript charting framework
21 lines (18 loc) • 5.68 kB
JavaScript
/*
Highstock JS v10.0.0 (2022-03-07)
Indicator series type for Highcharts Stock
(c) 2010-2021 Pawe Fus
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/stochastic",["highcharts","highcharts/modules/stock"],function(c){a(c);a.Highcharts=c;return a}):a("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(a){function c(a,f,l,t){a.hasOwnProperty(f)||(a[f]=t.apply(null,l),"function"===typeof CustomEvent&&window.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:f,module:a[f]}})))}
a=a?a._modules:{};c(a,"Stock/Indicators/ArrayUtilities.js",[],function(){return{getArrayExtremes:function(a,f,l){return a.reduce(function(a,c){return[Math.min(a[0],c[f]),Math.max(a[1],c[l])]},[Number.MAX_VALUE,-Number.MAX_VALUE])}}});c(a,"Stock/Indicators/MultipleLinesComposition.js",[a["Core/Series/SeriesRegistry.js"],a["Core/Utilities.js"]],function(a,f){var l=a.seriesTypes.sma,t=f.defined,c=f.error,n=f.merge,h;(function(f){function h(b){var e,a=[];b=b||this.points;if(this.fillGraph&&this.nextPoints){if((e=
l.prototype.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L";a=l.prototype.getGraphPath.call(this,b);e=e.slice(0,a.length);for(var d=e.length-1;0<=d;d--)a.push(e[d])}}else a=l.prototype.getGraphPath.apply(this,arguments);return a}function p(){var b=this,e=b.linesApiNames,k=b.areaLinesNames,m=b.points,g=b.options,f=b.graph,v={options:{gapSize:g.gapSize}},q=[],p=b.getTranslatedLinesNames(b.pointValKey),u=m.length,h;p.forEach(function(b,a){for(q[a]=[];u--;)h=m[u],q[a].push({x:h.x,plotX:h.plotX,
plotY:h[b],isNull:!t(h[b])});u=m.length});if(this.userOptions.fillColor&&k.length){var r=p.indexOf(d(k[0]));r=q[r];k=1===k.length?m:q[p.indexOf(d(k[1]))];p=b.color;b.points=k;b.nextPoints=r;b.color=this.userOptions.fillColor;b.options=n(m,v);b.graph=b.area;b.fillGraph=!0;a.seriesTypes.sma.prototype.drawGraph.call(b);b.area=b.graph;delete b.nextPoints;delete b.fillGraph;b.color=p}e.forEach(function(a,e){q[e]?(b.points=q[e],g[a]?b.options=n(g[a].styles,v):c('Error: "There is no '+a+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names." at mixin/multiple-line.js:34'),
b.graph=b["graph"+a],l.prototype.drawGraph.call(b),b["graph"+a]=b.graph):c('Error: "'+a+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")});b.points=m;b.options=g;b.graph=f;l.prototype.drawGraph.call(b)}function v(b){var a=[];(this.pointArrayMap||[]).forEach(function(e){e!==b&&a.push(d(e))});return a}function d(b){return"plot"+b.charAt(0).toUpperCase()+b.slice(1)}function g(b){var a=[];(this.pointArrayMap||[]).forEach(function(e){a.push(b[e])});
return a}function q(){var b=this,a=b.pointArrayMap,d=[],g;d=b.getTranslatedLinesNames();l.prototype.translate.apply(b,arguments);b.points.forEach(function(e){a.forEach(function(a,q){g=e[a];b.dataModify&&(g=b.dataModify.modifyValue(g));null!==g&&(e[d[q]]=b.yAxis.toPixels(g,!0))})})}var u=[],y=["bottomLine"],z=["top","bottom"],r=["top"];f.compose=function(b){if(-1===u.indexOf(b)){u.push(b);var a=b.prototype;a.linesApiNames=a.linesApiNames||y.slice();a.pointArrayMap=a.pointArrayMap||z.slice();a.pointValKey=
a.pointValKey||"top";a.areaLinesNames=a.areaLinesNames||r.slice();a.drawGraph=p;a.getGraphPath=h;a.toYData=g;a.translate=q;a.getTranslatedLinesNames=v}return b}})(h||(h={}));return h});c(a,"Stock/Indicators/Stochastic/StochasticIndicator.js",[a["Stock/Indicators/ArrayUtilities.js"],a["Stock/Indicators/MultipleLinesComposition.js"],a["Core/Series/SeriesRegistry.js"],a["Core/Utilities.js"]],function(a,f,l,c){var t=this&&this.__extends||function(){var a=function(c,d){a=Object.setPrototypeOf||{__proto__:[]}instanceof
Array&&function(a,d){a.__proto__=d}||function(a,d){for(var c in d)d.hasOwnProperty(c)&&(a[c]=d[c])};return a(c,d)};return function(c,d){function g(){this.constructor=c}a(c,d);c.prototype=null===d?Object.create(d):(g.prototype=d.prototype,new g)}}(),n=l.seriesTypes.sma,h=c.extend,x=c.isArray,w=c.merge;c=function(c){function f(){var a=null!==c&&c.apply(this,arguments)||this;a.data=void 0;a.options=void 0;a.points=void 0;return a}t(f,c);f.prototype.init=function(){l.seriesTypes.sma.prototype.init.apply(this,
arguments);this.options=w({smoothedLine:{styles:{lineColor:this.color}}},this.options)};f.prototype.getValues=function(c,g){var d=g.periods[0];g=g.periods[1];var f=c.xData,h=(c=c.yData)?c.length:0,p=[],r=[],b=[],e=null,k;if(!(h<d)&&x(c[0])&&4===c[0].length){for(k=d-1;k<h;k++){var m=c.slice(k-d+1,k+1);var t=a.getArrayExtremes(m,2,1);var n=t[0];m=c[k][3]-n;n=t[1]-n;m=m/n*100;r.push(f[k]);b.push([m,null]);k>=d-1+(g-1)&&(e=l.seriesTypes.sma.prototype.getValues.call(this,{xData:r.slice(-g),yData:b.slice(-g)},
{period:g}),e=e.yData[0]);p.push([f[k],m,e]);b[b.length-1][1]=e}return{values:p,xData:r,yData:b}}};f.defaultOptions=w(n.defaultOptions,{params:{index:void 0,period:void 0,periods:[14,3]},marker:{enabled:!1},tooltip:{pointFormat:'<span style="color:{point.color}">\u25cf</span><b> {series.name}</b><br/>%K: {point.y}<br/>%D: {point.smoothed}<br/>'},smoothedLine:{styles:{lineWidth:1,lineColor:void 0}},dataGrouping:{approximation:"averages"}});return f}(n);h(c.prototype,{areaLinesNames:[],nameComponents:["periods"],
nameBase:"Stochastic",pointArrayMap:["y","smoothed"],parallelArrays:["x","y","smoothed"],pointValKey:"y",linesApiNames:["smoothedLine"]});f.compose(c);l.registerSeriesType("stochastic",c);"";return c});c(a,"masters/indicators/stochastic.src.js",[],function(){})});
//# sourceMappingURL=stochastic.js.map