@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) • 2.05 kB
JavaScript
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("react/jsx-runtime"),A=require("react"),_=require("d3-shape"),I=require("d3"),R=require("./Tooltip.js"),D=require("react-intl");function E(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 P=E(I),T=(n,i,t,d,h,b,z,O)=>D.injectIntl(s=>{const{intl:M}=s;let o=d==="grouped";if(n){const{bars:v,xScale:x,yScale:y,innerWidth:q,innerHeight:w}=s;let a=new Set,f=[],r=0;v&&v.length>0?(a=new Set(s.bars.map(e=>e.data.indexValue)),f=n.data.filter(e=>Array.from(a).find(p=>p==e[0])),r=t==="horizontal"?s.bars[0].height:s.bars[0].width):(o=!1,n.data&&(n.data.forEach(e=>{e&&a.add(e[0])}),f=n.data,r=t==="horizontal"?w/a.size:q/a.size));let c,u;t==="horizontal"?(u=1,c=0):(u=0,c=1);const j=_.line();j.x(e=>t==="horizontal"?x(e[u]):x(e[u])+r*(o?h.length:1)/2).y(e=>t==="horizontal"?y(e[c])+r*(o?h.length:1)/2:y(e[c]));const l=P.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(A.Fragment,{children:[m.jsx("path",{d:j(f),fill:"none","stroke-width":"4",stroke:`${i}`,style:{pointerEvents:"none"}}),f.map(e=>{const S=t==="horizontal"?r*(o?h.length:1)/2:0,p=t==="horizontal"?0:r*(o?h.length:1)/2;return m.jsx("circle",{onMouseOver:g=>{l.style("visibility","visible")},onMouseMove:g=>{b&&b.trim().length>0&&(l.html(R.formatContent(b,{x:e[0],y:e[1],title:z,measure:O},M)),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:x(e[u])+p,cy:y(e[c])+S,r:7,fill:i,style:{pointerEvents:"all",cursor:"pointer"}},e.index)})]})}else return null});exports.default=T;
;