highcharts
Version:
JavaScript charting framework
14 lines • 5.92 kB
JavaScript
!/**
* Highstock JS v13.0.1 (2026-08-17)
* @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(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(e._Highcharts,e._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/indicators/dmi",["highcharts/highcharts"],function(e){return t(e,e.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/indicators/dmi"]=t(e._Highcharts,e._Highcharts.SeriesRegistry):e.Highcharts=t(e.Highcharts,e.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(e,t)=>(()=>{"use strict";var a,r={512(e){e.exports=t},944(t){t.exports=e}};let i={};function s(e){let t=i[e];if(void 0!==t)return t.exports;let a=i[e]={exports:{}};return r[e](a,a.exports,s),a.exports}s.n=e=>{let t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{if(Array.isArray(t))for(var a=0;a<t.length;){var r=t[a++],i=t[a++];s.o(e,r)?0===i&&a++:0===i?Object.defineProperty(e,r,{enumerable:!0,value:t[a++]}):Object.defineProperty(e,r,{enumerable:!0,get:i})}else for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let o={};s.d(o,{default:()=>g});var l=s(944),n=s.n(l),p=s(512),h=s.n(p);let{sma:{prototype:c}}=h().seriesTypes;!function(e){let t=["bottomLine"],a=["top","bottom"],r=["top"];function i(e){return"plot"+e.charAt(0).toUpperCase()+e.slice(1)}function s(e,t){let a=[];return(e.pointArrayMap||[]).forEach(e=>{e!==t&&a.push(i(e))}),a}function o(){let e=this,t=e.pointValKey,a=e.linesApiNames,r=e.areaLinesNames,o=e.points,n=e.options,p=e.graph,h={options:{gapSize:n.gapSize}},u=[],y=s(e,t),f=o.length,g;if(y.forEach((e,t)=>{for(u[t]=[];f--;)g=o[f],u[t].push({x:g.x,plotX:g.plotX,plotY:g[e],isNull:!(0,l.defined)(g[e])});f=o.length}),e.userOptions.fillColor&&r.length){let t=u[y.indexOf(i(r[0]))],a=1===r.length?o:u[y.indexOf(i(r[1]))],s=e.color;e.points=a,e.nextPoints=t,e.color=e.userOptions.fillColor,e.options=(0,l.merge)(o,h),e.graph=e.area,e.fillGraph=!0,c.drawGraph.call(e),e.area=e.graph,delete e.nextPoints,delete e.fillGraph,e.color=s}a.forEach((t,a)=>{u[a]?(e.points=u[a],n[t]?e.options=(0,l.merge)(n[t].styles,h):(0,l.error)('Error: "There is no '+t+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names."'),e.graph=e["graph"+t],c.drawGraph.call(e),e["graph"+t]=e.graph):(0,l.error)('Error: "'+t+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),e.points=o,e.options=n,e.graph=p,c.drawGraph.call(e)}function n(e){let t,a=[],r=[];if(e=e||this.points,this.fillGraph&&this.nextPoints){if((t=c.getGraphPath.call(this,this.nextPoints))&&t.length){t[0][0]="L",a=c.getGraphPath.call(this,e),r=t.slice(0,a.length);for(let e=r.length-1;e>=0;e--)a.push(r[e])}}else a=c.getGraphPath.apply(this,arguments);return a}function p(e){let t=[];return(this.pointArrayMap||[]).forEach(a=>{t.push(e[a])}),t}function h(){let e=this.pointArrayMap,t=[],a;t=s(this),c.translate.apply(this,arguments),this.points.forEach(r=>{e.forEach((e,i)=>{a=r[e],this.dataModify&&(a=this.dataModify.modifyValue(a)),null!==a&&(r[t[i]]=this.yAxis.toPixels(a,!0))})})}e.compose=function(e){let i=e.prototype;return i.linesApiNames=i.linesApiNames||t.slice(),i.pointArrayMap=i.pointArrayMap||a.slice(),i.pointValKey=i.pointValKey||"top",i.areaLinesNames=i.areaLinesNames||r.slice(),i.drawGraph=o,i.getGraphPath=n,i.toYData=p,i.translate=h,e}}(a||(a={}));let u=a,{sma:y}=h().seriesTypes;class f extends y{calculateDM(e,t,a){let r,i=e[t][1],s=e[t][2],o=e[t-1][1],n=e[t-1][2];return r=i-o>n-s?a?Math.max(i-o,0):0:a?0:Math.max(n-s,0),(0,l.correctFloat)(r)}calculateDI(e,t){return e/t*100}calculateDX(e,t){return(0,l.correctFloat)(Math.abs(e-t)/Math.abs(e+t)*100)}smoothValues(e,t,a){return(0,l.correctFloat)(e-e/a+t)}getTR(e,t){return(0,l.correctFloat)(Math.max(e[1]-e[2],t?Math.abs(e[1]-t[3]):0,t?Math.abs(e[2]-t[3]):0))}getValues(e,t){let a=t.period,r=e.xData,i=e.yData,s=i?i.length:0,o=[],n=[],p=[];if(r.length<=a||!(0,l.isArray)(i[0])||4!==i[0].length)return;let h=0,c=0,u=0,y;for(y=1;y<s;y++){let e,t,s,l,f,g,d,m,D;y<=a?(l=this.calculateDM(i,y,!0),f=this.calculateDM(i,y),g=this.getTR(i[y],i[y-1]),h+=l,c+=f,u+=g,y===a&&(d=this.calculateDI(h,u),m=this.calculateDI(c,u),D=this.calculateDX(h,c),o.push([r[y],D,d,m]),n.push(r[y]),p.push([D,d,m]))):(l=this.calculateDM(i,y,!0),f=this.calculateDM(i,y),g=this.getTR(i[y],i[y-1]),e=this.smoothValues(h,l,a),t=this.smoothValues(c,f,a),s=this.smoothValues(u,g,a),h=e,c=t,u=s,d=this.calculateDI(h,u),m=this.calculateDI(c,u),D=this.calculateDX(h,c),o.push([r[y],D,d,m]),n.push(r[y]),p.push([D,d,m]))}return{values:o,xData:n,yData:p}}}f.defaultOptions=(0,l.merge)(y.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:"var(--highcharts-positive-color)"}},minusDILine:{styles:{lineWidth:1,lineColor:"var(--highcharts-negative-color)"}},dataGrouping:{approximation:"averages"}}),(0,l.extend)(f.prototype,{areaLinesNames:[],nameBase:"DMI",linesApiNames:["plusDILine","minusDILine"],pointArrayMap:["y","plusDI","minusDI"],parallelArrays:["x","y","plusDI","minusDI"],pointValKey:"y"}),u.compose(f),h().registerSeriesType("dmi",f);let g=n();return o.default})());