@devgateway/dvz-ui-react
Version:
A modular, embeddable React component library for data visualization and UI, built with TypeScript. Provides reusable components for charts, maps, dashboards, and more, with built-in support for internationalization and Redux integration.
2 lines (1 loc) • 1.19 kB
JavaScript
"use strict";const c=require("d3");function d(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const r in i)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>i[r]})}}return e.default=i,Object.freeze(e)}const o=d(c);class u{constructor(e){const{breaks:r,defaultFillColor:s,defaultBorderColor:n,defaultSize:h}=e;this.breaks=r,this.defaultFillColor=s,this.defaultBorderColor=n,this.defaultSize=h;const a=r.filter(t=>t.type!=="graterThan"),l=r.filter(t=>t.type==="graterThan");l.length>0&&(this.graterThanStyle=l[0]),this.domain=a.map(t=>Number(t.end)),this.sizeScale=o.scaleThreshold().domain(this.domain).range(a.map(t=>t.size)),this.colorScale=o.scaleThreshold().domain(a.map(t=>t.end)).range(r.map(t=>t.color)),this.getSize=this.getSize.bind(this),this.getColor=this.getColor.bind(this)}getSize(e){return this.breaks.length>0?e>Math.max(...this.domain)?this.graterThanStyle.size:this.defaultSize+this.sizeScale(e):this.defaultSize}getColor(e,r){return this.breaks.length>0?e>Math.max(...this.domain)?this.graterThanStyle.color:this.colorScale(e):this.defaultFillColor}}module.exports=u;