highcharts
Version:
JavaScript charting framework
14 lines • 4.52 kB
JavaScript
/**
* Highstock JS v13.0.1 (2026-08-17)
* @module highcharts/indicators/price-envelopes
* @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 a=0;a<o.length;){var r=o[a++],i=o[a++];t.o(e,r)?0===i&&a++:0===i?Object.defineProperty(e,r,{enumerable:!0,value:o[a++]}):Object.defineProperty(e,r,{enumerable:!0,get:i})}else for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let o=e.default;var a,r=t.n(o);let i=e.default.SeriesRegistry;var n=t.n(i);let{sma:{prototype:s}}=n().seriesTypes;!function(e){let t=["bottomLine"],a=["top","bottom"],r=["top"];function i(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(i(e))}),o}function l(){let e=this,t=e.pointValKey,a=e.linesApiNames,r=e.areaLinesNames,l=e.points,p=e.options,h=e.graph,d={options:{gapSize:p.gapSize}},c=[],m=n(e,t),y=l.length,f;if(m.forEach((e,t)=>{for(c[t]=[];y--;)f=l[y],c[t].push({x:f.x,plotX:f.plotX,plotY:f[e],isNull:!(0,o.defined)(f[e])});y=l.length}),e.userOptions.fillColor&&r.length){let t=c[m.indexOf(i(r[0]))],a=1===r.length?l:c[m.indexOf(i(r[1]))],n=e.color;e.points=a,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}a.forEach((t,a)=>{c[a]?(e.points=c[a],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=[],a=[];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),a=t.slice(0,o.length);for(let e=a.length-1;e>=0;e--)o.push(a[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(a=>{e.forEach((e,r)=>{o=a[e],this.dataModify&&(o=this.dataModify.modifyValue(o)),null!==o&&(a[t[r]]=this.yAxis.toPixels(o,!0))})})}e.compose=function(e){let o=e.prototype;return o.linesApiNames=o.linesApiNames||t.slice(),o.pointArrayMap=o.pointArrayMap||a.slice(),o.pointValKey=o.pointValKey||"top",o.areaLinesNames=o.areaLinesNames||r.slice(),o.drawGraph=l,o.getGraphPath=p,o.toYData=h,o.translate=d,e}}(a||(a={}));let l=a,{sma:p}=n().seriesTypes;class h extends p{init(){super.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 a,r,i,n,s,l,p,h,d=t.period,c=t.topBand,m=t.bottomBand,y=e.xData,f=e.yData,u=f?f.length:0,g=[],b=[],A=[];if(!(y.length<d)&&(0,o.isArray)(f[0])&&4===f[0].length){for(h=d;h<=u;h++)s=y.slice(h-d,h),l=f.slice(h-d,h),n=(p=super.getValues({xData:s,yData:l},t)).xData[0],r=(a=p.yData[0])*(1+c),i=a*(1-m),g.push([n,r,a,i]),b.push(n),A.push([r,a,i]);return{values:g,xData:b,yData:A}}}}h.defaultOptions=(0,o.merge)(p.defaultOptions,{marker:{enabled:!1},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/>'},params:{period:20,topBand:.1,bottomBand:.1},bottomLine:{styles:{lineWidth:1,lineColor:void 0}},topLine:{styles:{lineWidth:1}},dataGrouping:{approximation:"averages"}}),(0,o.extend)(h.prototype,{areaLinesNames:["top","bottom"],linesApiNames:["topLine","bottomLine"],nameComponents:["period","topBand","bottomBand"],nameBase:"Price envelopes",pointArrayMap:["top","middle","bottom"],parallelArrays:["x","y","top","bottom"],pointValKey:"middle"}),l.compose(h),n().registerSeriesType("priceenvelopes",h);let d=r();export{d as default};