UNPKG

highcharts

Version:
14 lines 10.6 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 */function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts,t._Highcharts.Chart,t._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/indicators/indicators",["highcharts/highcharts"],function(t){return e(t,t.Chart,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/indicators/indicators"]=e(t._Highcharts,t._Highcharts.Chart,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.Chart,t.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(t,e,a)=>(()=>{"use strict";var i,s={960(t){t.exports=e},512(t){t.exports=a},944(e){e.exports=t}};let r={};function n(t){let e=r[t];if(void 0!==e)return e.exports;let a=r[t]={exports:{}};return s[t](a,a.exports,n),a.exports}n.n=t=>{let e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{if(Array.isArray(e))for(var a=0;a<e.length;){var i=e[a++],s=e[a++];n.o(t,i)?0===s&&a++:0===s?Object.defineProperty(t,i,{enumerable:!0,value:e[a++]}):Object.defineProperty(t,i,{enumerable:!0,get:s})}else for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let o={};n.d(o,{default:()=>w});var l=n(944),h=n.n(l),u=n(960),p=n.n(u);let{setLength:c,splice:d}={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 r=Object.getPrototypeOf(t).constructor,n=t[i?"subarray":"slice"](e,e+a),o=new r(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:n,array:o}}},f=class{constructor(t={}){this.isDataTable=!0,this.autoId=!t.id,this.columns={},this.id=t.id||(0,l.uniqueKey)(),this.rowCount=0,this.versionTag=(0,l.uniqueKey)();let e=0;(0,l.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,l.objectEach)(this.columns,(e,a)=>{e.length!==t&&(this.columns[a]=c(e,t))})}deleteRows(t,e=1){if(e>0&&t<this.rowCount){let a=0;(0,l.objectEach)(this.columns,(i,s)=>{this.columns[s]=d(i,t,e).array,a=i.length}),this.rowCount=a}(0,l.fireEvent)(this,"afterDeleteRows",{rowIndex:t,rowCount:e}),this.versionTag=(0,l.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,a){let i=this.rowCount;(0,l.objectEach)(t,(t,e)=>{this.columns[e]=t.slice(),i=t.length}),this.applyRowCount(i),a?.silent||((0,l.fireEvent)(this,"afterSetColumns"),this.versionTag=(0,l.uniqueKey)())}setRow(t,e=this.rowCount,a,i){var s;let{columns:r}=this,n=a?this.rowCount+1:e+1,o=Object.keys(t);if(i?.addColumns!==!1)for(let t=0,e=o.length;t<e;t++)r[s=o[t]]||(r[s]=Array(this.rowCount));(0,l.objectEach)(r,(i,s)=>{i&&(a?i=d(i,e,0,!0,[t[s]]).array:i[e]=s in t?t[s]:i[e],r[s]=i)}),this.applyRowCount(Math.max(n,this.rowCount)),i?.silent||((0,l.fireEvent)(this,"afterSetRows",{rowIndex:e}),this.versionTag=(0,l.uniqueKey)())}getModified(){return this.modified||this}};var y=n(512),m=n.n(y);let{line:g}=m().seriesTypes,x=(t,e)=>{let a=[],i=t.pointArrayMap,s=e&&t.dataTable.getModified()||t.dataTable;if(!i)return t.getColumn("y",e);let r=i.map(a=>t.getColumn(a,e));for(let t=0;t<s.rowCount;t++){let e=i.map((e,a)=>r[a]?.[t]||0);a.push(e)}return a};class C extends g{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,a){t.push(this.options.params[e]+(0,l.pick)(this.nameSuffixes[a],""))},this),e=(this.nameBase||this.type.toUpperCase())+(this.nameComponents?" ("+t.join(", ")+")":"")),e}getValues(t,e){let a=e.period,i=t.xData||[],s=t.yData,r=s.length,n=[],o=[],h=[],u,p=-1,c=0,d,f=0;if(!(i.length<a)){for((0,l.isArray)(s[0])&&(p=e.index?e.index:0);c<a-1;)f+=p<0?s[c]:s[c][p],c++;for(u=c;u<r;u++)f+=p<0?s[u]:s[u][p],d=[i[u],f/a],n.push(d),o.push(d[0]),h.push(d[1]),f-=p<0?s[u-c]:s[u-c][p];return{values:n,xData:o,yData:h}}}init(t,e){let a=this;super.init.call(a,t,e);let i=(0,l.addEvent)(p(),"afterLinkSeries",function({isUpdating:e}){if(e)return;let i=!!a.dataEventsToUnbind.length;if(!a.linkedParent)return(0,l.error)("Series "+a.options.linkedTo+" not found! Check `linkedTo`.",!1,t);if(!i&&(a.dataEventsToUnbind.push((0,l.addEvent)(a.linkedParent,"updatedData",function(){a.recalculateValues()})),a.calculateOn.xAxis&&a.dataEventsToUnbind.push((0,l.addEvent)(a.linkedParent.xAxis,a.calculateOn.xAxis,function(){a.recalculateValues()}))),"init"===a.calculateOn.chart)a.closestPointRange||a.recalculateValues();else if(!i){let t=(0,l.addEvent)(a.chart,a.calculateOn.chart,function(){a.recalculateValues(),t()})}},{order:0});a.dataEventsToUnbind=[],a.eventsToUnbind.push(i)}recalculateValues(){let t=this.dataTable,e=this.dataTable.rowCount,a=!0,i,s,r=this.linkedParent.yData,n=this.linkedParent.processedYData;this.linkedParent.xData=this.linkedParent.getColumn("x"),this.linkedParent.yData=x(this.linkedParent),this.linkedParent.processedYData=x(this.linkedParent,!0);let o=this.linkedParent.options&&this.linkedParent.dataTable.rowCount&&this.getValues(this.linkedParent,this.options.params)||{values:[],xData:[],yData:[]};o.xData.length=o.values.length,delete this.linkedParent.xData,this.linkedParent.yData=r,this.linkedParent.processedYData=n;let h=this.pointArrayMap||["y"],u={};if(o.yData.forEach(t=>{h.forEach((e,a)=>{let i=u[e]||[];i.push((0,l.isArray)(t)?t[a]:t),u[e]||(u[e]=i)})}),e&&!this.hasGroupedData&&this.visible&&this.points)if(this.cropped){this.xAxis&&(i=this.xAxis.min,s=this.xAxis.max);let e=this.cropData(t,i,s);this.setData(e.modified,!1)}else(this.updateAllPoints||o.xData.length!==e-1&&o.xData.length!==e+1)&&(a=!1,this.setData(new f({columns:{x:o.xData,...u}}),!1));a&&(u.x=o.xData,o.values.reduce((t,e,a)=>(Object.keys(e).forEach(i=>{t[i]||(t[i]=[]),t[i][a]=e[i]}),t),u),t.setColumns(u),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,l.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)}}C.defaultOptions=(0,l.merge)(g.defaultOptions,{name:void 0,tooltip:{valueDecimals:4},linkedTo:void 0,compareToMain:!1,params:{index:3,period:14}}),(0,l.extend)(C.prototype,{calculateOn:{chart:"init"},hasDerivedData:!0,nameComponents:["period"],nameSuffixes:[],useCommonDataGrouping:!0}),m().registerSeriesType("sma",C);let{sma:b}=m().seriesTypes;class v extends b{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,a,i,s,r,n){let o=t[a-1],h=r<0?e[a-1]:e[a-1][r];return[o,void 0===s?n:(0,l.correctFloat)(h*i+s*(1-i))]}getValues(t,e){let a=e.period,i=t.xData,s=t.yData,r=s?s.length:0,n=2/(a+1),o=[],h=[],u=[],p,c,d,f=-1,y=0;if(!(r<a)){for((0,l.isArray)(s[0])&&(f=e.index?e.index:0),y=this.accumulatePeriodPoints(a,f,s)/a,d=a;d<r+1;d++)c=this.calculateEma(i,s,d,n,p,f,y),o.push(c),h.push(c[0]),u.push(c[1]),p=c[1];return{values:o,xData:h,yData:u}}}}v.defaultOptions=(0,l.merge)(b.defaultOptions,{params:{index:3,period:9}}),m().registerSeriesType("ema",v);let{sma:{prototype:D}}=m().seriesTypes;!function(t){let e=["bottomLine"],a=["top","bottom"],i=["top"];function s(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(s(t))}),a}function n(){let t=this,e=t.pointValKey,a=t.linesApiNames,i=t.areaLinesNames,n=t.points,o=t.options,h=t.graph,u={options:{gapSize:o.gapSize}},p=[],c=r(t,e),d=n.length,f;if(c.forEach((t,e)=>{for(p[e]=[];d--;)f=n[d],p[e].push({x:f.x,plotX:f.plotX,plotY:f[t],isNull:!(0,l.defined)(f[t])});d=n.length}),t.userOptions.fillColor&&i.length){let e=p[c.indexOf(s(i[0]))],a=1===i.length?n:p[c.indexOf(s(i[1]))],r=t.color;t.points=a,t.nextPoints=e,t.color=t.userOptions.fillColor,t.options=(0,l.merge)(n,u),t.graph=t.area,t.fillGraph=!0,D.drawGraph.call(t),t.area=t.graph,delete t.nextPoints,delete t.fillGraph,t.color=r}a.forEach((e,a)=>{p[a]?(t.points=p[a],o[e]?t.options=(0,l.merge)(o[e].styles,u):(0,l.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],D.drawGraph.call(t),t["graph"+e]=t.graph):(0,l.error)('Error: "'+e+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),t.points=n,t.options=o,t.graph=h,D.drawGraph.call(t)}function o(t){let e,a=[],i=[];if(t=t||this.points,this.fillGraph&&this.nextPoints){if((e=D.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",a=D.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=D.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),D.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 s=t.prototype;return s.linesApiNames=s.linesApiNames||e.slice(),s.pointArrayMap=s.pointArrayMap||a.slice(),s.pointValKey=s.pointValKey||"top",s.areaLinesNames=s.areaLinesNames||i.slice(),s.drawGraph=n,s.getGraphPath=o,s.toYData=h,s.translate=u,t}}(i||(i={}));let P=i,A=h();A.MultipleLinesComposition=A.MultipleLinesComposition||P;let w=h();return o.default})());