UNPKG

highcharts

Version:
14 lines 3.33 kB
/** * Highstock JS v12.6.0 (2026-04-13) * @module highcharts/modules/renko * @requires highcharts * @requires highcharts/modules/stock * * Renko series type for Highcharts Stock * * (c) 2010-2026 Highsoft AS * Author: Paweł Lysy * * 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 o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},e.d=(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let o=t.default;var r=e.n(o);let n=t.default.SeriesRegistry;var s=e.n(n);let{column:{prototype:{pointClass:a}}}=s().seriesTypes,i=t.default.Series.types.column;var l=e.n(i);let{doc:p,win:c}=r();function u(t){return h(t)&&"number"==typeof t.nodeType}function h(t,e){let o;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(o=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==o)}Array.prototype.find;class f 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(){var t;let e=this.dataTable.getModified(),o=[],r=[],n=[],s=this.getColumn("x",!0),a=this.getColumn("y",!0);if(!this.renkoData||this.renkoData.length>0)return{modified:e,closestPointRange:1,cropped:!1,cropStart:0};let i=this.options.boxSize,l="number"==typeof i&&!isNaN(i)&&i<1/0&&i>-1/0?i:(t=a[0],/%$/.test(i)?t*parseFloat(i)/100+0:parseFloat(i)),p=[],c=s.length,u=0,h=a[0];for(let t=1;t<c;t++){let e=a[t]-a[t-1];if(e>l){2===u&&(h+=l);for(let o=0;o<e/l;o++)p.push({x:s[t]+o,low:h,y:h+l,color:this.options.color,upTrend:!0}),h+=l;u=1}else if(Math.abs(e)>l){1===u&&(h-=l);for(let o=0;o<Math.abs(e)/l;o++)p.push({x:s[t]+o,low:h-l,y:h,color:this.options.downColor,upTrend:!1}),h-=l;u=2}}for(let t of(this.renkoData=p,p))o.push(t.x),r.push(t.y),n.push(t.low);return this.processedData=p,e.setColumn("x",o),e.setColumn("y",r),e.setColumn("low",n),{modified:e,cropped:!1,cropStart:0,closestPointRange:1}}}f.defaultOptions=function(t,...e){let o,r=[t,...e],n={},s=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,o){for(let o in t)Object.hasOwnProperty.call(t,o)&&e.call((0,t[o]),t[o],o,t)}(e,function(o,r){if("__proto__"!==r&&"constructor"!==r){let n;!h(o,!0)||(n=o?.constructor,h(o,!0)&&!u(o)&&n?.name&&"Object"!==n.name)||u(o)?t[r]=e[r]:t[r]=s(t[r]||{},o)}}),t};!0===t&&(n=r[1],r=Array.prototype.slice.call(r,2));let a=r.length;for(o=0;o<a;o++)n=s(n,r[o]);return n}(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/>'}}),function(t,e){let o;for(o in t||(t={}),e)t[o]=e[o]}(f.prototype,{pointClass:class extends a{getClassName(){return super.getClassName.call(this)+(this.upTrend?" highcharts-point-up":" highcharts-point-down")}}}),s().registerSeriesType("renko",f);let d=r();export{d as default};