highcharts
Version:
JavaScript charting framework
14 lines • 3.88 kB
JavaScript
/**
* Highstock JS v12.6.0 (2026-04-13)
* @module highcharts/modules/heikinashi
* @requires highcharts
* @requires highcharts/modules/stock
*
* HeikinAshi series type for Highcharts Stock
*
* (c) 2010-2026 Highsoft AS
* Author: Karol Kołodziej
*
* 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 i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},e.d=(t,i)=>{for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=t.default;var n=e.n(i);let s=t.default.SeriesRegistry;var a=e.n(s);let{candlestick:{prototype:{pointClass:o}},hlc:{prototype:{pointClass:r}}}=a().seriesTypes,{doc:l,win:h}=n();function c(t,e,i,s={}){let a="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(a,"hcEvents")||(a.hcEvents={});let o=a.hcEvents;n().Point&&t instanceof n().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let r=t.addEventListener;r&&r.call(t,e,i,!!n().supportsPassiveEvents&&{passive:void 0===s.passive?-1!==e.indexOf("touch"):s.passive,capture:!1}),o[e]||(o[e]=[]);let l={fn:i,order:"number"==typeof s.order?s.order:1/0};return o[e].push(l),o[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,i){function n(e,i){let n=t.removeEventListener;n&&n.call(t,e,i,!1)}function s(i){let s,a;t.nodeName&&(e?(s={})[e]=!0:s=i,u(s,function(t,e){if(i[e])for(a=i[e].length;a--;)n(e,i[e][a].fn)}))}let a="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(a,"hcEvents")){let t=a.hcEvents;if(e){let a=t[e]||[];i?(t[e]=a.filter(function(t){return i!==t.fn}),n(e,i)):(s(t),t[e]=[])}else s(t),delete a.hcEvents}}(t,e,i)}}function p(t){return f(t)&&"number"==typeof t.nodeType}function f(t,e){let i;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(i=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==i)}function u(t,e,i){for(let n in t)Object.hasOwnProperty.call(t,n)&&e.call(i||t[n],t[n],n,t)}Array.prototype.find;let{composed:d}=n(),{candlestick:y}=a().seriesTypes;function v(){this.series.forEach(t=>{t.is("heikinashi")&&(t.heikinashiData.length=0,t.getHeikinashiData())})}function k(){let t=this.points,e=this.heikinashiData,i=this.cropStart||0;for(let n=0;n<t.length;n++){let s=t[n],a=e[n+i];s.open=a[0],s.high=a[1],s.low=a[2],s.close=a[3]}}function g(){this.heikinashiData.length&&(this.heikinashiData.length=0)}class m extends y{constructor(){super(...arguments),this.heikinashiData=[]}static compose(t,e){var i;y.compose(t),i="HeikinAshi",0>d.indexOf(i)&&d.push(i)&&(c(e,"postProcessData",v),c(m,"afterTranslate",k),c(m,"updatedData",g))}getHeikinashiData(){let t=this.allGroupedTable||this.dataTable,e=t.rowCount,i=this.heikinashiData;if(!i.length&&e){this.modifyFirstPointValue(t.getRow(0,this.pointArrayMap));for(let n=1;n<e;n++)this.modifyDataPoint(t.getRow(n,this.pointArrayMap),i[n-1])}this.heikinashiData=i}init(){super.init.apply(this,arguments),this.heikinashiData=[]}modifyFirstPointValue(t){let e=(t[0]+t[1]+t[2]+t[3])/4,i=(t[0]+t[3])/2;this.heikinashiData.push([e,t[1],t[2],i])}modifyDataPoint(t,e){let i=(e[0]+e[3])/2,n=(t[0]+t[1]+t[2]+t[3])/4,s=Math.max(t[1],n,i),a=Math.min(t[2],n,i);this.heikinashiData.push([i,s,a,n])}}m.defaultOptions=function(t,...e){let i,n=[t,...e],s={},a=function(t,e){return"object"!=typeof t&&(t={}),u(e,function(i,n){if("__proto__"!==n&&"constructor"!==n){let s;!f(i,!0)||(s=i?.constructor,f(i,!0)&&!p(i)&&s?.name&&"Object"!==s.name)||p(i)?t[n]=e[n]:t[n]=a(t[n]||{},i)}}),t};!0===t&&(s=n[1],n=Array.prototype.slice.call(n,2));let o=n.length;for(i=0;i<o;i++)s=a(s,n[i]);return s}(y.defaultOptions,{dataGrouping:{groupAll:!0}}),m.prototype.pointClass=class extends o{},a().registerSeriesType("heikinashi",m);let b=n();m.compose(b.Series,b.Axis);let D=n();export{D as default};