highcharts
Version:
JavaScript charting framework
14 lines • 10.5 kB
JavaScript
!/**
* Highstock JS v12.6.0 (2026-04-13)
* @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,n={512:t=>{t.exports=a},944:e=>{e.exports=t},960:t=>{t.exports=e}},r={};function s(t){var e=r[t];if(void 0!==e)return e.exports;var a=r[t]={exports:{}};return n[t](a,a.exports,s),a.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var a in e)s.o(e,a)&&!s.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var o={};s.d(o,{default:()=>j});var l=s(944),p=s.n(l),h=s(960),c=s.n(h),u=s(512),d=s.n(u);let{doc:f,win:y}=p();function g(t,e,a,i={}){let n="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(n,"hcEvents")||(n.hcEvents={});let r=n.hcEvents;p().Point&&t instanceof p().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let s=t.addEventListener;s&&s.call(t,e,a,!!p().supportsPassiveEvents&&{passive:void 0===i.passive?-1!==e.indexOf("touch"):i.passive,capture:!1}),r[e]||(r[e]=[]);let o={fn:a,order:"number"==typeof i.order?i.order:1/0};return r[e].push(o),r[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,a){function i(e,a){let i=t.removeEventListener;i&&i.call(t,e,a,!1)}function n(a){let n,r;t.nodeName&&(e?(n={})[e]=!0:n=a,E(n,function(t,e){if(a[e])for(r=a[e].length;r--;)i(e,a[e][r].fn)}))}let r="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(r,"hcEvents")){let t=r.hcEvents;if(e){let r=t[e]||[];a?(t[e]=r.filter(function(t){return a!==t.fn}),i(e,a)):(n(t),t[e]=[])}else n(t),delete r.hcEvents}}(t,e,a)}}function m(t,e){let a;for(a in t||(t={}),e)t[a]=e[a];return t}function x(t){return D(t)&&"number"==typeof t.nodeType}function v(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function D(t,e){return!!t&&"object"==typeof t&&(!e||!v(t))}function P(t,...e){let a,i=[t,...e],n={},r=function(t,e){return"object"!=typeof t&&(t={}),E(e,function(a,i){if("__proto__"!==i&&"constructor"!==i){let n;!D(a,!0)||(n=a?.constructor,D(a,!0)&&!x(a)&&n?.name&&"Object"!==n.name)||x(a)?t[i]=e[i]:t[i]=r(t[i]||{},a)}}),t};!0===t&&(n=i[1],i=Array.prototype.slice.call(i,2));let s=i.length;for(a=0;a<s;a++)n=r(n,i[a]);return n}function E(t,e,a){for(let i in t)Object.hasOwnProperty.call(t,i)&&e.call(a||t[i],t[i],i,t)}Array.prototype.find;let{line:O}=d().seriesTypes,b=(t,e)=>{let a=[],i=t.pointArrayMap,n=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<n.rowCount;t++){let e=i.map((e,a)=>r[a]?.[t]||0);a.push(e)}return a};class C extends O{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]+function(){let t=arguments,e=t.length;for(let a=0;a<e;a++){let e=t[a];if(null!=e)return e}}(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||[],n=t.yData,r=n.length,s=[],o=[],l=[],p,h=-1,c=0,u,d=0;if(!(i.length<a)){for(v(n[0])&&(h=e.index?e.index:0);c<a-1;)d+=h<0?n[c]:n[c][h],c++;for(p=c;p<r;p++)d+=h<0?n[p]:n[p][h],u=[i[p],d/a],s.push(u),o.push(u[0]),l.push(u[1]),d-=h<0?n[p-c]:n[p-c][h];return{values:s,xData:o,yData:l}}}init(t,e){let a=this;super.init.call(a,t,e);let i=g(c(),"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(g(a.linkedParent,"updatedData",function(){a.recalculateValues()})),a.calculateOn.xAxis&&a.dataEventsToUnbind.push(g(a.linkedParent.xAxis,a.calculateOn.xAxis,function(){a.recalculateValues()}))),"init"===a.calculateOn.chart)a.closestPointRange||a.recalculateValues();else if(!i){let t=g(a.chart,a.calculateOn.chart,function(){a.recalculateValues(),t()})}},{order:0});a.dataEventsToUnbind=[],a.eventsToUnbind.push(i)}recalculateValues(){let t=[],e=this.dataTable,a=this.points||[],i=this.dataTable.rowCount,n=!0,r,s,o,l,h=this.linkedParent.yData,c=this.linkedParent.processedYData;this.linkedParent.xData=this.linkedParent.getColumn("x"),this.linkedParent.yData=b(this.linkedParent),this.linkedParent.processedYData=b(this.linkedParent,!0);let u=this.linkedParent.options&&this.linkedParent.dataTable.rowCount&&this.getValues(this.linkedParent,this.options.params)||{values:[],xData:[],yData:[]};delete this.linkedParent.xData,this.linkedParent.yData=h,this.linkedParent.processedYData=c;let d=this.pointArrayMap||["y"],y={};if(u.yData.forEach(t=>{d.forEach((e,a)=>{let i=y[e]||[];i.push(v(t)?t[a]:t),y[e]||(y[e]=i)})}),i&&!this.hasGroupedData&&this.visible&&this.points)if(this.cropped){this.xAxis&&(o=this.xAxis.min,l=this.xAxis.max);let i=this.cropData(e,o,l),n=["x",...this.pointArrayMap||["y"]];for(let e=0;e<(i.modified?.rowCount||0);e++){let a=n.map(t=>this.getColumn(t)[e]||0);t.push(a)}let p=this.getColumn("x");r=u.xData.indexOf(p[0]),s=u.xData.indexOf(p[p.length-1]),-1===r&&s===u.xData.length-2&&t[0][0]===a[0].x&&t.shift(),this.updateData(t)}else(this.updateAllPoints||u.xData.length!==i-1&&u.xData.length!==i+1)&&(n=!1,this.updateData(u.values));n&&(e.setColumns({...y,x:u.xData}),this.options.data=u.values),this.calculateOn.xAxis&&this.getColumn("x",!0).length&&(this.isDirty=!0,this.redraw()),this.isDirtyData=!!this.linkedSeries.length,function(t,e,a,i){if(a=a||{},f?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==p())){let i=f.createEvent("Events");i.initEvent(e,!0,!0),a=m(i,a),t.dispatchEvent?t.dispatchEvent(a):t.fireEvent(e,a)}else if(t.hcEvents){a.target||m(a,{preventDefault:function(){a.defaultPrevented=!0},target:t,type:e});let i=[],n=t,r=!1;for(;n.hcEvents;)Object.hasOwnProperty.call(n,"hcEvents")&&n.hcEvents[e]&&(i.length&&(r=!0),i.unshift.apply(i,n.hcEvents[e])),n=Object.getPrototypeOf(n);r&&i.sort((t,e)=>t.order-e.order),i.forEach(e=>{!1===e.fn.call(t,a,t)&&a.preventDefault()})}}(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=P(O.defaultOptions,{name:void 0,tooltip:{valueDecimals:4},linkedTo:void 0,compareToMain:!1,params:{index:3,period:14}}),m(C.prototype,{calculateOn:{chart:"init"},hasDerivedData:!0,nameComponents:["period"],nameSuffixes:[],useCommonDataGrouping:!0}),d().registerSeriesType("sma",C);let{sma:A}=d().seriesTypes;class k extends A{accumulatePeriodPoints(t,e,a){let i=0,n=0;for(;n<t;)i+=e<0?a[n]:a[n][e],n++;return i}calculateEma(t,e,a,i,n,r,s){var o;let l=t[a-1],p=r<0?e[a-1]:e[a-1][r];return[l,void 0===n?s:(o=p*i+n*(1-i))>1e14?o:parseFloat(o.toPrecision(14))]}getValues(t,e){let a=e.period,i=t.xData,n=t.yData,r=n?n.length:0,s=2/(a+1),o=[],l=[],p=[],h,c,u,d=-1,f=0;if(!(r<a)){for(v(n[0])&&(d=e.index?e.index:0),f=this.accumulatePeriodPoints(a,d,n)/a,u=a;u<r+1;u++)c=this.calculateEma(i,n,u,s,h,d,f),o.push(c),l.push(c[0]),p.push(c[1]),h=c[1];return{values:o,xData:l,yData:p}}}}k.defaultOptions=P(A.defaultOptions,{params:{index:3,period:9}}),d().registerSeriesType("ema",k);let{sma:{prototype:T}}=d().seriesTypes;!function(t){let e=["bottomLine"],a=["top","bottom"],i=["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 s(){let t=this,e=t.pointValKey,a=t.linesApiNames,i=t.areaLinesNames,s=t.points,o=t.options,p=t.graph,h={options:{gapSize:o.gapSize}},c=[],u=r(t,e),d=s.length,f;if(u.forEach((t,e)=>{for(c[e]=[];d--;)f=s[d],c[e].push({x:f.x,plotX:f.plotX,plotY:f[t],isNull:null==f[t]});d=s.length}),t.userOptions.fillColor&&i.length){let e=c[u.indexOf(n(i[0]))],a=1===i.length?s:c[u.indexOf(n(i[1]))],r=t.color;t.points=a,t.nextPoints=e,t.color=t.userOptions.fillColor,t.options=P(s,h),t.graph=t.area,t.fillGraph=!0,T.drawGraph.call(t),t.area=t.graph,delete t.nextPoints,delete t.fillGraph,t.color=r}a.forEach((e,a)=>{c[a]?(t.points=c[a],o[e]?t.options=P(o[e].styles,h):(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],T.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=s,t.options=o,t.graph=p,T.drawGraph.call(t)}function o(t){let e,a=[],i=[];if(t=t||this.points,this.fillGraph&&this.nextPoints){if((e=T.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",a=T.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=T.getGraphPath.apply(this,arguments);return a}function p(t){let e=[];return(this.pointArrayMap||[]).forEach(a=>{e.push(t[a])}),e}function h(){let t=this.pointArrayMap,e=[],a;e=r(this),T.translate.apply(this,arguments),this.points.forEach(i=>{t.forEach((t,n)=>{a=i[t],this.dataModify&&(a=this.dataModify.modifyValue(a)),null!==a&&(i[e[n]]=this.yAxis.toPixels(a,!0))})})}t.compose=function(t){let n=t.prototype;return n.linesApiNames=n.linesApiNames||e.slice(),n.pointArrayMap=n.pointArrayMap||a.slice(),n.pointValKey=n.pointValKey||"top",n.areaLinesNames=n.areaLinesNames||i.slice(),n.drawGraph=s,n.getGraphPath=o,n.toYData=p,n.translate=h,t}}(i||(i={}));let M=i,w=p();w.MultipleLinesComposition=w.MultipleLinesComposition||M;let j=p();return o.default})());