highcharts
Version:
JavaScript charting framework
14 lines • 4.14 kB
JavaScript
/**
* Highstock JS v13.0.1 (2026-08-17)
* @module highcharts/indicators/price-channel
* @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=function(e,t,a){return e.reduce((e,r)=>[Math.min(e[0],r[t]),Math.max(e[1],r[a])],[Number.MAX_VALUE,-Number.MAX_VALUE])},n=e.default.SeriesRegistry;var s=t.n(n);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 n(e,t){let a=[];return(e.pointArrayMap||[]).forEach(e=>{e!==t&&a.push(o(e))}),a}function s(){let e=this,t=e.pointValKey,r=e.linesApiNames,i=e.areaLinesNames,s=e.points,p=e.options,h=e.graph,c={options:{gapSize:p.gapSize}},u=[],f=n(e,t),d=s.length,m;if(f.forEach((e,t)=>{for(u[t]=[];d--;)m=s[d],u[t].push({x:m.x,plotX:m.plotX,plotY:m[e],isNull:!(0,a.defined)(m[e])});d=s.length}),e.userOptions.fillColor&&i.length){let t=u[f.indexOf(o(i[0]))],r=1===i.length?s:u[f.indexOf(o(i[1]))],n=e.color;e.points=r,e.nextPoints=t,e.color=e.userOptions.fillColor,e.options=(0,a.merge)(s,c),e.graph=e.area,e.fillGraph=!0,l.drawGraph.call(e),e.area=e.graph,delete e.nextPoints,delete e.fillGraph,e.color=n}r.forEach((t,r)=>{u[r]?(e.points=u[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=s,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=n(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=s,a.getGraphPath=p,a.toYData=h,a.translate=c,e}}(r||(r={}));let p=r,{sma:h}=s().seriesTypes;class c extends h{getValues(e,t){let a,r,i,n,s,l,p=t.period,h=e.xData,c=e.yData,u=c?c.length:0,f=[],d=[],m=[];if(!(u<p)){for(l=p;l<=u;l++)n=h[l-1],a=((r=(s=o(c.slice(l-p,l),2,1))[1])+(i=s[0]))/2,f.push([n,r,a,i]),d.push(n),m.push([r,a,i]);return{values:f,xData:d,yData:m}}}}c.defaultOptions=(0,a.merge)(h.defaultOptions,{params:{index:void 0,period:20},lineWidth:1,topLine:{styles:{lineColor:"var(--highcharts-color-2)",lineWidth:1}},bottomLine:{styles:{lineColor:"var(--highcharts-color-8)",lineWidth:1}},dataGrouping:{approximation:"averages"}}),(0,a.extend)(c.prototype,{areaLinesNames:["top","bottom"],nameBase:"Price Channel",nameComponents:["period"],linesApiNames:["topLine","bottomLine"],pointArrayMap:["top","middle","bottom"],pointValKey:"middle"}),p.compose(c),s().registerSeriesType("pc",c);let u=i();export{u as default};