UNPKG

highcharts

Version:
14 lines 4.45 kB
/** * Highstock JS v13.0.1 (2026-08-17) * @module highcharts/indicators/acceleration-bands * @requires highcharts * @requires highcharts/modules/stock * * Indicator series type for Highcharts Stock * * (c) 2010-2026 Highsoft AS * Author: Daniel Studencki * * 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 a=e&&e.__esModule?()=>e.default:()=>e;return t.d(a,{a:a}),a},t.d=(e,a)=>{if(Array.isArray(a))for(var r=0;r<a.length;){var i=a[r++],o=a[r++];t.o(e,i)?0===o&&r++:0===o?Object.defineProperty(e,i,{enumerable:!0,value:a[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:o})}else for(var i in a)t.o(a,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:a[i]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let a=e.default;var r,i=t.n(a);let o=e.default.SeriesRegistry;var s=t.n(o);let{sma:{prototype:l}}=s().seriesTypes;!function(e){let t=["bottomLine"],r=["top","bottom"],i=["top"];function o(e){return"plot"+e.charAt(0).toUpperCase()+e.slice(1)}function s(e,t){let a=[];return(e.pointArrayMap||[]).forEach(e=>{e!==t&&a.push(o(e))}),a}function n(){let e=this,t=e.pointValKey,r=e.linesApiNames,i=e.areaLinesNames,n=e.points,p=e.options,h=e.graph,c={options:{gapSize:p.gapSize}},d=[],u=s(e,t),f=n.length,y;if(u.forEach((e,t)=>{for(d[t]=[];f--;)y=n[f],d[t].push({x:y.x,plotX:y.plotX,plotY:y[e],isNull:!(0,a.defined)(y[e])});f=n.length}),e.userOptions.fillColor&&i.length){let t=d[u.indexOf(o(i[0]))],r=1===i.length?n:d[u.indexOf(o(i[1]))],s=e.color;e.points=r,e.nextPoints=t,e.color=e.userOptions.fillColor,e.options=(0,a.merge)(n,c),e.graph=e.area,e.fillGraph=!0,l.drawGraph.call(e),e.area=e.graph,delete e.nextPoints,delete e.fillGraph,e.color=s}r.forEach((t,r)=>{d[r]?(e.points=d[r],p[t]?e.options=(0,a.merge)(p[t].styles,c):(0,a.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],l.drawGraph.call(e),e["graph"+t]=e.graph):(0,a.error)('Error: "'+t+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),e.points=n,e.options=p,e.graph=h,l.drawGraph.call(e)}function p(e){let t,a=[],r=[];if(e=e||this.points,this.fillGraph&&this.nextPoints){if((t=l.getGraphPath.call(this,this.nextPoints))&&t.length){t[0][0]="L",a=l.getGraphPath.call(this,e),r=t.slice(0,a.length);for(let e=r.length-1;e>=0;e--)a.push(r[e])}}else a=l.getGraphPath.apply(this,arguments);return a}function h(e){let t=[];return(this.pointArrayMap||[]).forEach(a=>{t.push(e[a])}),t}function c(){let e=this.pointArrayMap,t=[],a;t=s(this),l.translate.apply(this,arguments),this.points.forEach(r=>{e.forEach((e,i)=>{a=r[e],this.dataModify&&(a=this.dataModify.modifyValue(a)),null!==a&&(r[t[i]]=this.yAxis.toPixels(a,!0))})})}e.compose=function(e){let a=e.prototype;return a.linesApiNames=a.linesApiNames||t.slice(),a.pointArrayMap=a.pointArrayMap||r.slice(),a.pointValKey=a.pointValKey||"top",a.areaLinesNames=a.areaLinesNames||i.slice(),a.drawGraph=n,a.getGraphPath=p,a.toYData=h,a.translate=c,e}}(r||(r={}));let n=r,{sma:p}=s().seriesTypes;class h extends p{getValues(e,t){let r,i,o,s,l,n,p,h,c,d,u,f=t.period,y=t.factor,m=t.index,g=e.xData,x=e.yData,A=x?x.length:0,D=[],b=[],O=[],P=[],v=[];if(!(A<f)){for(u=0;u<=A;u++){if(u<A){var G,M,N,L;G=x[u][2],M=x[u][1],l=(0,a.correctFloat)(M-G)/((0,a.correctFloat)(M+G)/2)*1e3*y,D.push((N=x[u][1],N*(0,a.correctFloat)(1+2*l))),b.push((L=x[u][2],L*(0,a.correctFloat)(1-2*l)))}u>=f&&(c=g.slice(u-f,u),d=x.slice(u-f,u),p=super.getValues.call(this,{xData:c,yData:D.slice(u-f,u)},{period:f}),h=super.getValues.call(this,{xData:c,yData:b.slice(u-f,u)},{period:f}),s=(n=super.getValues.call(this,{xData:c,yData:d},{period:f,index:m})).xData[0],i=p.yData[0],o=h.yData[0],r=n.yData[0],O.push([s,i,r,o]),P.push(s),v.push([i,r,o]))}return{values:O,xData:P,yData:v}}}}h.defaultOptions=(0,a.merge)(p.defaultOptions,{params:{period:20,factor:.001,index:3},lineWidth:1,topLine:{styles:{lineWidth:1}},bottomLine:{styles:{lineWidth:1}},dataGrouping:{approximation:"averages"}}),(0,a.extend)(h.prototype,{areaLinesNames:["top","bottom"],linesApiNames:["topLine","bottomLine"],nameBase:"Acceleration Bands",nameComponents:["period","factor"],pointArrayMap:["top","middle","bottom"],pointValKey:"middle"}),n.compose(h),s().registerSeriesType("abands",h);let c=i();export{c as default};