highcharts
Version:
JavaScript charting framework
14 lines • 4.63 kB
JavaScript
/**
* Highstock JS v13.0.1 (2026-08-17)
* @module highcharts/indicators/bollinger-bands
* @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
*/import*as e from"../highcharts.js";let t={};t.n=e=>{let o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},t.d=(e,o)=>{if(Array.isArray(o))for(var i=0;i<o.length;){var a=o[i++],r=o[i++];t.o(e,a)?0===r&&i++:0===r?Object.defineProperty(e,a,{enumerable:!0,value:o[i++]}):Object.defineProperty(e,a,{enumerable:!0,get:r})}else for(var a in o)t.o(o,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:o[a]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let o=e.default;var i,a=t.n(o);let r=e.default.SeriesRegistry;var n=t.n(r);let{sma:{prototype:s}}=n().seriesTypes;!function(e){let t=["bottomLine"],i=["top","bottom"],a=["top"];function r(e){return"plot"+e.charAt(0).toUpperCase()+e.slice(1)}function n(e,t){let o=[];return(e.pointArrayMap||[]).forEach(e=>{e!==t&&o.push(r(e))}),o}function l(){let e=this,t=e.pointValKey,i=e.linesApiNames,a=e.areaLinesNames,l=e.points,p=e.options,h=e.graph,d={options:{gapSize:p.gapSize}},c=[],y=n(e,t),f=l.length,m;if(y.forEach((e,t)=>{for(c[t]=[];f--;)m=l[f],c[t].push({x:m.x,plotX:m.plotX,plotY:m[e],isNull:!(0,o.defined)(m[e])});f=l.length}),e.userOptions.fillColor&&a.length){let t=c[y.indexOf(r(a[0]))],i=1===a.length?l:c[y.indexOf(r(a[1]))],n=e.color;e.points=i,e.nextPoints=t,e.color=e.userOptions.fillColor,e.options=(0,o.merge)(l,d),e.graph=e.area,e.fillGraph=!0,s.drawGraph.call(e),e.area=e.graph,delete e.nextPoints,delete e.fillGraph,e.color=n}i.forEach((t,i)=>{c[i]?(e.points=c[i],p[t]?e.options=(0,o.merge)(p[t].styles,d):(0,o.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],s.drawGraph.call(e),e["graph"+t]=e.graph):(0,o.error)('Error: "'+t+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),e.points=l,e.options=p,e.graph=h,s.drawGraph.call(e)}function p(e){let t,o=[],i=[];if(e=e||this.points,this.fillGraph&&this.nextPoints){if((t=s.getGraphPath.call(this,this.nextPoints))&&t.length){t[0][0]="L",o=s.getGraphPath.call(this,e),i=t.slice(0,o.length);for(let e=i.length-1;e>=0;e--)o.push(i[e])}}else o=s.getGraphPath.apply(this,arguments);return o}function h(e){let t=[];return(this.pointArrayMap||[]).forEach(o=>{t.push(e[o])}),t}function d(){let e=this.pointArrayMap,t=[],o;t=n(this),s.translate.apply(this,arguments),this.points.forEach(i=>{e.forEach((e,a)=>{o=i[e],this.dataModify&&(o=this.dataModify.modifyValue(o)),null!==o&&(i[t[a]]=this.yAxis.toPixels(o,!0))})})}e.compose=function(e){let o=e.prototype;return o.linesApiNames=o.linesApiNames||t.slice(),o.pointArrayMap=o.pointArrayMap||i.slice(),o.pointValKey=o.pointValKey||"top",o.areaLinesNames=o.areaLinesNames||a.slice(),o.drawGraph=l,o.getGraphPath=p,o.toYData=h,o.translate=d,e}}(i||(i={}));let l=i,{sma:p}=n().seriesTypes;class h extends p{init(){n().seriesTypes.sma.prototype.init.apply(this,arguments),this.options=(0,o.merge)({topLine:{styles:{lineColor:this.color}},bottomLine:{styles:{lineColor:this.color}}},this.options)}getValues(e,t){let i,a,r,s,l,p,h,d,c,y=t.period,f=t.standardDeviation,m=[],u=[],g=e.xData,b=e.yData,x=b?b.length:0,A=[];if(g.length<y)return;let v=(0,o.isArray)(b[0]);for(c=y;c<=x;c++)l=g.slice(c-y,c),p=b.slice(c-y,c),s=(d=n().seriesTypes.sma.prototype.getValues.call(this,{xData:l,yData:p},t)).xData[0],i=d.yData[0],h=function(e,t,o,i){let a=e.length,r=0,n,s=0;for(;r<a;r++)s+=(n=(o?e[r][t]:e[r])-i)*n;return Math.sqrt(s/=a-1)}(p,t.index,v,i),a=i+f*h,r=i-f*h,A.push([s,a,i,r]),m.push(s),u.push([a,i,r]);return{values:A,xData:m,yData:u}}}h.defaultOptions=(0,o.merge)(p.defaultOptions,{params:{period:20,standardDeviation:2,index:3},bottomLine:{styles:{lineWidth:1,lineColor:void 0}},topLine:{styles:{lineWidth:1,lineColor:void 0}},tooltip:{pointFormat:'<span style="color:{point.color}">●</span><b> {series.name}</b><br/>Top: {point.top}<br/>Middle: {point.middle}<br/>Bottom: {point.bottom}<br/>'},marker:{enabled:!1},dataGrouping:{approximation:"averages"}}),(0,o.extend)(h.prototype,{areaLinesNames:["top","bottom"],linesApiNames:["topLine","bottomLine"],nameComponents:["period","standardDeviation"],pointArrayMap:["top","middle","bottom"],pointValKey:"middle"}),l.compose(h),n().registerSeriesType("bb",h);let d=a();export{d as default};