highcharts
Version:
JavaScript charting framework
14 lines • 5.02 kB
JavaScript
/**
* Highstock JS v12.6.0 (2026-04-13)
* @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 t from"../highcharts.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 r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r=t.default;var a=o.n(r);let i=t.default.SeriesRegistry;var n=o.n(i);let{doc:l,win:p}=a();function s(t){return c(t)&&"number"==typeof t.nodeType}function h(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function c(t,e){return!!t&&"object"==typeof t&&(!e||!h(t))}function u(t,...e){let o,r=[t,...e],a={},i=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 a;!c(o,!0)||(a=o?.constructor,c(o,!0)&&!s(o)&&a?.name&&"Object"!==a.name)||s(o)?t[r]=e[r]:t[r]=i(t[r]||{},o)}}),t};!0===t&&(a=r[1],r=Array.prototype.slice.call(r,2));let n=r.length;for(o=0;o<n;o++)a=i(a,r[o]);return a}Array.prototype.find;let{sma:{prototype:f}}=n().seriesTypes;!function(t){let e=["bottomLine"],o=["top","bottom"],a=["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 l(){let t=this,e=t.pointValKey,o=t.linesApiNames,a=t.areaLinesNames,l=t.points,p=t.options,s=t.graph,h={options:{gapSize:p.gapSize}},c=[],y=n(t,e),d=l.length,m;if(y.forEach((t,e)=>{for(c[e]=[];d--;)m=l[d],c[e].push({x:m.x,plotX:m.plotX,plotY:m[t],isNull:null==m[t]});d=l.length}),t.userOptions.fillColor&&a.length){let e=c[y.indexOf(i(a[0]))],o=1===a.length?l:c[y.indexOf(i(a[1]))],r=t.color;t.points=o,t.nextPoints=e,t.color=t.userOptions.fillColor,t.options=u(l,h),t.graph=t.area,t.fillGraph=!0,f.drawGraph.call(t),t.area=t.graph,delete t.nextPoints,delete t.fillGraph,t.color=r}o.forEach((e,o)=>{c[o]?(t.points=c[o],p[e]?t.options=u(p[e].styles,h):(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=l,t.options=p,t.graph=s,f.drawGraph.call(t)}function p(t){let e,o=[],r=[];if(t=t||this.points,this.fillGraph&&this.nextPoints){if((e=f.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",o=f.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=f.getGraphPath.apply(this,arguments);return o}function s(t){let e=[];return(this.pointArrayMap||[]).forEach(o=>{e.push(t[o])}),e}function h(){let t=this.pointArrayMap,e=[],o;e=n(this),f.translate.apply(this,arguments),this.points.forEach(r=>{t.forEach((t,a)=>{o=r[t],this.dataModify&&(o=this.dataModify.modifyValue(o)),null!==o&&(r[e[a]]=this.yAxis.toPixels(o,!0))})})}t.compose=function(t){let r=t.prototype;return r.linesApiNames=r.linesApiNames||e.slice(),r.pointArrayMap=r.pointArrayMap||o.slice(),r.pointValKey=r.pointValKey||"top",r.areaLinesNames=r.areaLinesNames||a.slice(),r.drawGraph=l,r.getGraphPath=p,r.toYData=s,r.translate=h,t}}(e||(e={}));let y=e,{sma:d}=n().seriesTypes;class m extends d{init(){super.init.apply(this,arguments),this.options=u({topLine:{styles:{lineColor:this.color}},bottomLine:{styles:{lineColor:this.color}}},this.options)}getValues(t,e){let o,r,a,i,n,l,p,s,c=e.period,u=e.topBand,f=e.bottomBand,y=t.xData,d=t.yData,m=d?d.length:0,g=[],b=[],A=[];if(!(y.length<c)&&h(d[0])&&4===d[0].length){for(s=c;s<=m;s++)n=y.slice(s-c,s),l=d.slice(s-c,s),i=(p=super.getValues({xData:n,yData:l},e)).xData[0],r=(o=p.yData[0])*(1+u),a=o*(1-f),g.push([i,r,o,a]),b.push(i),A.push([r,o,a]);return{values:g,xData:b,yData:A}}}}m.defaultOptions=u(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"}}),function(t,e){let o;for(o in t||(t={}),e)t[o]=e[o]}(m.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"}),y.compose(m),n().registerSeriesType("priceenvelopes",m);let g=a();export{g as default};