UNPKG

highcharts

Version:
12 lines 2.49 kB
/** * Highstock JS v12.3.0 (2025-06-21) * @module highcharts/modules/renko * @requires highcharts * @requires highcharts/modules/stock * * Renko series type for Highcharts Stock * * (c) 2010-2025 Pawel Lysy * * License: www.highcharts.com/license */import*as t from"../highcharts.js";import"./stock.js";var e={};e.n=t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},e.d=(t,o)=>{for(var s in o)e.o(o,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:o[s]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let o=t.default;var s=e.n(o);e.d({},{});let r=t.default.SeriesRegistry;var a=e.n(r);let{column:{prototype:{pointClass:i}}}=a().seriesTypes,n=t.default.Series.types.column;var l=e.n(n);let{extend:p,merge:h,relativeLength:u,isNumber:d}=s();class c extends l(){constructor(){super(...arguments),this.hasDerivedData=!0,this.allowDG=!1}init(){super.init.apply(this,arguments),this.renkoData=[]}setData(t,e,o){this.renkoData=[],super.setData(t,e,o,!1)}getXExtremes(t){return this.processData(),{min:(t=this.getColumn("x",!0))[0],max:t[t.length-1]}}getProcessedData(){let t=this.dataTable.modified,e=[],o=[],s=[],r=this.getColumn("x",!0),a=this.getColumn("y",!0);if(!this.renkoData||this.renkoData.length>0)return{modified:t,closestPointRange:1,cropped:!1,cropStart:0};let i=this.options.boxSize,n=d(i)?i:u(i,a[0]),l=[],p=r.length,h=0,c=a[0];for(let t=1;t<p;t++){let e=a[t]-a[t-1];if(e>n){2===h&&(c+=n);for(let o=0;o<e/n;o++)l.push({x:r[t]+o,low:c,y:c+n,color:this.options.color,upTrend:!0}),c+=n;h=1}else if(Math.abs(e)>n){1===h&&(c-=n);for(let o=0;o<Math.abs(e)/n;o++)l.push({x:r[t]+o,low:c-n,y:c,color:this.options.downColor,upTrend:!1}),c-=n;h=2}}for(let t of(this.renkoData=l,l))e.push(t.x),o.push(t.y),s.push(t.low);return this.processedData=l,t.setColumn("x",e),t.setColumn("y",o),t.setColumn("low",s),{modified:t,cropped:!1,cropStart:0,closestPointRange:1}}}c.defaultOptions=h(l().defaultOptions,{boxSize:4,groupPadding:0,pointPadding:0,downColor:"#ff0000",navigatorOptions:{type:"renko"},fillColor:"transparent",borderWidth:2,lineWidth:0,stickyTracking:!0,borderRadius:{where:"all"},tooltip:{pointFormat:'<span style="color:{point.color}">●</span> {series.name}: <b>{point.low:.2f} - {point.y:.2f}</b><br/>'}}),p(c.prototype,{pointClass:class extends i{getClassName(){return super.getClassName.call(this)+(this.upTrend?" highcharts-point-up":" highcharts-point-down")}}}),a().registerSeriesType("renko",c);let f=s();export{f as default};