UNPKG

@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.

19 lines (18 loc) 1.07 kB
import * as s from "d3"; class d { constructor(e) { const { breaks: r, defaultFillColor: l, defaultBorderColor: h, defaultSize: o } = e; this.breaks = r, this.defaultFillColor = l, this.defaultBorderColor = h, this.defaultSize = o; const i = r.filter((t) => t.type !== "graterThan"), a = r.filter((t) => t.type === "graterThan"); a.length > 0 && (this.graterThanStyle = a[0]), this.domain = i.map((t) => Number(t.end)), this.sizeScale = s.scaleThreshold().domain(this.domain).range(i.map((t) => t.size)), this.colorScale = s.scaleThreshold().domain(i.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; } } export { d as default };