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.

2 lines (1 loc) 1.96 kB
"use strict";const m=require("react/jsx-runtime"),M=require("react"),I=require("d3-shape"),R=require("d3"),D=require("./Tooltip.js"),E=require("react-intl");function _(n){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const d=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(i,t,d.get?d:{enumerable:!0,get:()=>n[t]})}}return i.default=n,Object.freeze(i)}const B=_(R),L=(n,i,t,d,h,x,S,O)=>E.injectIntl(s=>{const{intl:q}=s;let o=d==="grouped";if(n){const{bars:j,xScale:b,yScale:p,innerWidth:w,innerHeight:A}=s;let c=new Set,f=[],r=0;j&&j.length>0?(c=new Set(s.bars.map(e=>e.data.indexValue)),f=n.data.filter(e=>Array.from(c).find(y=>y==e[0])),r=t==="horizontal"?s.bars[0].height:s.bars[0].width):(o=!1,n.data&&(n.data.forEach(e=>{e&&c.add(e[0])}),f=n.data,r=t==="horizontal"?A/c.size:w/c.size));let a,u;t==="horizontal"?(u=1,a=0):(u=0,a=1);const v=I.line();v.x(e=>t==="horizontal"?b(e[u]):b(e[u])+r*(o?h.length:1)/2).y(e=>t==="horizontal"?p(e[a])+r*(o?h.length:1)/2:p(e[a]));const l=B.select("#root").append("div").attr("class","chart tooltip").style("transition","all 1s ease-out;").style("background-color",i).style("position","absolute").style("visibility","hidden");return m.jsxs(M.Fragment,{children:[m.jsx("path",{d:v(f),fill:"none","stroke-width":"4",stroke:`${i}`,style:{pointerEvents:"none"}}),f.map(e=>{const z=t==="horizontal"?r*(o?h.length:1)/2:0,y=t==="horizontal"?0:r*(o?h.length:1)/2;return m.jsx("circle",{onMouseOver:g=>{l.style("visibility","visible")},onMouseMove:g=>{x&&x.trim().length>0&&(l.html(D.formatContent(x,{x:e[0],y:e[1],title:S,measure:O},q)),l.style("top",g.pageY-l.node().getBoundingClientRect().height+"px").style("left",g.pageX-l.node().getBoundingClientRect().width+"px"))},onMouseOut:g=>l.style("visibility","hidden"),cx:b(e[u])+y,cy:p(e[a])+z,r:7,fill:i,style:{pointerEvents:"all",cursor:"pointer"}},e.index)})]})}else return null});module.exports=L;