highcharts
Version:
JavaScript charting framework
14 lines • 4.93 kB
JavaScript
/**
* Highstock JS v12.6.0 (2026-04-13)
* @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 t from"../highcharts.js";var e,a={};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);let r=t.default;var o=a.n(r);let i=t.default.SeriesRegistry;var n=a.n(i);let{doc:s,win:l}=o();function p(t,e){return t>1e14?t:parseFloat(t.toPrecision(e||14))}function c(t){return h(t)&&"number"==typeof t.nodeType}function h(t,e){let a;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(a=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==a)}function u(t,...e){let a,r=[t,...e],o={},i=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,a){for(let a in t)Object.hasOwnProperty.call(t,a)&&e.call((0,t[a]),t[a],a,t)}(e,function(a,r){if("__proto__"!==r&&"constructor"!==r){let o;!h(a,!0)||(o=a?.constructor,h(a,!0)&&!c(a)&&o?.name&&"Object"!==o.name)||c(a)?t[r]=e[r]:t[r]=i(t[r]||{},a)}}),t};!0===t&&(o=r[1],r=Array.prototype.slice.call(r,2));let n=r.length;for(a=0;a<n;a++)o=i(o,r[a]);return o}Array.prototype.find;let{sma:{prototype:f}}=n().seriesTypes;!function(t){let e=["bottomLine"],a=["top","bottom"],o=["top"];function i(t){return"plot"+t.charAt(0).toUpperCase()+t.slice(1)}function n(t,e){let a=[];return(t.pointArrayMap||[]).forEach(t=>{t!==e&&a.push(i(t))}),a}function s(){let t=this,e=t.pointValKey,a=t.linesApiNames,o=t.areaLinesNames,s=t.points,l=t.options,p=t.graph,c={options:{gapSize:l.gapSize}},h=[],y=n(t,e),d=s.length,m;if(y.forEach((t,e)=>{for(h[e]=[];d--;)m=s[d],h[e].push({x:m.x,plotX:m.plotX,plotY:m[t],isNull:null==m[t]});d=s.length}),t.userOptions.fillColor&&o.length){let e=h[y.indexOf(i(o[0]))],a=1===o.length?s:h[y.indexOf(i(o[1]))],r=t.color;t.points=a,t.nextPoints=e,t.color=t.userOptions.fillColor,t.options=u(s,c),t.graph=t.area,t.fillGraph=!0,f.drawGraph.call(t),t.area=t.graph,delete t.nextPoints,delete t.fillGraph,t.color=r}a.forEach((e,a)=>{h[a]?(t.points=h[a],l[e]?t.options=u(l[e].styles,c):(0,r.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],f.drawGraph.call(t),t["graph"+e]=t.graph):(0,r.error)('Error: "'+e+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),t.points=s,t.options=l,t.graph=p,f.drawGraph.call(t)}function l(t){let e,a=[],r=[];if(t=t||this.points,this.fillGraph&&this.nextPoints){if((e=f.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",a=f.getGraphPath.call(this,t),r=e.slice(0,a.length);for(let t=r.length-1;t>=0;t--)a.push(r[t])}}else a=f.getGraphPath.apply(this,arguments);return a}function p(t){let e=[];return(this.pointArrayMap||[]).forEach(a=>{e.push(t[a])}),e}function c(){let t=this.pointArrayMap,e=[],a;e=n(this),f.translate.apply(this,arguments),this.points.forEach(r=>{t.forEach((t,o)=>{a=r[t],this.dataModify&&(a=this.dataModify.modifyValue(a)),null!==a&&(r[e[o]]=this.yAxis.toPixels(a,!0))})})}t.compose=function(t){let r=t.prototype;return r.linesApiNames=r.linesApiNames||e.slice(),r.pointArrayMap=r.pointArrayMap||a.slice(),r.pointValKey=r.pointValKey||"top",r.areaLinesNames=r.areaLinesNames||o.slice(),r.drawGraph=s,r.getGraphPath=l,r.toYData=p,r.translate=c,t}}(e||(e={}));let y=e,{sma:d}=n().seriesTypes;class m extends d{getValues(t,e){let a,r,o,i,n,s,l,c,h,u,f,y=e.period,d=e.factor,m=e.index,g=t.xData,x=t.yData,A=x?x.length:0,b=[],D=[],O=[],P=[],G=[];if(!(A<y)){for(f=0;f<=A;f++){if(f<A){var v,M;v=x[f][2],M=x[f][1],n=p(M-v)/(p(M+v)/2)*1e3*d,b.push(x[f][1]*p(1+2*n)),D.push(x[f][2]*p(1-2*n))}f>=y&&(h=g.slice(f-y,f),u=x.slice(f-y,f),l=super.getValues.call(this,{xData:h,yData:b.slice(f-y,f)},{period:y}),c=super.getValues.call(this,{xData:h,yData:D.slice(f-y,f)},{period:y}),i=(s=super.getValues.call(this,{xData:h,yData:u},{period:y,index:m})).xData[0],r=l.yData[0],o=c.yData[0],a=s.yData[0],O.push([i,r,a,o]),P.push(i),G.push([r,a,o]))}return{values:O,xData:P,yData:G}}}}m.defaultOptions=u(d.defaultOptions,{params:{period:20,factor:.001,index:3},lineWidth:1,topLine:{styles:{lineWidth:1}},bottomLine:{styles:{lineWidth:1}},dataGrouping:{approximation:"averages"}}),function(t,e){let a;for(a in t||(t={}),e)t[a]=e[a]}(m.prototype,{areaLinesNames:["top","bottom"],linesApiNames:["topLine","bottomLine"],nameBase:"Acceleration Bands",nameComponents:["period","factor"],pointArrayMap:["top","middle","bottom"],pointValKey:"middle"}),y.compose(m),n().registerSeriesType("abands",m);let g=o();export{g as default};