UNPKG

highcharts

Version:
1 lines 3.71 kB
import*as e from"../highcharts.js";import"../modules/stock.js";var t,a={};a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var i in t)a.o(t,i)&&!a.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let i=e.default;var r=a.n(i);a.d({},{});let o={getArrayExtremes:function(e,t,a){return e.reduce((e,i)=>[Math.min(e[0],i[t]),Math.max(e[1],i[a])],[Number.MAX_VALUE,-Number.MAX_VALUE])}},n=e.default.SeriesRegistry;var s=a.n(n);let{sma:{prototype:p}}=s().seriesTypes,{defined:l,error:h,merge:c}=r();!function(e){let t=["bottomLine"],a=["top","bottom"],i=["top"];function r(e){return"plot"+e.charAt(0).toUpperCase()+e.slice(1)}function o(e,t){let a=[];return(e.pointArrayMap||[]).forEach(e=>{e!==t&&a.push(r(e))}),a}function n(){let e=this,t=e.pointValKey,a=e.linesApiNames,i=e.areaLinesNames,n=e.points,s=e.options,f=e.graph,u={options:{gapSize:s.gapSize}},d=[],m=o(e,t),y=n.length,g;if(m.forEach((e,t)=>{for(d[t]=[];y--;)g=n[y],d[t].push({x:g.x,plotX:g.plotX,plotY:g[e],isNull:!l(g[e])});y=n.length}),e.userOptions.fillColor&&i.length){let t=d[m.indexOf(r(i[0]))],a=1===i.length?n:d[m.indexOf(r(i[1]))],o=e.color;e.points=a,e.nextPoints=t,e.color=e.userOptions.fillColor,e.options=c(n,u),e.graph=e.area,e.fillGraph=!0,p.drawGraph.call(e),e.area=e.graph,delete e.nextPoints,delete e.fillGraph,e.color=o}a.forEach((t,a)=>{d[a]?(e.points=d[a],s[t]?e.options=c(s[t].styles,u):h('Error: "There is no '+t+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names."'),e.graph=e["graph"+t],p.drawGraph.call(e),e["graph"+t]=e.graph):h('Error: "'+t+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),e.points=n,e.options=s,e.graph=f,p.drawGraph.call(e)}function s(e){let t,a=[],i=[];if(e=e||this.points,this.fillGraph&&this.nextPoints){if((t=p.getGraphPath.call(this,this.nextPoints))&&t.length){t[0][0]="L",a=p.getGraphPath.call(this,e),i=t.slice(0,a.length);for(let e=i.length-1;e>=0;e--)a.push(i[e])}}else a=p.getGraphPath.apply(this,arguments);return a}function f(e){let t=[];return(this.pointArrayMap||[]).forEach(a=>{t.push(e[a])}),t}function u(){let e=this.pointArrayMap,t=[],a;t=o(this),p.translate.apply(this,arguments),this.points.forEach(i=>{e.forEach((e,r)=>{a=i[e],this.dataModify&&(a=this.dataModify.modifyValue(a)),null!==a&&(i[t[r]]=this.yAxis.toPixels(a,!0))})})}e.compose=function(e){let r=e.prototype;return r.linesApiNames=r.linesApiNames||t.slice(),r.pointArrayMap=r.pointArrayMap||a.slice(),r.pointValKey=r.pointValKey||"top",r.areaLinesNames=r.areaLinesNames||i.slice(),r.drawGraph=n,r.getGraphPath=s,r.toYData=f,r.translate=u,e}}(t||(t={}));let f=t,u=["#2caffe","#544fc5","#00e272","#fe6a35","#6b8abc","#d568fb","#2ee0ca","#fa4b42","#feb56a","#91e8e1"],{sma:d}=s().seriesTypes,{merge:m,extend:y}=r();class g extends d{getValues(e,t){let a,i,r,n,s,p,l,h=t.period,c=e.xData,f=e.yData,u=f?f.length:0,d=[],m=[],y=[];if(!(u<h)){for(l=h;l<=u;l++)n=c[l-1],s=f.slice(l-h,l),a=((i=(p=o.getArrayExtremes(s,2,1))[1])+(r=p[0]))/2,d.push([n,i,a,r]),m.push(n),y.push([i,a,r]);return{values:d,xData:m,yData:y}}}}g.defaultOptions=m(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"}}),y(g.prototype,{areaLinesNames:["top","bottom"],nameBase:"Price Channel",nameComponents:["period"],linesApiNames:["topLine","bottomLine"],pointArrayMap:["top","middle","bottom"],pointValKey:"middle"}),f.compose(g),s().registerSeriesType("pc",g);let A=r();export{A as default};