highcharts
Version:
JavaScript charting framework
12 lines • 4.25 kB
JavaScript
/**
* Highstock JS v12.3.0 (2025-06-21)
* @module highcharts/indicators/price-envelopes
* @requires highcharts
* @requires highcharts/modules/stock
*
* Indicator series type for Highcharts Stock
*
* (c) 2010-2025 Paweł Fus
*
* License: www.highcharts.com/license
*/import*as t from"../highcharts.js";import"../modules/stock.js";var e,o={};o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var a in e)o.o(e,a)&&!o.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let a=t.default;var i=o.n(a);o.d({},{});let r=t.default.SeriesRegistry;var s=o.n(r);let{sma:{prototype:n}}=s().seriesTypes,{defined:p,error:l,merge:h}=i();!function(t){let e=["bottomLine"],o=["top","bottom"],a=["top"];function i(t){return"plot"+t.charAt(0).toUpperCase()+t.slice(1)}function r(t,e){let o=[];return(t.pointArrayMap||[]).forEach(t=>{t!==e&&o.push(i(t))}),o}function s(){let t=this,e=t.pointValKey,o=t.linesApiNames,a=t.areaLinesNames,s=t.points,c=t.options,d=t.graph,m={options:{gapSize:c.gapSize}},u=[],y=r(t,e),f=s.length,g;if(y.forEach((t,e)=>{for(u[e]=[];f--;)g=s[f],u[e].push({x:g.x,plotX:g.plotX,plotY:g[t],isNull:!p(g[t])});f=s.length}),t.userOptions.fillColor&&a.length){let e=u[y.indexOf(i(a[0]))],o=1===a.length?s:u[y.indexOf(i(a[1]))],r=t.color;t.points=o,t.nextPoints=e,t.color=t.userOptions.fillColor,t.options=h(s,m),t.graph=t.area,t.fillGraph=!0,n.drawGraph.call(t),t.area=t.graph,delete t.nextPoints,delete t.fillGraph,t.color=r}o.forEach((e,o)=>{u[o]?(t.points=u[o],c[e]?t.options=h(c[e].styles,m):l('Error: "There is no '+e+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names."'),t.graph=t["graph"+e],n.drawGraph.call(t),t["graph"+e]=t.graph):l('Error: "'+e+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),t.points=s,t.options=c,t.graph=d,n.drawGraph.call(t)}function c(t){let e,o=[],a=[];if(t=t||this.points,this.fillGraph&&this.nextPoints){if((e=n.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",o=n.getGraphPath.call(this,t),a=e.slice(0,o.length);for(let t=a.length-1;t>=0;t--)o.push(a[t])}}else o=n.getGraphPath.apply(this,arguments);return o}function d(t){let e=[];return(this.pointArrayMap||[]).forEach(o=>{e.push(t[o])}),e}function m(){let t=this.pointArrayMap,e=[],o;e=r(this),n.translate.apply(this,arguments),this.points.forEach(a=>{t.forEach((t,i)=>{o=a[t],this.dataModify&&(o=this.dataModify.modifyValue(o)),null!==o&&(a[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||a.slice(),i.drawGraph=s,i.getGraphPath=c,i.toYData=d,i.translate=m,t}}(e||(e={}));let c=e,{sma:d}=s().seriesTypes,{extend:m,isArray:u,merge:y}=i();class f extends d{init(){super.init.apply(this,arguments),this.options=y({topLine:{styles:{lineColor:this.color}},bottomLine:{styles:{lineColor:this.color}}},this.options)}getValues(t,e){let o,a,i,r,s,n,p,l,h=e.period,c=e.topBand,d=e.bottomBand,m=t.xData,y=t.yData,f=y?y.length:0,g=[],b=[],x=[];if(!(m.length<h)&&u(y[0])&&4===y[0].length){for(l=h;l<=f;l++)s=m.slice(l-h,l),n=y.slice(l-h,l),r=(p=super.getValues({xData:s,yData:n},e)).xData[0],a=(o=p.yData[0])*(1+c),i=o*(1-d),g.push([r,a,o,i]),b.push(r),x.push([a,o,i]);return{values:g,xData:b,yData:x}}}}f.defaultOptions=y(d.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"}}),m(f.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"}),c.compose(f),s().registerSeriesType("priceenvelopes",f);let g=i();export{g as default};