@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.28 kB
JavaScript
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("d3");function u(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const r in i)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(e,r,a.get?a:{enumerable:!0,get:()=>i[r]})}}return e.default=i,Object.freeze(e)}const o=u(d);class c{constructor(e){const{breaks:r,defaultFillColor:a,defaultBorderColor:n,defaultSize:h}=e;this.breaks=r,this.defaultFillColor=a,this.defaultBorderColor=n,this.defaultSize=h;const s=r.filter(t=>t.type!=="graterThan"),l=r.filter(t=>t.type==="graterThan");l.length>0&&(this.graterThanStyle=l[0]),this.domain=s.map(t=>Number(t.end)),this.sizeScale=o.scaleThreshold().domain(this.domain).range(s.map(t=>t.size)),this.colorScale=o.scaleThreshold().domain(s.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}}exports.default=c;