highcharts
Version:
JavaScript charting framework
14 lines • 5.8 kB
JavaScript
!/**
* Highstock JS v12.6.0 (2026-04-13)
* @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(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts,t._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/indicators/stochastic",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/indicators/stochastic"]=e(t._Highcharts,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(t,e)=>(()=>{"use strict";var r,o={512:t=>{t.exports=e},944:e=>{e.exports=t}},i={};function a(t){var e=i[t];if(void 0!==e)return e.exports;var r=i[t]={exports:{}};return o[t](r,r.exports,a),r.exports}a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};a.d(n,{default:()=>v});var s=a(944),p=a.n(s);let l=function(t,e,r){return t.reduce((t,o)=>[Math.min(t[0],o[e]),Math.max(t[1],o[r])],[Number.MAX_VALUE,-Number.MAX_VALUE])};var h=a(512),c=a.n(h);let{doc:u,win:f}=p();function y(t){return g(t)&&"number"==typeof t.nodeType}function d(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function g(t,e){return!!t&&"object"==typeof t&&(!e||!d(t))}function m(t,...e){let r,o=[t,...e],i={},a=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,r){for(let r in t)Object.hasOwnProperty.call(t,r)&&e.call((0,t[r]),t[r],r,t)}(e,function(r,o){if("__proto__"!==o&&"constructor"!==o){let i;!g(r,!0)||(i=r?.constructor,g(r,!0)&&!y(r)&&i?.name&&"Object"!==i.name)||y(r)?t[o]=e[o]:t[o]=a(t[o]||{},r)}}),t};!0===t&&(i=o[1],o=Array.prototype.slice.call(o,2));let n=o.length;for(r=0;r<n;r++)i=a(i,o[r]);return i}Array.prototype.find;let{sma:{prototype:x}}=c().seriesTypes;!function(t){let e=["bottomLine"],r=["top","bottom"],o=["top"];function i(t){return"plot"+t.charAt(0).toUpperCase()+t.slice(1)}function a(t,e){let r=[];return(t.pointArrayMap||[]).forEach(t=>{t!==e&&r.push(i(t))}),r}function n(){let t=this,e=t.pointValKey,r=t.linesApiNames,o=t.areaLinesNames,n=t.points,p=t.options,l=t.graph,h={options:{gapSize:p.gapSize}},c=[],u=a(t,e),f=n.length,y;if(u.forEach((t,e)=>{for(c[e]=[];f--;)y=n[f],c[e].push({x:y.x,plotX:y.plotX,plotY:y[t],isNull:null==y[t]});f=n.length}),t.userOptions.fillColor&&o.length){let e=c[u.indexOf(i(o[0]))],r=1===o.length?n:c[u.indexOf(i(o[1]))],a=t.color;t.points=r,t.nextPoints=e,t.color=t.userOptions.fillColor,t.options=m(n,h),t.graph=t.area,t.fillGraph=!0,x.drawGraph.call(t),t.area=t.graph,delete t.nextPoints,delete t.fillGraph,t.color=a}r.forEach((e,r)=>{c[r]?(t.points=c[r],p[e]?t.options=m(p[e].styles,h):(0,s.error)('Error: "There is no '+e+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names."'),t.graph=t["graph"+e],x.drawGraph.call(t),t["graph"+e]=t.graph):(0,s.error)('Error: "'+e+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),t.points=n,t.options=p,t.graph=l,x.drawGraph.call(t)}function p(t){let e,r=[],o=[];if(t=t||this.points,this.fillGraph&&this.nextPoints){if((e=x.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",r=x.getGraphPath.call(this,t),o=e.slice(0,r.length);for(let t=o.length-1;t>=0;t--)r.push(o[t])}}else r=x.getGraphPath.apply(this,arguments);return r}function l(t){let e=[];return(this.pointArrayMap||[]).forEach(r=>{e.push(t[r])}),e}function h(){let t=this.pointArrayMap,e=[],r;e=a(this),x.translate.apply(this,arguments),this.points.forEach(o=>{t.forEach((t,i)=>{r=o[t],this.dataModify&&(r=this.dataModify.modifyValue(r)),null!==r&&(o[e[i]]=this.yAxis.toPixels(r,!0))})})}t.compose=function(t){let i=t.prototype;return i.linesApiNames=i.linesApiNames||e.slice(),i.pointArrayMap=i.pointArrayMap||r.slice(),i.pointValKey=i.pointValKey||"top",i.areaLinesNames=i.areaLinesNames||o.slice(),i.drawGraph=n,i.getGraphPath=p,i.toYData=l,i.translate=h,t}}(r||(r={}));let b=r,{sma:A}=c().seriesTypes;class N extends A{init(){super.init.apply(this,arguments),this.options=m({smoothedLine:{styles:{lineColor:this.color}}},this.options)}getValues(t,e){let r=e.periods[0],o=e.periods[1],i=t.xData,a=t.yData,n=a?a.length:0,s=[],p=[],h=[],c,u,f=null,y,g;if(n<r||!d(a[0])||4!==a[0].length)return;let m=!0,x=0;for(g=r-1;g<n;g++){if(c=(y=l(a.slice(g-r+1,g+1),2,1))[0],isNaN(u=(a[g][3]-c)/(y[1]-c)*100)&&m){x++;continue}m&&!isNaN(u)&&(m=!1);let t=p.push(i[g]);isNaN(u)?h.push([h[t-2]&&"number"==typeof h[t-2][0]?h[t-2][0]:null,null]):h.push([u,null]),g>=x+(r-1)+(o-1)&&(f=super.getValues({xData:p.slice(-o),yData:h.slice(-o)},{period:o}).yData[0]),s.push([i[g],u,f]),h[t-1][1]=f}return{values:s,xData:p,yData:h}}}N.defaultOptions=m(A.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"}}),function(t,e){let r;for(r in t||(t={}),e)t[r]=e[r]}(N.prototype,{areaLinesNames:[],nameComponents:["periods"],nameBase:"Stochastic",pointArrayMap:["y","smoothed"],parallelArrays:["x","y","smoothed"],pointValKey:"y",linesApiNames:["smoothedLine"]}),b.compose(N),c().registerSeriesType("stochastic",N);let v=p();return n.default})());