highcharts
Version:
JavaScript charting framework
14 lines • 4.6 kB
JavaScript
/**
* Highstock JS v12.6.0 (2026-04-13)
* @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 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 n=function(t,e,o){return t.reduce((t,r)=>[Math.min(t[0],r[e]),Math.max(t[1],r[o])],[Number.MAX_VALUE,-Number.MAX_VALUE])},i=t.default.SeriesRegistry;var l=o.n(i);let{doc:p,win:s}=a();function h(t){return c(t)&&"number"==typeof t.nodeType}function c(t,e){let o;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(o=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==o)}function u(t,...e){let o,r=[t,...e],a={},n=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)&&!h(o)&&a?.name&&"Object"!==a.name)||h(o)?t[r]=e[r]:t[r]=n(t[r]||{},o)}}),t};!0===t&&(a=r[1],r=Array.prototype.slice.call(r,2));let i=r.length;for(o=0;o<i;o++)a=n(a,r[o]);return a}Array.prototype.find;let{sma:{prototype:f}}=l().seriesTypes;!function(t){let e=["bottomLine"],o=["top","bottom"],a=["top"];function n(t){return"plot"+t.charAt(0).toUpperCase()+t.slice(1)}function i(t,e){let o=[];return(t.pointArrayMap||[]).forEach(t=>{t!==e&&o.push(n(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=i(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(n(a[0]))],o=1===a.length?l:c[y.indexOf(n(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=i(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}=l().seriesTypes;class m extends d{getValues(t,e){let o,r,a,i,l,p,s=e.period,h=t.xData,c=t.yData,u=c?c.length:0,f=[],y=[],d=[];if(!(u<s)){for(p=s;p<=u;p++)i=h[p-1],o=((r=(l=n(c.slice(p-s,p),2,1))[1])+(a=l[0]))/2,f.push([i,r,o,a]),y.push(i),d.push([r,o,a]);return{values:f,xData:y,yData:d}}}}m.defaultOptions=u(d.defaultOptions,{params:{index:void 0,period:20},lineWidth:1,topLine:{styles:{lineColor:"#00e272",lineWidth:1}},bottomLine:{styles:{lineColor:"#feb56a",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"],nameBase:"Price Channel",nameComponents:["period"],linesApiNames:["topLine","bottomLine"],pointArrayMap:["top","middle","bottom"],pointValKey:"middle"}),y.compose(m),l().registerSeriesType("pc",m);let g=a();export{g as default};