UNPKG

highcharts

Version:
14 lines 9.85 kB
/** * Highstock JS v13.0.1 (2026-08-17) * @module highcharts/indicators/indicators * @requires highcharts * @requires highcharts/modules/stock * * Indicator series type for Highcharts Stock * * (c) 2010-2026 Highsoft AS * Author: Paweł Fus, Sebastian Bochan * * A commercial license may be required depending on use, * see www.highcharts.com/license */import*as t from"../highcharts.js";let e={};e.n=t=>{let a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a:a}),a},e.d=(t,a)=>{if(Array.isArray(a))for(var i=0;i<a.length;){var s=a[i++],n=a[i++];e.o(t,s)?0===n&&i++:0===n?Object.defineProperty(t,s,{enumerable:!0,value:a[i++]}):Object.defineProperty(t,s,{enumerable:!0,get:n})}else for(var s in a)e.o(a,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:a[s]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let a=t.default;var i,s=e.n(a);let n=t.default.Chart;var r=e.n(n);let{setLength:o,splice:l}={convertToNumber:function(t,e){switch(typeof t){case"boolean":return+!!t;case"number":return isNaN(t)&&!e?null:t;default:return isNaN(t=parseFloat(`${t??""}`))&&!e?null:t}},setLength:function(t,e,a){return Array.isArray(t)?(t.length=e,t):t[a?"subarray":"slice"](0,e)},splice:function(t,e,a,i,s=[]){if(Array.isArray(t))return Array.isArray(s)||(s=Array.from(s)),{removed:t.splice(e,a,...s),array:t};let n=Object.getPrototypeOf(t).constructor,r=t[i?"subarray":"slice"](e,e+a),o=new n(t.length-a+s.length);return o.set(t.subarray(0,e),0),o.set(s,e),o.set(t.subarray(e+a),e+s.length),{removed:r,array:o}}},h=class{constructor(t={}){this.isDataTable=!0,this.autoId=!t.id,this.columns={},this.id=t.id||(0,a.uniqueKey)(),this.rowCount=0,this.versionTag=(0,a.uniqueKey)();let e=0;(0,a.objectEach)(t.columns||{},(t,a)=>{this.columns[a]=t.slice(),e=Math.max(e,t.length)}),this.applyRowCount(e)}applyRowCount(t){this.rowCount=t,(0,a.objectEach)(this.columns,(e,a)=>{e.length!==t&&(this.columns[a]=o(e,t))})}deleteRows(t,e=1){if(e>0&&t<this.rowCount){let i=0;(0,a.objectEach)(this.columns,(a,s)=>{this.columns[s]=l(a,t,e).array,i=a.length}),this.rowCount=i}(0,a.fireEvent)(this,"afterDeleteRows",{rowIndex:t,rowCount:e}),this.versionTag=(0,a.uniqueKey)()}getColumn(t,e){return this.columns[t]}getColumns(t,e){return(t||Object.keys(this.columns)).reduce((t,e)=>(t[e]=this.columns[e],t),{})}getRowObject(t,e){let a={},i=this.columns;for(let s of(e??(e=Object.keys(this.columns)),e))a[s]=i[s]?.[t];return a}setColumn(t,e=[],a=0,i){this.setColumns({[t]:e},a,i)}setColumns(t,e,i){let s=this.rowCount;(0,a.objectEach)(t,(t,e)=>{this.columns[e]=t.slice(),s=t.length}),this.applyRowCount(s),i?.silent||((0,a.fireEvent)(this,"afterSetColumns"),this.versionTag=(0,a.uniqueKey)())}setRow(t,e=this.rowCount,i,s){var n;let{columns:r}=this,o=i?this.rowCount+1:e+1,h=Object.keys(t);if(s?.addColumns!==!1)for(let t=0,e=h.length;t<e;t++)r[n=h[t]]||(r[n]=Array(this.rowCount));(0,a.objectEach)(r,(a,s)=>{a&&(i?a=l(a,e,0,!0,[t[s]]).array:a[e]=s in t?t[s]:a[e],r[s]=a)}),this.applyRowCount(Math.max(o,this.rowCount)),s?.silent||((0,a.fireEvent)(this,"afterSetRows",{rowIndex:e}),this.versionTag=(0,a.uniqueKey)())}getModified(){return this.modified||this}},u=t.default.SeriesRegistry;var p=e.n(u);let{line:c}=p().seriesTypes,d=(t,e)=>{let a=[],i=t.pointArrayMap,s=e&&t.dataTable.getModified()||t.dataTable;if(!i)return t.getColumn("y",e);let n=i.map(a=>t.getColumn(a,e));for(let t=0;t<s.rowCount;t++){let e=i.map((e,a)=>n[a]?.[t]||0);a.push(e)}return a};class f extends c{destroy(){this.dataEventsToUnbind.forEach(function(t){t()}),super.destroy.apply(this,arguments)}getName(){let t=[],e=this.name;return e||((this.nameComponents||[]).forEach(function(e,i){t.push(this.options.params[e]+(0,a.pick)(this.nameSuffixes[i],""))},this),e=(this.nameBase||this.type.toUpperCase())+(this.nameComponents?" ("+t.join(", ")+")":"")),e}getValues(t,e){let i=e.period,s=t.xData||[],n=t.yData,r=n.length,o=[],l=[],h=[],u,p=-1,c=0,d,f=0;if(!(s.length<i)){for((0,a.isArray)(n[0])&&(p=e.index?e.index:0);c<i-1;)f+=p<0?n[c]:n[c][p],c++;for(u=c;u<r;u++)f+=p<0?n[u]:n[u][p],d=[s[u],f/i],o.push(d),l.push(d[0]),h.push(d[1]),f-=p<0?n[u-c]:n[u-c][p];return{values:o,xData:l,yData:h}}}init(t,e){let i=this;super.init.call(i,t,e);let s=(0,a.addEvent)(r(),"afterLinkSeries",function({isUpdating:e}){if(e)return;let s=!!i.dataEventsToUnbind.length;if(!i.linkedParent)return(0,a.error)("Series "+i.options.linkedTo+" not found! Check `linkedTo`.",!1,t);if(!s&&(i.dataEventsToUnbind.push((0,a.addEvent)(i.linkedParent,"updatedData",function(){i.recalculateValues()})),i.calculateOn.xAxis&&i.dataEventsToUnbind.push((0,a.addEvent)(i.linkedParent.xAxis,i.calculateOn.xAxis,function(){i.recalculateValues()}))),"init"===i.calculateOn.chart)i.closestPointRange||i.recalculateValues();else if(!s){let t=(0,a.addEvent)(i.chart,i.calculateOn.chart,function(){i.recalculateValues(),t()})}},{order:0});i.dataEventsToUnbind=[],i.eventsToUnbind.push(s)}recalculateValues(){let t=this.dataTable,e=this.dataTable.rowCount,i=!0,s,n,r=this.linkedParent.yData,o=this.linkedParent.processedYData;this.linkedParent.xData=this.linkedParent.getColumn("x"),this.linkedParent.yData=d(this.linkedParent),this.linkedParent.processedYData=d(this.linkedParent,!0);let l=this.linkedParent.options&&this.linkedParent.dataTable.rowCount&&this.getValues(this.linkedParent,this.options.params)||{values:[],xData:[],yData:[]};l.xData.length=l.values.length,delete this.linkedParent.xData,this.linkedParent.yData=r,this.linkedParent.processedYData=o;let u=this.pointArrayMap||["y"],p={};if(l.yData.forEach(t=>{u.forEach((e,i)=>{let s=p[e]||[];s.push((0,a.isArray)(t)?t[i]:t),p[e]||(p[e]=s)})}),e&&!this.hasGroupedData&&this.visible&&this.points)if(this.cropped){this.xAxis&&(s=this.xAxis.min,n=this.xAxis.max);let e=this.cropData(t,s,n);this.setData(e.modified,!1)}else(this.updateAllPoints||l.xData.length!==e-1&&l.xData.length!==e+1)&&(i=!1,this.setData(new h({columns:{x:l.xData,...p}}),!1));i&&(p.x=l.xData,l.values.reduce((t,e,a)=>(Object.keys(e).forEach(i=>{t[i]||(t[i]=[]),t[i][a]=e[i]}),t),p),t.setColumns(p),delete this.xColumn,delete this.xColumnIsNumbers),this.calculateOn.xAxis&&this.getColumn("x",!0).length&&(this.isDirty=!0,this.redraw()),this.isDirtyData=!!this.linkedSeries.length,(0,a.fireEvent)(this,"updatedData")}processData(){let t=this.options.compareToMain,e=this.linkedParent;super.processData.apply(this,arguments),this.dataModify&&e&&e.dataModify&&e.dataModify.compareValue&&t&&(this.dataModify.compareValue=e.dataModify.compareValue)}}f.defaultOptions=(0,a.merge)(c.defaultOptions,{name:void 0,tooltip:{valueDecimals:4},linkedTo:void 0,compareToMain:!1,params:{index:3,period:14}}),(0,a.extend)(f.prototype,{calculateOn:{chart:"init"},hasDerivedData:!0,nameComponents:["period"],nameSuffixes:[],useCommonDataGrouping:!0}),p().registerSeriesType("sma",f);let{sma:m}=p().seriesTypes;class y extends m{accumulatePeriodPoints(t,e,a){let i=0,s=0;for(;s<t;)i+=e<0?a[s]:a[s][e],s++;return i}calculateEma(t,e,i,s,n,r,o){let l=t[i-1],h=r<0?e[i-1]:e[i-1][r];return[l,void 0===n?o:(0,a.correctFloat)(h*s+n*(1-s))]}getValues(t,e){let i=e.period,s=t.xData,n=t.yData,r=n?n.length:0,o=2/(i+1),l=[],h=[],u=[],p,c,d,f=-1,m=0;if(!(r<i)){for((0,a.isArray)(n[0])&&(f=e.index?e.index:0),m=this.accumulatePeriodPoints(i,f,n)/i,d=i;d<r+1;d++)c=this.calculateEma(s,n,d,o,p,f,m),l.push(c),h.push(c[0]),u.push(c[1]),p=c[1];return{values:l,xData:h,yData:u}}}}y.defaultOptions=(0,a.merge)(m.defaultOptions,{params:{index:3,period:9}}),p().registerSeriesType("ema",y);let{sma:{prototype:g}}=p().seriesTypes;!function(t){let e=["bottomLine"],i=["top","bottom"],s=["top"];function n(t){return"plot"+t.charAt(0).toUpperCase()+t.slice(1)}function r(t,e){let a=[];return(t.pointArrayMap||[]).forEach(t=>{t!==e&&a.push(n(t))}),a}function o(){let t=this,e=t.pointValKey,i=t.linesApiNames,s=t.areaLinesNames,o=t.points,l=t.options,h=t.graph,u={options:{gapSize:l.gapSize}},p=[],c=r(t,e),d=o.length,f;if(c.forEach((t,e)=>{for(p[e]=[];d--;)f=o[d],p[e].push({x:f.x,plotX:f.plotX,plotY:f[t],isNull:!(0,a.defined)(f[t])});d=o.length}),t.userOptions.fillColor&&s.length){let e=p[c.indexOf(n(s[0]))],i=1===s.length?o:p[c.indexOf(n(s[1]))],r=t.color;t.points=i,t.nextPoints=e,t.color=t.userOptions.fillColor,t.options=(0,a.merge)(o,u),t.graph=t.area,t.fillGraph=!0,g.drawGraph.call(t),t.area=t.graph,delete t.nextPoints,delete t.fillGraph,t.color=r}i.forEach((e,i)=>{p[i]?(t.points=p[i],l[e]?t.options=(0,a.merge)(l[e].styles,u):(0,a.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],g.drawGraph.call(t),t["graph"+e]=t.graph):(0,a.error)('Error: "'+e+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),t.points=o,t.options=l,t.graph=h,g.drawGraph.call(t)}function l(t){let e,a=[],i=[];if(t=t||this.points,this.fillGraph&&this.nextPoints){if((e=g.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",a=g.getGraphPath.call(this,t),i=e.slice(0,a.length);for(let t=i.length-1;t>=0;t--)a.push(i[t])}}else a=g.getGraphPath.apply(this,arguments);return a}function h(t){let e=[];return(this.pointArrayMap||[]).forEach(a=>{e.push(t[a])}),e}function u(){let t=this.pointArrayMap,e=[],a;e=r(this),g.translate.apply(this,arguments),this.points.forEach(i=>{t.forEach((t,s)=>{a=i[t],this.dataModify&&(a=this.dataModify.modifyValue(a)),null!==a&&(i[e[s]]=this.yAxis.toPixels(a,!0))})})}t.compose=function(t){let a=t.prototype;return a.linesApiNames=a.linesApiNames||e.slice(),a.pointArrayMap=a.pointArrayMap||i.slice(),a.pointValKey=a.pointValKey||"top",a.areaLinesNames=a.areaLinesNames||s.slice(),a.drawGraph=o,a.getGraphPath=l,a.toYData=h,a.translate=u,t}}(i||(i={}));let x=i,C=s();C.MultipleLinesComposition=C.MultipleLinesComposition||x;let D=s();export{D as default};