UNPKG

highcharts

Version:
14 lines 6.37 kB
!/** * Highstock JS v12.6.0 (2026-04-13) * @module highcharts/indicators/dmi * @requires highcharts * @requires highcharts/modules/stock * * Indicator series type for Highcharts Stock * * (c) 2010-2026 Highsoft AS * Author: Rafał Sebestjański * * 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.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/indicators/dmi",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/indicators/dmi"]=e(t._Highcharts,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(t,e)=>(()=>{"use strict";var r,a={512:t=>{t.exports=e},944:e=>{e.exports=t}},o={};function i(t){var e=o[t];if(void 0!==e)return e.exports;var r=o[t]={exports:{}};return a[t](r,r.exports,i),r.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var s={};i.d(s,{default:()=>A});var n=i(944),l=i.n(n),p=i(512),h=i.n(p);let{doc:c,win:u}=l();function f(t,e){return t>1e14?t:parseFloat(t.toPrecision(e||14))}function y(t){return g(t)&&"number"==typeof t.nodeType}function d(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function g(t,e){return!!t&&"object"==typeof t&&(!e||!d(t))}function m(t,...e){let r,a=[t,...e],o={},i=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,r){for(let r in t)Object.hasOwnProperty.call(t,r)&&e.call((0,t[r]),t[r],r,t)}(e,function(r,a){if("__proto__"!==a&&"constructor"!==a){let o;!g(r,!0)||(o=r?.constructor,g(r,!0)&&!y(r)&&o?.name&&"Object"!==o.name)||y(r)?t[a]=e[a]:t[a]=i(t[a]||{},r)}}),t};!0===t&&(o=a[1],a=Array.prototype.slice.call(a,2));let s=a.length;for(r=0;r<s;r++)o=i(o,a[r]);return o}Array.prototype.find;let{sma:{prototype:D}}=h().seriesTypes;!function(t){let e=["bottomLine"],r=["top","bottom"],a=["top"];function o(t){return"plot"+t.charAt(0).toUpperCase()+t.slice(1)}function i(t,e){let r=[];return(t.pointArrayMap||[]).forEach(t=>{t!==e&&r.push(o(t))}),r}function s(){let t=this,e=t.pointValKey,r=t.linesApiNames,a=t.areaLinesNames,s=t.points,l=t.options,p=t.graph,h={options:{gapSize:l.gapSize}},c=[],u=i(t,e),f=s.length,y;if(u.forEach((t,e)=>{for(c[e]=[];f--;)y=s[f],c[e].push({x:y.x,plotX:y.plotX,plotY:y[t],isNull:null==y[t]});f=s.length}),t.userOptions.fillColor&&a.length){let e=c[u.indexOf(o(a[0]))],r=1===a.length?s:c[u.indexOf(o(a[1]))],i=t.color;t.points=r,t.nextPoints=e,t.color=t.userOptions.fillColor,t.options=m(s,h),t.graph=t.area,t.fillGraph=!0,D.drawGraph.call(t),t.area=t.graph,delete t.nextPoints,delete t.fillGraph,t.color=i}r.forEach((e,r)=>{c[r]?(t.points=c[r],l[e]?t.options=m(l[e].styles,h):(0,n.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,n.error)('Error: "'+e+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),t.points=s,t.options=l,t.graph=p,D.drawGraph.call(t)}function l(t){let e,r=[],a=[];if(t=t||this.points,this.fillGraph&&this.nextPoints){if((e=D.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",r=D.getGraphPath.call(this,t),a=e.slice(0,r.length);for(let t=a.length-1;t>=0;t--)r.push(a[t])}}else r=D.getGraphPath.apply(this,arguments);return r}function p(t){let e=[];return(this.pointArrayMap||[]).forEach(r=>{e.push(t[r])}),e}function h(){let t=this.pointArrayMap,e=[],r;e=i(this),D.translate.apply(this,arguments),this.points.forEach(a=>{t.forEach((t,o)=>{r=a[t],this.dataModify&&(r=this.dataModify.modifyValue(r)),null!==r&&(a[e[o]]=this.yAxis.toPixels(r,!0))})})}t.compose=function(t){let o=t.prototype;return o.linesApiNames=o.linesApiNames||e.slice(),o.pointArrayMap=o.pointArrayMap||r.slice(),o.pointValKey=o.pointValKey||"top",o.areaLinesNames=o.areaLinesNames||a.slice(),o.drawGraph=s,o.getGraphPath=l,o.toYData=p,o.translate=h,t}}(r||(r={}));let x=r,{sma:b}=h().seriesTypes;class M extends b{calculateDM(t,e,r){let a=t[e][1],o=t[e][2],i=t[e-1][1],s=t[e-1][2];return f(a-i>s-o?r?Math.max(a-i,0):0:r?0:Math.max(s-o,0))}calculateDI(t,e){return t/e*100}calculateDX(t,e){return f(Math.abs(t-e)/Math.abs(t+e)*100)}smoothValues(t,e,r){return f(t-t/r+e)}getTR(t,e){return f(Math.max(t[1]-t[2],e?Math.abs(t[1]-e[3]):0,e?Math.abs(t[2]-e[3]):0))}getValues(t,e){let r=e.period,a=t.xData,o=t.yData,i=o?o.length:0,s=[],n=[],l=[];if(a.length<=r||!d(o[0])||4!==o[0].length)return;let p=0,h=0,c=0,u;for(u=1;u<i;u++){let t,e,i,f,y,d,g,m,D;u<=r?(f=this.calculateDM(o,u,!0),y=this.calculateDM(o,u),d=this.getTR(o[u],o[u-1]),p+=f,h+=y,c+=d,u===r&&(g=this.calculateDI(p,c),m=this.calculateDI(h,c),D=this.calculateDX(p,h),s.push([a[u],D,g,m]),n.push(a[u]),l.push([D,g,m]))):(f=this.calculateDM(o,u,!0),y=this.calculateDM(o,u),d=this.getTR(o[u],o[u-1]),t=this.smoothValues(p,f,r),e=this.smoothValues(h,y,r),i=this.smoothValues(c,d,r),p=t,h=e,c=i,g=this.calculateDI(p,c),m=this.calculateDI(h,c),D=this.calculateDX(p,h),s.push([a[u],D,g,m]),n.push(a[u]),l.push([D,g,m]))}return{values:s,xData:n,yData:l}}}M.defaultOptions=m(b.defaultOptions,{params:{index:void 0},marker:{enabled:!1},tooltip:{pointFormat:'<span style="color: {point.color}">●</span><b> {series.name}</b><br/><span style="color: {point.color}">DX</span>: {point.y}<br/><span style="color: {point.series.options.plusDILine.styles.lineColor}">+DI</span>: {point.plusDI}<br/><span style="color: {point.series.options.minusDILine.styles.lineColor}">-DI</span>: {point.minusDI}<br/>'},plusDILine:{styles:{lineWidth:1,lineColor:"#06b535"}},minusDILine:{styles:{lineWidth:1,lineColor:"#f21313"}},dataGrouping:{approximation:"averages"}}),function(t,e){let r;for(r in t||(t={}),e)t[r]=e[r]}(M.prototype,{areaLinesNames:[],nameBase:"DMI",linesApiNames:["plusDILine","minusDILine"],pointArrayMap:["y","plusDI","minusDI"],parallelArrays:["x","y","plusDI","minusDI"],pointValKey:"y"}),x.compose(M),h().registerSeriesType("dmi",M);let A=l();return s.default})());