realchart
Version:
Wooritech charting library
8 lines (6 loc) • 2.34 kB
JavaScript
/**
* RealChart Heatmap v1.4.29
* Copyright (C) 2023-2026 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 l,SeriesView as o,PointViewPool as a,SeriesAnimation as h,Color as u,RectElement as _}from"./index.mjs";class c extends l{}class d 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}}d.type=e,d.defaults=t(s.defaults,{tooltipText:"${detail}",tooltipDetail:"x: <b>${x}</b><br>y: <b>${y}</b><br>heat: <b>${z}</b>"});class g extends _{constructor(e){super(e,o.POINT_CLASS)}}class p extends o{constructor(e){super(e,"rct-heatmap-series"),this._cells=new a(this._pointContainer,g)}_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,(l,o)=>{const a=l.point=t[o];i[0].fill=s.brighten(1-(a.zValue-r)/n).toString(),this._setPointStyle(l,e,a,i)})}$_layoutCells(e,t){const s=this.model,i=this._inverted,r=this._getGrowRate();s.pointLabel;const n=this._labelViews(),l=this._labelContainer._textAlign,o=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=o.getUnitLen(u,t.xValue)*r,c=a.getUnitLen(h,t.yValue)*r;let d,g=o.getPos(u,t.xValue)-s/2,p=_-a.getPos(h,t.yValue)-c/2;if(t.xPos=i?_+a.getPos(h,t.yValue):g+s/2,t.yPos=i?u-o.getPos(u,t.xValue)+s/2:p+c/2,e.setBounds(g,p,s,c),n&&(d=n.get(t,0))){d.layout(l);const e=d.getBBox();i?(p=u-o.getPos(u,t.xValue)-e.height/2,g=_+a.getPos(h,t.yValue)):(g+=s/2,p+=(c-e.height)/2),g-=e.width/2,d.trans(g,p)}}})}}function x(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(d),e.SeriesView.register([d,p]))}export{d as HeatmapSeries,x as default};