UNPKG

realchart

Version:

Wooritech charting library

8 lines (6 loc) 2.32 kB
/** * RealChart Heatmap v1.3.17 * Copyright (C) 2023-2025 WooriTech Inc. * All Rights Reserved. */ import{HeatmapSeriesType as e,extend as t,Series as s,ConnectableSeries as i,minv as r,maxv as n,ZValuePoint as o,SeriesView as l,ElementPool as a,SeriesAnimation as h,Color as u,RectElement as _}from"./index.mjs";class c extends o{}class g extends i{getColor(e){}canMixWith(e){return!1}canCategorized(){return!0}hasZ(){return!0}defYAxisType(){return"category"}_createPoint(e){return new c(e)}_doPrepareRender(){super._doPrepareRender();let e=Number.MAX_VALUE,t=Number.MIN_VALUE;this._runPoints.forEach((s=>{isNaN(s.zValue)||(e=r(e,s.zValue),t=n(t,s.zValue))})),this._heatMin=e,this._heatMax=t}}g.type=e,g.defaults=t(s.defaults,{tooltipText:"x: <b>${x}</b><br>y: <b>${y}</b><br>heat: <b>${z}</b>"});class d extends _{constructor(e){super(e,l.POINT_CLASS)}}class p extends l{constructor(e){super(e,"rct-heatmap-series"),this._cells=new a(this._pointContainer,d)}_getPointPool(){return this._cells}_prepareSeries(e,t){this.$_parepareCells(t,this._visPoints)}_renderSeries(e,t){this._pointContainer.invert(this._inverted,t),this.$_layoutCells(e,t)}_runShowEffect(e){e&&h.grow(this)}_doViewRateChanged(e){this.$_layoutCells(this.width,this.height)}$_parepareCells(e,t){const s=new u(e._calcedColor),i=[{fill:void 0}],r=e._heatMin,n=e._heatMax-r;this._cells.prepare(t.length,((o,l)=>{const a=o.point=t[l];i[0].fill=s.brighten(1-(a.zValue-r)/n).toString(),this._setPointStyle(o,e,a,i)}))}$_layoutCells(e,t){const s=this.model,i=this._inverted,r=this._getGrowRate();s.pointLabel;const n=this._labelViews(),o=this._labelContainer._textAlign,l=s._xAxisObj,a=s._yAxisObj,h=i?e:t,u=i?t:e,_=i?0:t;this._cells.forEach((e=>{const t=e.point;if(e.setVis(!t.isNull)){const s=l.getUnitLen(u,t.xValue)*r,c=a.getUnitLen(h,t.yValue)*r;let g,d=l.getPos(u,t.xValue)-s/2,p=_-a.getPos(h,t.yValue)-c/2;if(t.xPos=i?_+a.getPos(h,t.yValue):d+s/2,t.yPos=i?u-l.getPos(u,t.xValue)+s/2:p+c/2,e.setBounds(d,p,s,c),n&&(g=n.get(t,0))){g.layout(o);const e=g.getBBox();i?(p=u-l.getPos(u,t.xValue)-e.height/2,d=_+a.getPos(h,t.yValue)):(d+=s/2,p+=(c-e.height)/2),d-=e.width/2,g.trans(d,p)}}}))}}function x(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(g),e.SeriesView.register([g,p]))}export{g as HeatmapSeries,x as default};