highcharts
Version:
JavaScript charting framework
14 lines • 5.3 kB
JavaScript
!/**
* Highstock JS v13.0.1 (2026-08-17)
* @module highcharts/indicators/stochastic
* @requires highcharts
* @requires highcharts/modules/stock
*
* Indicator series type for Highcharts Stock
*
* (c) 2010-2026 Highsoft AS
* Author: Paweł Fus
*
* A commercial license may be required depending on use,
* see www.highcharts.com/license
*/function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(e._Highcharts,e._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/indicators/stochastic",["highcharts/highcharts"],function(e){return t(e,e.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/indicators/stochastic"]=t(e._Highcharts,e._Highcharts.SeriesRegistry):e.Highcharts=t(e.Highcharts,e.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(e,t)=>(()=>{"use strict";var r,i={512(e){e.exports=t},944(t){t.exports=e}};let o={};function a(e){let t=o[e];if(void 0!==t)return t.exports;let r=o[e]={exports:{}};return i[e](r,r.exports,a),r.exports}a.n=e=>{let t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var i=t[r++],o=t[r++];a.o(e,i)?0===o&&r++:0===o?Object.defineProperty(e,i,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:o})}else for(var i in t)a.o(t,i)&&!a.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let s={};a.d(s,{default:()=>g});var n=a(944),p=a.n(n);let l=function(e,t,r){return e.reduce((e,i)=>[Math.min(e[0],i[t]),Math.max(e[1],i[r])],[Number.MAX_VALUE,-Number.MAX_VALUE])};var h=a(512),c=a.n(h);let{sma:{prototype:u}}=c().seriesTypes;!function(e){let t=["bottomLine"],r=["top","bottom"],i=["top"];function o(e){return"plot"+e.charAt(0).toUpperCase()+e.slice(1)}function a(e,t){let r=[];return(e.pointArrayMap||[]).forEach(e=>{e!==t&&r.push(o(e))}),r}function s(){let e=this,t=e.pointValKey,r=e.linesApiNames,i=e.areaLinesNames,s=e.points,p=e.options,l=e.graph,h={options:{gapSize:p.gapSize}},c=[],d=a(e,t),f=s.length,y;if(d.forEach((e,t)=>{for(c[t]=[];f--;)y=s[f],c[t].push({x:y.x,plotX:y.plotX,plotY:y[e],isNull:!(0,n.defined)(y[e])});f=s.length}),e.userOptions.fillColor&&i.length){let t=c[d.indexOf(o(i[0]))],r=1===i.length?s:c[d.indexOf(o(i[1]))],a=e.color;e.points=r,e.nextPoints=t,e.color=e.userOptions.fillColor,e.options=(0,n.merge)(s,h),e.graph=e.area,e.fillGraph=!0,u.drawGraph.call(e),e.area=e.graph,delete e.nextPoints,delete e.fillGraph,e.color=a}r.forEach((t,r)=>{c[r]?(e.points=c[r],p[t]?e.options=(0,n.merge)(p[t].styles,h):(0,n.error)('Error: "There is no '+t+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names."'),e.graph=e["graph"+t],u.drawGraph.call(e),e["graph"+t]=e.graph):(0,n.error)('Error: "'+t+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),e.points=s,e.options=p,e.graph=l,u.drawGraph.call(e)}function p(e){let t,r=[],i=[];if(e=e||this.points,this.fillGraph&&this.nextPoints){if((t=u.getGraphPath.call(this,this.nextPoints))&&t.length){t[0][0]="L",r=u.getGraphPath.call(this,e),i=t.slice(0,r.length);for(let e=i.length-1;e>=0;e--)r.push(i[e])}}else r=u.getGraphPath.apply(this,arguments);return r}function l(e){let t=[];return(this.pointArrayMap||[]).forEach(r=>{t.push(e[r])}),t}function h(){let e=this.pointArrayMap,t=[],r;t=a(this),u.translate.apply(this,arguments),this.points.forEach(i=>{e.forEach((e,o)=>{r=i[e],this.dataModify&&(r=this.dataModify.modifyValue(r)),null!==r&&(i[t[o]]=this.yAxis.toPixels(r,!0))})})}e.compose=function(e){let o=e.prototype;return o.linesApiNames=o.linesApiNames||t.slice(),o.pointArrayMap=o.pointArrayMap||r.slice(),o.pointValKey=o.pointValKey||"top",o.areaLinesNames=o.areaLinesNames||i.slice(),o.drawGraph=s,o.getGraphPath=p,o.toYData=l,o.translate=h,e}}(r||(r={}));let d=r,{sma:f}=c().seriesTypes;class y extends f{init(){super.init.apply(this,arguments),this.options=(0,n.merge)({smoothedLine:{styles:{lineColor:this.color}}},this.options)}getValues(e,t){let r=t.periods[0],i=t.periods[1],o=e.xData,a=e.yData,s=a?a.length:0,p=[],h=[],c=[],u,d,f=null,y,g;if(s<r||!(0,n.isArray)(a[0])||4!==a[0].length)return;let m=!0,x=0;for(g=r-1;g<s;g++){if(u=(y=l(a.slice(g-r+1,g+1),2,1))[0],isNaN(d=(a[g][3]-u)/(y[1]-u)*100)&&m){x++;continue}m&&!isNaN(d)&&(m=!1);let e=h.push(o[g]);isNaN(d)?c.push([c[e-2]&&"number"==typeof c[e-2][0]?c[e-2][0]:null,null]):c.push([d,null]),g>=x+(r-1)+(i-1)&&(f=super.getValues({xData:h.slice(-i),yData:c.slice(-i)},{period:i}).yData[0]),p.push([o[g],d,f]),c[e-1][1]=f}return{values:p,xData:h,yData:c}}}y.defaultOptions=(0,n.merge)(f.defaultOptions,{params:{index:void 0,period:void 0,periods:[14,3]},marker:{enabled:!1},tooltip:{pointFormat:'<span style="color:{point.color}">●</span><b> {series.name}</b><br/>%K: {point.y}<br/>%D: {point.smoothed}<br/>'},smoothedLine:{styles:{lineWidth:1,lineColor:void 0}},dataGrouping:{approximation:"averages"}}),(0,n.extend)(y.prototype,{areaLinesNames:[],nameComponents:["periods"],nameBase:"Stochastic",pointArrayMap:["y","smoothed"],parallelArrays:["x","y","smoothed"],pointValKey:"y",linesApiNames:["smoothedLine"]}),d.compose(y),c().registerSeriesType("stochastic",y);let g=p();return s.default})());