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.

60 lines (59 loc) 2 kB
import { jsx as n } from "react/jsx-runtime"; import l from "react"; import { createRoot as a } from "react-dom/client"; import * as s from "d3"; import p from "./Tooltip.js"; let w = class extends l.Component { constructor() { super(), this.loadJSON = this.loadJSON.bind(this), this.create = this.create.bind(this), this.createLayer = this.createLayer.bind(this), this.loadJSON = this.loadJSON.bind(this), this.showToolTip = this.showToolTip.bind(this), this.moveToolTip = this.moveToolTip.bind(this), this.gRef = l.createRef(), this.state = { json: null }; } loadJSON(e) { return new Promise((t, i) => { s.json(e).then((function(r, o) { o && console.log("Error loading JSON: " + o), t(r); }).bind(this)); }); } createLayer(e) { alert("please implement createLayer"); } create() { const { file: e } = this.props; this.state.json ? this.createLayer(this.state.json) : this.loadJSON(e).then((t) => { this.createLayer(t); }); } showToolTip(e, t, i, r) { if (t) { debugger; const o = s.select("body").append("div").attr("class", "d3MapTooltip").style("position", "absolute").html("").style("left", window.event.pageX + 15 + "px").style("top", window.event.pageY - 50 + "px"); a(o._groups[0][0]).render(/* @__PURE__ */ n( p, { intl: this.props.intl, tooltip: e, data: t, tooltipEnableMarkdown: !1 } )); } } moveToolTip(e) { s.select(".d3MapTooltip").style("left", window.event.pageX + 15 + "px").style("top", window.event.pageY - 50 + "px"); } hiddenToolTip(e) { s.selectAll(".d3MapTooltip").remove(); } componentDidMount() { this.create(), this.props.zoom && this.props.current && this.props.zoom.current.fullView(); } render() { const { name: e, height: t, width: i } = this.props; return /* @__PURE__ */ n("g", { className: "layer", ref: this.gRef }); } }; export { w as default };