UNPKG

highcharts

Version:
14 lines 5.77 kB
!/** * Highstock JS v12.6.0 (2026-04-13) * @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 */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/bollinger-bands",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/indicators/bollinger-bands"]=e(t._Highcharts,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(t,e)=>(()=>{"use strict";var o,r={512:t=>{t.exports=e},944:e=>{e.exports=t}},i={};function n(t){var e=i[t];if(void 0!==e)return e.exports;var o=i[t]={exports:{}};return r[t](o,o.exports,n),o.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var a={};n.d(a,{default:()=>v});var s=n(944),p=n.n(s),l=n(512),h=n.n(l);let{doc:c,win:u}=p();function f(t){return y(t)&&"number"==typeof t.nodeType}function d(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function y(t,e){return!!t&&"object"==typeof t&&(!e||!d(t))}function g(t,...e){let o,r=[t,...e],i={},n=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,o){for(let o in t)Object.hasOwnProperty.call(t,o)&&e.call((0,t[o]),t[o],o,t)}(e,function(o,r){if("__proto__"!==r&&"constructor"!==r){let i;!y(o,!0)||(i=o?.constructor,y(o,!0)&&!f(o)&&i?.name&&"Object"!==i.name)||f(o)?t[r]=e[r]:t[r]=n(t[r]||{},o)}}),t};!0===t&&(i=r[1],r=Array.prototype.slice.call(r,2));let a=r.length;for(o=0;o<a;o++)i=n(i,r[o]);return i}Array.prototype.find;let{sma:{prototype:m}}=h().seriesTypes;!function(t){let e=["bottomLine"],o=["top","bottom"],r=["top"];function i(t){return"plot"+t.charAt(0).toUpperCase()+t.slice(1)}function n(t,e){let o=[];return(t.pointArrayMap||[]).forEach(t=>{t!==e&&o.push(i(t))}),o}function a(){let t=this,e=t.pointValKey,o=t.linesApiNames,r=t.areaLinesNames,a=t.points,p=t.options,l=t.graph,h={options:{gapSize:p.gapSize}},c=[],u=n(t,e),f=a.length,d;if(u.forEach((t,e)=>{for(c[e]=[];f--;)d=a[f],c[e].push({x:d.x,plotX:d.plotX,plotY:d[t],isNull:null==d[t]});f=a.length}),t.userOptions.fillColor&&r.length){let e=c[u.indexOf(i(r[0]))],o=1===r.length?a:c[u.indexOf(i(r[1]))],n=t.color;t.points=o,t.nextPoints=e,t.color=t.userOptions.fillColor,t.options=g(a,h),t.graph=t.area,t.fillGraph=!0,m.drawGraph.call(t),t.area=t.graph,delete t.nextPoints,delete t.fillGraph,t.color=n}o.forEach((e,o)=>{c[o]?(t.points=c[o],p[e]?t.options=g(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],m.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=a,t.options=p,t.graph=l,m.drawGraph.call(t)}function p(t){let e,o=[],r=[];if(t=t||this.points,this.fillGraph&&this.nextPoints){if((e=m.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",o=m.getGraphPath.call(this,t),r=e.slice(0,o.length);for(let t=r.length-1;t>=0;t--)o.push(r[t])}}else o=m.getGraphPath.apply(this,arguments);return o}function l(t){let e=[];return(this.pointArrayMap||[]).forEach(o=>{e.push(t[o])}),e}function h(){let t=this.pointArrayMap,e=[],o;e=n(this),m.translate.apply(this,arguments),this.points.forEach(r=>{t.forEach((t,i)=>{o=r[t],this.dataModify&&(o=this.dataModify.modifyValue(o)),null!==o&&(r[e[i]]=this.yAxis.toPixels(o,!0))})})}t.compose=function(t){let i=t.prototype;return i.linesApiNames=i.linesApiNames||e.slice(),i.pointArrayMap=i.pointArrayMap||o.slice(),i.pointValKey=i.pointValKey||"top",i.areaLinesNames=i.areaLinesNames||r.slice(),i.drawGraph=a,i.getGraphPath=p,i.toYData=l,i.translate=h,t}}(o||(o={}));let b=o,{sma:x}=h().seriesTypes;class A extends x{init(){h().seriesTypes.sma.prototype.init.apply(this,arguments),this.options=g({topLine:{styles:{lineColor:this.color}},bottomLine:{styles:{lineColor:this.color}}},this.options)}getValues(t,e){let o,r,i,n,a,s,p,l,c,u=e.period,f=e.standardDeviation,y=[],g=[],m=t.xData,b=t.yData,x=b?b.length:0,A=[];if(m.length<u)return;let v=d(b[0]);for(c=u;c<=x;c++)a=m.slice(c-u,c),s=b.slice(c-u,c),n=(l=h().seriesTypes.sma.prototype.getValues.call(this,{xData:a,yData:s},e)).xData[0],o=l.yData[0],p=function(t,e,o,r){let i=t.length,n=0,a,s=0;for(;n<i;n++)s+=(a=(o?t[n][e]:t[n])-r)*a;return Math.sqrt(s/=i-1)}(s,e.index,v,o),r=o+f*p,i=o-f*p,A.push([n,r,o,i]),y.push(n),g.push([r,o,i]);return{values:A,xData:y,yData:g}}}A.defaultOptions=g(x.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"}}),function(t,e){let o;for(o in t||(t={}),e)t[o]=e[o]}(A.prototype,{areaLinesNames:["top","bottom"],linesApiNames:["topLine","bottomLine"],nameComponents:["period","standardDeviation"],pointArrayMap:["top","middle","bottom"],pointValKey:"middle"}),b.compose(A),h().registerSeriesType("bb",A);let v=p();return a.default})());