UNPKG

highcharts

Version:
14 lines 4.24 kB
/** * Highstock JS v12.6.0 (2026-04-13) * @module highcharts/indicators/pivot-points * @requires highcharts * @requires highcharts/modules/stock * * Indicator series type for Highcharts Stock * * (c) 2010-2026 Highsoft AS * Author: Paweł Fus * * A commercial license may be required depending on use. * See www.highcharts.com/license */import*as t from"../highcharts.js";var e={};e.n=t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a:a}),a},e.d=(t,a)=>{for(var l in a)e.o(a,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:a[l]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let a=t.default;var l=e.n(a);let n=t.default.SeriesRegistry;var o=e.n(n);let r=o().seriesTypes.sma.prototype.pointClass;function s(t,e){let a=t.series.pointArrayMap,l,n=a.length;for(o().seriesTypes.sma.prototype.pointClass.prototype[e].call(t);n--;)t[l="dataLabel"+a[n]]&&t[l].element&&t[l].destroy(),t[l]=null}let{doc:i,win:p}=l();function c(t){return d(t)&&"number"==typeof t.nodeType}function u(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||!u(t))}Array.prototype.find;let{sma:f}=o().seriesTypes;class y extends f{toYData(t){return[t.P]}translate(){let t=this;super.translate.apply(t),t.points.forEach(function(e){t.pointArrayMap.forEach(function(a){null!=e[a]&&(e["plot"+a]=t.yAxis.toPixels(e[a],!0))})}),t.plotEndPoint=t.xAxis.toPixels(t.endPoint,!0)}getGraphPath(t){let e=this,a=[[],[],[],[],[],[],[],[],[]],l=e.pointArrayMap.length,n=e.plotEndPoint,o=[],r,s,i=t.length,p;for(;i--;){for(p=0,s=t[i];p<l;p++)null!=s[r=e.pointArrayMap[p]]&&a[p].push({plotX:s.plotX,plotY:s["plot"+r],isNull:!1},{plotX:n,plotY:s["plot"+r],isNull:!1},{plotX:n,plotY:null,isNull:!0});n=s.plotX}return a.forEach(t=>{o=o.concat(super.getGraphPath.call(e,t))}),o}drawDataLabels(){let t,e,a,l,n=this,o=n.pointArrayMap;n.options.dataLabels.enabled&&(e=n.points.length,o.concat([!1]).forEach((r,s)=>{for(l=e;l--;)a=n.points[l],r?(a.y=a[r],a.pivotLine=r,a.plotY=a["plot"+r],t=a["dataLabel"+r],s&&(a["dataLabel"+o[s-1]]=a.dataLabel),a.dataLabels||(a.dataLabels=[]),a.dataLabels[0]=a.dataLabel=t=t&&t.element?t:null):a["dataLabel"+o[s-1]]=a.dataLabel;super.drawDataLabels.call(n)}))}getValues(t,e){let a,l,n,o,r,s,i,p=e.period,c=t.xData,d=t.yData,f=d?d.length:0,y=this[e.algorithm+"Placement"],h=[],b=[],m=[];if(!(c.length<p)&&u(d[0])&&4===d[0].length){for(i=p+1;i<=f+p;i+=p)n=c.slice(i-p-1,i),o=d.slice(i-p-1,i),l=n.length,a=n[l-1],s=y(this.getPivotAndHLC(o)),r=h.push([a].concat(s)),b.push(a),m.push(h[r-1].slice(1));return this.endPoint=n[0]+(a-n[0])/l*p,{values:h,xData:b,yData:m}}}getPivotAndHLC(t){let e=t[t.length-1][3],a=-1/0,l=1/0;return t.forEach(function(t){a=Math.max(a,t[1]),l=Math.min(l,t[2])}),[(a+l+e)/3,a,l,e]}standardPlacement(t){let e=t[1]-t[2];return[null,null,t[0]+e,2*t[0]-t[2],t[0],2*t[0]-t[1],t[0]-e,null,null]}camarillaPlacement(t){let e=t[1]-t[2];return[t[3]+1.5*e,t[3]+1.25*e,t[3]+1.1666*e,t[3]+1.0833*e,t[0],t[3]-1.0833*e,t[3]-1.1666*e,t[3]-1.25*e,t[3]-1.5*e]}fibonacciPlacement(t){let e=t[1]-t[2];return[null,t[0]+e,t[0]+.618*e,t[0]+.382*e,t[0],t[0]-.382*e,t[0]-.618*e,t[0]-e,null]}}y.defaultOptions=function(t,...e){let a,l=[t,...e],n={},o=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,a){for(let a in t)Object.hasOwnProperty.call(t,a)&&e.call((0,t[a]),t[a],a,t)}(e,function(a,l){if("__proto__"!==l&&"constructor"!==l){let n;!d(a,!0)||(n=a?.constructor,d(a,!0)&&!c(a)&&n?.name&&"Object"!==n.name)||c(a)?t[l]=e[l]:t[l]=o(t[l]||{},a)}}),t};!0===t&&(n=l[1],l=Array.prototype.slice.call(l,2));let r=l.length;for(a=0;a<r;a++)n=o(n,l[a]);return n}(f.defaultOptions,{params:{index:void 0,period:28,algorithm:"standard"},marker:{enabled:!1},enableMouseTracking:!1,dataLabels:{enabled:!0,format:"{point.pivotLine}"},dataGrouping:{approximation:"averages"}}),function(t,e){let a;for(a in t||(t={}),e)t[a]=e[a]}(y.prototype,{nameBase:"Pivot Points",pointArrayMap:["R4","R3","R2","R1","P","S1","S2","S3","S4"],pointValKey:"P",pointClass:class extends r{destroyElements(){s(this,"destroyElements")}destroy(){s(this,"destroyElements")}}}),o().registerSeriesType("pivotpoints",y);let h=l();export{h as default};