@performant-software/visualize 1.0.7-beta.0 → 1.0.7-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{TreeGraph:function(){return O},withZoom:function(){return x}});var n=require("@visx/group"),r=require("@visx/hierarchy"),a=require("@visx/responsive"),o=require("@visx/shape"),i=require("d3-shape"),l=require("react"),s=e.n(l),c=require("underscore"),d=e.n(c),u=require("@visx/event"),p=require("@visx/zoom"),m=require("i18next"),h=e.n(m);const g={en:{translation:JSON.parse('{"Zoom":{"buttons":{"center":"Center","clear":"Clear","reset":"Reset","zoomIn":"+","zoomOut":"-"}}}')}},b=h().createInstance();b.init({debug:!0,fallbackLng:"en",lng:"en",interpolation:{escapeValue:!1},resources:g});var f=b;function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(this,arguments)}const k={scaleX:1,scaleY:1,translateX:0,translateY:0,skewX:0,skewY:0};var x=e=>t=>{const{parentWidth:n,parentHeight:r}=t,{scaleXMin:a=.5,scaleXMax:o=4}=t,{scaleYMin:i=.5,scaleYMax:c=4}=t,{initialTransform:d=k}=t,m=(0,l.useCallback)((e=>s().createElement("rect",{width:n,height:r,rx:14,fill:"transparent",onTouchStart:e.dragStart,onTouchMove:e.dragMove,onTouchEnd:e.dragEnd,onMouseDown:e.dragStart,onMouseMove:e.dragMove,onMouseUp:e.dragEnd,onMouseLeave:()=>{e.isDragging&&e.dragEnd()},onDoubleClick:t=>{const n=(0,u.localPoint)(t)||{x:0,y:0};e.scale({scaleX:1.1,scaleY:1.1,point:n})}})),[n,r]);return s().createElement(p.Zoom,{width:n,height:r,scaleXMin:a,scaleXMax:o,scaleYMin:i,scaleYMax:c,initialTransformMatrix:d},(n=>s().createElement("div",{className:"zoom"},s().createElement(e,y({},t,{renderZoomContainer:m.bind(void 0,n),zoom:n})),s().createElement("div",{className:"controls"},s().createElement("button",{type:"button",className:"btn btn-zoom",onClick:()=>n.scale({scaleX:1.2,scaleY:1.2})},f.t("Zoom.buttons.zoomIn")),s().createElement("button",{type:"button",className:"btn btn-zoom btn-bottom",onClick:()=>n.scale({scaleX:.8,scaleY:.8})},f.t("Zoom.buttons.zoomOut")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.center},f.t("Zoom.buttons.center")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.reset},f.t("Zoom.buttons.reset")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.clear},f.t("Zoom.buttons.clear"))))))};function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v.apply(this,arguments)}const E="polar",C="curve",T="line",M="step",z="vertical",w=e=>s().createElement("circle",v({r:e.radius},e)),N=e=>s().createElement("rect",e),L=e=>{const t=(0,l.useRef)(),a=e.parentWidth-e.margin.left-e.margin.right,c=e.parentHeight-e.margin.top-e.margin.bottom,u=(0,l.useMemo)((()=>{let t;return t=e.layout===E?e.linkType===M?o.LinkRadialStep:e.linkType===C?o.LinkRadialCurve:e.linkType===T?o.LinkRadialLine:o.LinkRadial:e.orientation===z?e.linkType===M?o.LinkVerticalStep:e.linkType===C?o.LinkVerticalCurve:e.linkType===T?o.LinkVerticalLine:o.LinkVertical:e.linkType===M?o.LinkHorizontalStep:e.linkType===C?o.LinkHorizontalCurve:e.linkType===T?o.LinkHorizontalLine:o.LinkHorizontal,t}),[e.layout,e.linkType,e.orientation]),p=(0,l.useCallback)(((e,t)=>{let n=t;return e.isExpanded&&(n=d().max(d().map(e.children,(e=>p(e,t+1))))),n}),[]),m=(0,l.useCallback)(((t,n)=>{let r,a;if(e.layout===E){const[e,o]=(0,i.pointRadial)(t,n);r=o,a=e}else e.orientation===z?(r=n,a=t):(r=t,a=n);return{top:r,left:a}}),[e.layout,e.orientation]),h=(0,l.useMemo)((()=>{let t,n,r;const o=p(e.data,1);return e.layout===E?(r={x:a/2,y:c/2},t=2*Math.PI,n=Math.min(a,c)/2*(o/2)):(r={x:0,y:0},e.orientation===z?(t=a,n=c):(t=c,n=a)),{sizeWidth:t,sizeHeight:n,origin:r}}),[p,c,a,e.data,e.layout,e.orientation]),g=(0,l.useCallback)((t=>e.renderNode?e.renderNode(t.data):0===t.depth?s().createElement(w,{fill:"#FF4A4A",onClick:e.onClick&&e.onClick.bind(void 0,t.data)}):s().createElement(N,{fill:"#272b4d",stroke:t.data.children?"#03c0dc":"#26deb0",strokeWidth:1,strokeDasharray:t.data.children?"0":"2,2",strokeOpacity:t.data.children?1:.6,rx:t.data.children?0:10,onClick:e.onClick&&e.onClick.bind(void 0,t.data)})),[e.onClick,e.renderNode]),b=(0,l.useCallback)((t=>e.renderText?e.renderText(t.data):s().createElement("text",{dy:"0.33em",fontSize:e.fontSize,textAnchor:"middle",fill:e.textColor},t.data.name)),[e.renderText]),f=(0,l.useCallback)(((e,t)=>{const{top:r,left:a}=m(e.x,e.y);return s().createElement(n.Group,{top:r,left:a,key:t},g(e),b(e))}),[g,b,e.layout,e.orientation]);return(0,l.useEffect)((()=>{const{current:n}=t;if(n){const t=15,r=n.getElementsByTagName("g");d().each(r,(n=>{const r=d().first(n.getElementsByTagName("circle")),a=d().first(n.getElementsByTagName("rect")),o=d().first(n.getElementsByTagName("text"));if(o){const{height:i}=o.getBBox();if(!o.getElementsByTagName("tspan").length){const l=o.innerHTML.split(/\s+/),s=[];let c=0;for(let t=0;t<l.length;t+=1)if(s[c]||(s[c]=[]),s[c].push(l[t]),t<l.length-1){const r=o.cloneNode();r.innerHTML=[...s[c],l[t+1]].join(" "),n.append(r),r.getBBox().width>e.nodeWidth&&(c+=1),r.remove()}d().each(s,((e,t)=>{const n=document.createElementNS("http://www.w3.org/2000/svg","tspan");n.setAttribute("x","0"),t>0&&n.setAttribute("dy",`${i}px`),n.appendChild(document.createTextNode(e.join(" "))),0===t?o.replaceChildren(n):o.appendChild(n)}));const u=o.getBBox();r&&o?(r.setAttribute("x",u.x-t),r.setAttribute("y",u.y-t),r.setAttribute("r",u.width/2+t)):a&&o&&(a.setAttribute("x",u.x-t),a.setAttribute("y",u.y-t),a.setAttribute("width",u.width+2*t),a.setAttribute("height",u.height+2*t))}}}))}}),[e.data]),s().createElement("div",{className:"tree-graph",ref:t,style:{display:"flex",flexGrow:"1"}},s().createElement("svg",{width:e.parentWidth,height:e.parentHeight-e.offset,ref:e.zoom.containerRef},e.renderZoomContainer(),s().createElement(n.Group,{top:e.margin.top,left:e.margin.left,transform:e.zoom.toString()},s().createElement(r.Tree,{root:(0,r.hierarchy)(e.data,(e=>e.isExpanded?e.children:null)),size:[h.sizeWidth,h.sizeHeight],separation:(e,t)=>(e.parent===t.parent?1:2)/e.depth},(t=>s().createElement(n.Group,{top:h.origin.y,left:h.origin.x},t.links().map(((t,n)=>s().createElement(u,{key:n,data:t,percent:e.stepPercent,stroke:e.linkColor,strokeWidth:e.linkWidth,fill:"none"}))),d().map(t.descendants(),f)))))))};L.defaultProps={fontSize:12,layout:"cartesian",linkColor:"#B2B09B",linkType:T,linkWidth:1,margin:{top:30,left:30,right:30,bottom:70},nodeWidth:75,offset:0,orientation:"horizontal",stepPercent:.5,textColor:"#FFFFFF"};const S=(0,a.withParentSize)(x(L));S.Circle=w,S.Rectangle=N;var O=S;module.exports=t}();
1
+ !function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{TreeGraph:function(){return L},withZoom:function(){return v}});var n=require("@visx/group"),r=require("@visx/hierarchy"),o=require("@visx/responsive"),a=require("@visx/shape"),i=require("d3-shape"),l=require("react"),s=e.n(l),c=require("underscore"),u=e.n(c),p=require("@visx/event"),d=require("@visx/zoom"),m=require("i18next"),f=e.n(m);const g={en:{translation:JSON.parse('{"Zoom":{"buttons":{"center":"Center","clear":"Clear","reset":"Reset","zoomIn":"+","zoomOut":"-"}}}')}},b=f().createInstance();b.init({debug:!0,fallbackLng:"en",lng:"en",interpolation:{escapeValue:!1},resources:g});var h=b;function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(this,arguments)}const k={scaleX:1,scaleY:1,translateX:0,translateY:0,skewX:0,skewY:0};var v=e=>t=>{const{parentWidth:n,parentHeight:r}=t,{scaleXMin:o=.5,scaleXMax:a=4}=t,{scaleYMin:i=.5,scaleYMax:c=4}=t,{initialTransform:u=k}=t,m=(0,l.useCallback)((e=>s().createElement("rect",{width:n,height:r,rx:14,fill:"transparent",onTouchStart:e.dragStart,onTouchMove:e.dragMove,onTouchEnd:e.dragEnd,onMouseDown:e.dragStart,onMouseMove:e.dragMove,onMouseUp:e.dragEnd,onMouseLeave:()=>{e.isDragging&&e.dragEnd()},onDoubleClick:t=>{const n=(0,p.localPoint)(t)||{x:0,y:0};e.scale({scaleX:1.1,scaleY:1.1,point:n})}})),[n,r]);return s().createElement(d.Zoom,{width:n,height:r,scaleXMin:o,scaleXMax:a,scaleYMin:i,scaleYMax:c,initialTransformMatrix:u},(n=>s().createElement("div",{className:"zoom"},s().createElement(e,y({},t,{renderZoomContainer:m.bind(void 0,n),zoom:n})),s().createElement("div",{className:"controls"},s().createElement("button",{type:"button",className:"btn btn-zoom",onClick:()=>n.scale({scaleX:1.2,scaleY:1.2})},h.t("Zoom.buttons.zoomIn")),s().createElement("button",{type:"button",className:"btn btn-zoom btn-bottom",onClick:()=>n.scale({scaleX:.8,scaleY:.8})},h.t("Zoom.buttons.zoomOut")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.center},h.t("Zoom.buttons.center")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.reset},h.t("Zoom.buttons.reset")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.clear},h.t("Zoom.buttons.clear"))))))};const E="polar",x="curve",M="line",T="step",z="vertical",C=e=>{const t=(0,l.useRef)(),o=e.parentWidth-e.margin.left-e.margin.right,c=e.parentHeight-e.margin.top-e.margin.bottom,p=(0,l.useMemo)((()=>{let t;return t=e.layout===E?e.linkType===T?a.LinkRadialStep:e.linkType===x?a.LinkRadialCurve:e.linkType===M?a.LinkRadialLine:a.LinkRadial:e.orientation===z?e.linkType===T?a.LinkVerticalStep:e.linkType===x?a.LinkVerticalCurve:e.linkType===M?a.LinkVerticalLine:a.LinkVertical:e.linkType===T?a.LinkHorizontalStep:e.linkType===x?a.LinkHorizontalCurve:e.linkType===M?a.LinkHorizontalLine:a.LinkHorizontal,t}),[e.layout,e.linkType,e.orientation]),d=(0,l.useCallback)(((e,t)=>{let n=t;return e.isExpanded&&(n=u().max(u().map(e.children,(e=>d(e,t+1))))),n}),[]),m=(0,l.useCallback)(((t,n)=>{let r,o;if(e.layout===E){const[e,a]=(0,i.pointRadial)(t,n);r=a,o=e}else e.orientation===z?(r=n,o=t):(r=t,o=n);return{top:r,left:o}}),[e.layout,e.orientation]),f=(0,l.useMemo)((()=>{let t,n,r;const a=d(e.data,1);return e.layout===E?(r={x:o/2,y:c/2},t=2*Math.PI,n=Math.min(o,c)/2*(a/2)):(r={x:0,y:0},e.orientation===z?(t=o,n=c):(t=c,n=o)),{sizeWidth:t,sizeHeight:n,origin:r}}),[d,c,o,e.data,e.layout,e.orientation]),g=(0,l.useCallback)((t=>s().createElement("foreignObject",null,e.renderNode(t.data))),[e.renderNode]),b=(0,l.useCallback)(((e,t)=>{const{top:r,left:o}=m(e.x,e.y);return s().createElement(n.Group,{nodeleft:o,nodetop:r,top:r,left:o,key:t},g(e))}),[g,e.layout,e.orientation,e.linkType]);return(0,l.useEffect)((()=>{const{current:e}=t;if(e){const t=e.getElementsByTagName("g");u().each(t,(e=>{const t=u().first(e.getElementsByTagName("foreignObject"));if(t&&t.firstChild){const{offsetWidth:n,offsetHeight:r}=t.firstChild;t.setAttribute("width",n),t.setAttribute("height",r);const o=`translate(${parseFloat(e.getAttribute("nodeleft"))-n/2}, ${parseFloat(e.getAttribute("nodetop"))-r/2})`;e.setAttribute("transform",o)}}))}}),[e.data,e.layout,e.orientation,e.linkType]),s().createElement("div",{className:"tree-graph",style:{display:"flex",flexGrow:"1"}},s().createElement("svg",{width:e.parentWidth,height:e.parentHeight-e.offset,ref:e.zoom.containerRef},e.renderZoomContainer(),s().createElement(n.Group,{top:e.margin.top,left:e.margin.left,transform:e.zoom.toString()},s().createElement(r.Tree,{root:(0,r.hierarchy)(e.data,(e=>e.isExpanded?e.children:null)),size:[f.sizeWidth,f.sizeHeight],separation:(e,t)=>(e.parent===t.parent?1:2)/e.depth},(r=>s().createElement(n.Group,{innerRef:t,left:f.origin.x,top:f.origin.y},r.links().map(((t,n)=>s().createElement(p,{key:n,data:t,percent:e.stepPercent,stroke:e.linkColor,strokeWidth:e.linkWidth,fill:"none"}))),u().map(r.descendants(),b)))))))};C.defaultProps={layout:"cartesian",linkColor:"#B2B09B",linkType:M,linkWidth:1,margin:{top:30,left:30,right:30,bottom:70},offset:0,orientation:"horizontal",stepPercent:.5};var L=(0,o.withParentSize)(v(C));module.exports=t}();
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","mappings":"yBACA,IAAIA,EAAsB,CCA1BA,EAAwB,SAASC,GAChC,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,WAAa,OAAOF,EAAgB,OAAG,EACvC,WAAa,OAAOA,CAAQ,EAE7B,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CACR,ECNAF,EAAwB,SAASM,EAASC,GACzC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAG3E,ECPAR,EAAwB,SAASc,EAAKC,GAAQ,OAAOL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,EAAO,ECCtGf,EAAwB,SAASM,GACX,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GACvD,G,kFCNA,IAAI,EAA+BC,QAAQ,eCAvC,EAA+BA,QAAQ,mBCAvC,EAA+BA,QAAQ,oBCAvC,EAA+BA,QAAQ,eCAvC,EAA+BA,QAAQ,YCAvC,EAA+BA,QAAQ,S,SCAvC,EAA+BA,QAAQ,c,SCAvC,EAA+BA,QAAQ,eCAvC,EAA+BA,QAAQ,cCAvC,EAA+BA,QAAQ,W,SCI3C,MAAMC,EAAY,CAChBC,GAAI,CACFC,Y,oHAIEC,EAAOC,IAAAA,iBAEbD,EACGE,KAAK,CACJC,OAAO,EACPC,YAAa,KACbC,IAAK,KACLC,cAAe,CACbC,aAAa,GAEfV,cAGJ,Q,oOCIA,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pack://@performant-software/visualize/webpack/bootstrap","webpack://@performant-software/visualize/webpack/runtime/compat get default export","webpack://@performant-software/visualize/webpack/runtime/define property getters","webpack://@performant-software/visualize/webpack/runtime/hasOwnProperty shorthand","webpack://@performant-software/visualize/webpack/runtime/make namespace object","webpack://@performant-software/visualize/external commonjs \"@visx/group\"","webpack://@performant-software/visualize/external commonjs \"@visx/hierarchy\"","webpack://@performant-software/visualize/external commonjs \"@visx/responsive\"","webpack://@performant-software/visualize/external commonjs \"@visx/shape\"","webpack://@performant-software/visualize/external commonjs \"d3-shape\"","webpack://@performant-software/visualize/external commonjs2 \"react\"","webpack://@performant-software/visualize/external commonjs \"underscore\"","webpack://@performant-software/visualize/external commonjs \"@visx/event\"","webpack://@performant-software/visualize/external commonjs \"@visx/zoom\"","webpack://@performant-software/visualize/external commonjs \"i18next\"","webpack://@performant-software/visualize/./src/i18n/i18n.js","webpack://@performant-software/visualize/./src/hooks/Zoom.js","webpack://@performant-software/visualize/./src/components/TreeGraph.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/group\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/hierarchy\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/responsive\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/shape\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"d3-shape\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"underscore\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/event\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/zoom\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"i18next\");","import i18next from 'i18next';\n\nimport en from './en.json';\n\nconst resources = {\n en: {\n translation: en\n }\n};\n\nconst i18n = i18next.createInstance();\n\ni18n\n .init({\n debug: true,\n fallbackLng: 'en',\n lng: 'en',\n interpolation: {\n escapeValue: false,\n },\n resources\n });\n\nexport default i18n;\n","// @flow\n\nimport React, { useCallback, type ComponentType, type Element } from 'react';\nimport { localPoint } from '@visx/event';\nimport { Zoom } from '@visx/zoom';\nimport i18n from '../i18n/i18n';\nimport './Zoom.css';\n\ntype Props = {\n initialTransform?: {\n skewX: number,\n skewY: number,\n scaleX: number,\n scaleY: number,\n translateX: number,\n translateY: number\n },\n parentHeight: number,\n parentWidth: number,\n scaleXMax?: number,\n scaleXMin?: number,\n scaleYMax?: number,\n scaleYMin?: number\n};\n\ntype WithZoomType = (WrappedComponent: ComponentType<any>) => (props: Props) => Element<any>;\n\nconst DEFAULT_INITIAL_TRANSFORM = {\n scaleX: 1,\n scaleY: 1,\n translateX: 0,\n translateY: 0,\n skewX: 0,\n skewY: 0,\n};\n\nconst withZoom: WithZoomType = (WrappedComponent: ComponentType<any>) => (props: Props) => {\n const { parentWidth: width, parentHeight: height } = props;\n const { scaleXMin = 1 / 2, scaleXMax = 4 } = props;\n const { scaleYMin = 1 / 2, scaleYMax = 4 } = props;\n const { initialTransform = DEFAULT_INITIAL_TRANSFORM } = props;\n\n /**\n * Renders the container with zoom controls.\n *\n * @type {unknown}\n */\n const renderZoomContainer = useCallback((zoom) => (\n <rect\n width={width}\n height={height}\n rx={14}\n fill='transparent'\n onTouchStart={zoom.dragStart}\n onTouchMove={zoom.dragMove}\n onTouchEnd={zoom.dragEnd}\n onMouseDown={zoom.dragStart}\n onMouseMove={zoom.dragMove}\n onMouseUp={zoom.dragEnd}\n onMouseLeave={() => {\n if (zoom.isDragging) zoom.dragEnd();\n }}\n onDoubleClick={(event) => {\n const point = localPoint(event) || { x: 0, y: 0 };\n zoom.scale({ scaleX: 1.1, scaleY: 1.1, point });\n }}\n />\n ), [width, height]);\n\n return (\n <Zoom\n width={width}\n height={height}\n scaleXMin={scaleXMin}\n scaleXMax={scaleXMax}\n scaleYMin={scaleYMin}\n scaleYMax={scaleYMax}\n initialTransformMatrix={initialTransform}\n >\n { (zoom) => (\n <div\n className='zoom'\n >\n <WrappedComponent\n {...props}\n renderZoomContainer={renderZoomContainer.bind(this, zoom)}\n zoom={zoom}\n />\n <div\n className='controls'\n >\n <button\n type='button'\n className='btn btn-zoom'\n onClick={() => zoom.scale({ scaleX: 1.2, scaleY: 1.2 })}\n >\n { i18n.t('Zoom.buttons.zoomIn') }\n </button>\n <button\n type='button'\n className='btn btn-zoom btn-bottom'\n onClick={() => zoom.scale({ scaleX: 0.8, scaleY: 0.8 })}\n >\n { i18n.t('Zoom.buttons.zoomOut') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.center}\n >\n { i18n.t('Zoom.buttons.center') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.reset}\n >\n { i18n.t('Zoom.buttons.reset') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.clear}\n >\n { i18n.t('Zoom.buttons.clear') }\n </button>\n </div>\n </div>\n )}\n </Zoom>\n );\n};\n\nexport default withZoom;\n\nexport type ZoomProps = {\n renderZoomContainer: () => Element<any>,\n zoom: typeof Zoom\n};\n","// @flow\n\nimport { Group } from '@visx/group';\nimport { hierarchy, Tree } from '@visx/hierarchy';\nimport { withParentSize } from '@visx/responsive';\nimport {\n LinkHorizontal,\n LinkHorizontalCurve,\n LinkHorizontalLine,\n LinkHorizontalStep,\n LinkRadial,\n LinkRadialCurve,\n LinkRadialLine,\n LinkRadialStep,\n LinkVertical,\n LinkVerticalCurve,\n LinkVerticalLine,\n LinkVerticalStep\n} from '@visx/shape';\nimport { pointRadial } from 'd3-shape';\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n type ComponentType,\n type Element\n} from 'react';\nimport _ from 'underscore';\nimport withZoom, { type ZoomProps } from '../hooks/Zoom';\nimport './TreeGraph.css';\n\ntype Props = ZoomProps & {\n data: any,\n fontSize: number,\n layout: string,\n linkType: string,\n offset: number,\n orientation: string,\n parentHeight: number,\n parentWidth: number,\n linkColor: string,\n linkWidth: number,\n margin: {\n top: number,\n right: number,\n bottom: number,\n left: number\n },\n nodeWidth: number,\n onClick?: (data: any) => void,\n renderNode?: (data: any) => Element<any>,\n renderText?: (data: any) => Element<any>,\n stepPercent: number,\n textColor: string\n};\n\nconst Layout = {\n cartesian: 'cartesian',\n polar: 'polar'\n};\n\nconst LinkType = {\n curve: 'curve',\n line: 'line',\n step: 'step'\n};\n\nconst Orientation = {\n horizontal: 'horizontal',\n vertical: 'vertical'\n};\n\nconst Circle: ComponentType<any> = (props: any) => (\n <circle\n r={props.radius}\n {...props}\n />\n);\n\nconst Rectangle: ComponentType<any> = (props: any) => (\n <rect\n {...props}\n />\n);\n\nconst TreeGraph = (props: Props) => {\n const ref = useRef();\n\n const innerWidth = props.parentWidth - props.margin.left - props.margin.right;\n const innerHeight = props.parentHeight - props.margin.top - props.margin.bottom;\n\n /**\n * Sets the link component based on the layout, linkType, and orientation props.\n *\n * @type {*}\n */\n const LinkComponent = useMemo(() => {\n let value;\n\n if (props.layout === Layout.polar) {\n if (props.linkType === LinkType.step) {\n value = LinkRadialStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkRadialCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkRadialLine;\n } else {\n value = LinkRadial;\n }\n } else if (props.orientation === Orientation.vertical) {\n if (props.linkType === LinkType.step) {\n value = LinkVerticalStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkVerticalCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkVerticalLine;\n } else {\n value = LinkVertical;\n }\n } else if (props.linkType === LinkType.step) {\n value = LinkHorizontalStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkHorizontalCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkHorizontalLine;\n } else {\n value = LinkHorizontal;\n }\n\n return value;\n }, [props.layout, props.linkType, props.orientation]);\n\n /**\n * Returns the depth of the last expanded node.\n *\n * @type {function(*, *): *}\n */\n const getMaxDepth = useCallback((node, depth) => {\n let max = depth;\n\n if (node.isExpanded) {\n max = _.max(_.map(node.children, (child) => getMaxDepth(child, depth + 1)));\n }\n\n return max;\n }, []);\n\n /**\n * Returns the node position for the passed coordinates.\n *\n * @type {function(*, *): {top: *, left: *}}\n */\n const getNodePosition = useCallback((x, y) => {\n let top;\n let left;\n\n if (props.layout === Layout.polar) {\n const [radialX, radialY] = pointRadial(x, y);\n top = radialY;\n left = radialX;\n } else if (props.orientation === Orientation.vertical) {\n top = y;\n left = x;\n } else {\n top = x;\n left = y;\n }\n\n return {\n top,\n left\n };\n }, [props.layout, props.orientation]);\n\n /**\n * Returns the position and size of the root node.\n *\n * @type {{sizeWidth: *, origin: *, sizeHeight: *}}\n */\n const root = useMemo(() => {\n let sizeWidth;\n let sizeHeight;\n let origin;\n\n const depth = getMaxDepth(props.data, 1);\n\n if (props.layout === Layout.polar) {\n origin = {\n x: innerWidth / 2,\n y: innerHeight / 2,\n };\n sizeWidth = 2 * Math.PI;\n sizeHeight = (Math.min(innerWidth, innerHeight) / 2) * (depth / 2);\n } else {\n origin = { x: 0, y: 0 };\n if (props.orientation === Orientation.vertical) {\n sizeWidth = innerWidth;\n sizeHeight = innerHeight;\n } else {\n sizeWidth = innerHeight;\n sizeHeight = innerWidth;\n }\n }\n\n return {\n sizeWidth,\n sizeHeight,\n origin\n };\n }, [getMaxDepth, innerHeight, innerWidth, props.data, props.layout, props.orientation]);\n\n /**\n * Renders the passed node. If provided, only the \"renderNode\" prop is called.\n *\n * @type {(function(*): (*))|*}\n */\n const renderNode = useCallback((node) => {\n if (props.renderNode) {\n return props.renderNode(node.data);\n }\n\n if (node.depth === 0) {\n return (\n <Circle\n fill='#FF4A4A'\n onClick={props.onClick && props.onClick.bind(this, node.data)}\n />\n );\n }\n\n return (\n <Rectangle\n fill='#272b4d'\n stroke={node.data.children ? '#03c0dc' : '#26deb0'}\n strokeWidth={1}\n strokeDasharray={node.data.children ? '0' : '2,2'}\n strokeOpacity={node.data.children ? 1 : 0.6}\n rx={node.data.children ? 0 : 10}\n onClick={props.onClick && props.onClick.bind(this, node.data)}\n />\n );\n }, [props.onClick, props.renderNode]);\n\n /**\n * Renders the text for the passed node.\n *\n * @type {(function(*): (*))|*}\n */\n const renderText = useCallback((node) => {\n if (props.renderText) {\n return props.renderText(node.data);\n }\n\n return (\n <text\n dy='0.33em'\n fontSize={props.fontSize}\n textAnchor='middle'\n fill={props.textColor}\n >\n { node.data.name }\n </text>\n );\n }, [props.renderText]);\n\n /**\n * Renders the group element for the passed node.\n *\n * @type {unknown}\n */\n const renderGroup = useCallback((node, key) => {\n const { top, left } = getNodePosition(node.x, node.y);\n\n return (\n <Group\n top={top}\n left={left}\n key={key}\n >\n { renderNode(node) }\n { renderText(node) }\n </Group>\n );\n }, [renderNode, renderText, props.layout, props.orientation]);\n\n /**\n * Resizes the \"circle\" and \"rect\" elements based on the text contained in the group. This effect will also\n * convert text into multiple lines.\n */\n useEffect(() => {\n const { current } = ref;\n if (current) {\n const padding = 15;\n const groups = current.getElementsByTagName('g');\n _.each(groups, (group) => {\n const circle = _.first(group.getElementsByTagName('circle'));\n const rect = _.first(group.getElementsByTagName('rect'));\n const text = _.first(group.getElementsByTagName('text'));\n\n if (text) {\n const { height } = text.getBBox();\n\n if (!text.getElementsByTagName('tspan').length) {\n const words = text.innerHTML.split(/\\s+/);\n\n const lines = [];\n let lineIndex = 0;\n\n for (let i = 0; i < words.length; i += 1) {\n // Initialize the line array for the current line\n if (!lines[lineIndex]) {\n lines[lineIndex] = [];\n }\n\n // Add the current word to the current line\n lines[lineIndex].push(words[i]);\n\n // Look ahead to the next word and increment the line index if necessary\n if (i < words.length - 1) {\n const testElement = text.cloneNode();\n testElement.innerHTML = [...lines[lineIndex], words[i + 1]].join(' ');\n group.append(testElement);\n\n if (testElement.getBBox().width > props.nodeWidth) {\n lineIndex += 1;\n }\n\n testElement.remove();\n }\n }\n\n // Append the lines to the text element\n _.each(lines, (line, index) => {\n const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');\n tspan.setAttribute('x', '0');\n if (index > 0) {\n tspan.setAttribute('dy', `${height}px`);\n }\n tspan.appendChild(document.createTextNode(line.join(' ')));\n\n if (index === 0) {\n text.replaceChildren(tspan);\n } else {\n text.appendChild(tspan);\n }\n });\n\n // Set the shape attributes based on the text size\n const bbox = text.getBBox();\n if (circle && text) {\n circle.setAttribute('x', bbox.x - padding);\n circle.setAttribute('y', bbox.y - padding);\n circle.setAttribute('r', (bbox.width / 2) + padding);\n } else if (rect && text) {\n rect.setAttribute('x', bbox.x - padding);\n rect.setAttribute('y', bbox.y - padding);\n rect.setAttribute('width', bbox.width + 2 * padding);\n rect.setAttribute('height', bbox.height + 2 * padding);\n }\n }\n }\n });\n }\n }, [props.data]);\n\n return (\n <div\n className='tree-graph'\n ref={ref}\n style={{\n display: 'flex',\n flexGrow: '1'\n }}\n >\n <svg\n width={props.parentWidth}\n height={props.parentHeight - props.offset}\n ref={props.zoom.containerRef}\n >\n { props.renderZoomContainer() }\n <Group\n top={props.margin.top}\n left={props.margin.left}\n transform={props.zoom.toString()}\n >\n <Tree\n root={hierarchy(props.data, (d) => (d.isExpanded ? d.children : null))}\n size={[root.sizeWidth, root.sizeHeight]}\n separation={(a, b) => (a.parent === b.parent ? 1 : 2) / a.depth}\n >\n { (tree) => (\n <Group\n top={root.origin.y}\n left={root.origin.x}\n >\n { tree.links().map((link, i) => (\n <LinkComponent\n key={i}\n data={link}\n percent={props.stepPercent}\n stroke={props.linkColor}\n strokeWidth={props.linkWidth}\n fill='none'\n />\n ))}\n { _.map(tree.descendants(), renderGroup) }\n </Group>\n )}\n </Tree>\n </Group>\n </svg>\n </div>\n );\n};\n\nTreeGraph.defaultProps = {\n fontSize: 12,\n layout: Layout.cartesian,\n linkColor: '#B2B09B',\n linkType: LinkType.line,\n linkWidth: 1,\n margin: {\n top: 30,\n left: 30,\n right: 30,\n bottom: 70\n },\n nodeWidth: 75,\n offset: 0,\n orientation: Orientation.horizontal,\n stepPercent: 0.5,\n textColor: '#FFFFFF'\n};\n\ntype TreeGraphType = ComponentType<any> & {\n Circle: typeof Circle,\n Rectangle: typeof Rectangle\n};\n\nconst TreeGraphComponent: TreeGraphType = withParentSize(withZoom(TreeGraph));\nTreeGraphComponent.Circle = Circle;\nTreeGraphComponent.Rectangle = Rectangle;\n\nexport default TreeGraphComponent;\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","resources","en","translation","i18n","i18next","init","debug","fallbackLng","lng","interpolation","escapeValue","DEFAULT_INITIAL_TRANSFORM","scaleX","scaleY","translateX","translateY","skewX","skewY","WrappedComponent","props","parentWidth","width","parentHeight","height","scaleXMin","scaleXMax","scaleYMin","scaleYMax","initialTransform","renderZoomContainer","useCallback","zoom","rx","fill","onTouchStart","dragStart","onTouchMove","dragMove","onTouchEnd","dragEnd","onMouseDown","onMouseMove","onMouseUp","onMouseLeave","isDragging","onDoubleClick","event","point","localPoint","x","y","scale","Zoom","initialTransformMatrix","className","bind","type","onClick","center","reset","clear","Layout","LinkType","Orientation","Circle","r","radius","Rectangle","TreeGraph","ref","useRef","innerWidth","margin","left","right","innerHeight","top","bottom","LinkComponent","useMemo","layout","linkType","LinkRadialStep","LinkRadialCurve","LinkRadialLine","LinkRadial","orientation","LinkVerticalStep","LinkVerticalCurve","LinkVerticalLine","LinkVertical","LinkHorizontalStep","LinkHorizontalCurve","LinkHorizontalLine","LinkHorizontal","getMaxDepth","node","depth","max","isExpanded","_","children","child","getNodePosition","radialX","radialY","pointRadial","root","sizeWidth","sizeHeight","origin","data","Math","PI","min","renderNode","stroke","strokeWidth","strokeDasharray","strokeOpacity","renderText","dy","fontSize","textAnchor","textColor","name","renderGroup","Group","useEffect","current","padding","groups","getElementsByTagName","group","circle","rect","text","getBBox","length","words","innerHTML","split","lines","lineIndex","i","push","testElement","cloneNode","join","append","nodeWidth","remove","line","index","tspan","document","createElementNS","setAttribute","appendChild","createTextNode","replaceChildren","bbox","style","display","flexGrow","offset","containerRef","transform","toString","Tree","hierarchy","size","separation","b","parent","tree","links","map","link","percent","stepPercent","linkColor","linkWidth","descendants","defaultProps","TreeGraphComponent","withParentSize","withZoom"],"sourceRoot":""}
1
+ {"version":3,"file":"index.js","mappings":"yBACA,IAAIA,EAAsB,CCA1BA,EAAwB,SAASC,GAChC,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,WAAa,OAAOF,EAAgB,OAAG,EACvC,WAAa,OAAOA,CAAQ,EAE7B,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CACR,ECNAF,EAAwB,SAASM,EAASC,GACzC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAG3E,ECPAR,EAAwB,SAASc,EAAKC,GAAQ,OAAOL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,EAAO,ECCtGf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ack://@performant-software/visualize/webpack/runtime/compat get default export","webpack://@performant-software/visualize/webpack/runtime/define property getters","webpack://@performant-software/visualize/webpack/runtime/hasOwnProperty shorthand","webpack://@performant-software/visualize/webpack/runtime/make namespace object","webpack://@performant-software/visualize/external commonjs \"@visx/group\"","webpack://@performant-software/visualize/external commonjs \"@visx/hierarchy\"","webpack://@performant-software/visualize/external commonjs \"@visx/responsive\"","webpack://@performant-software/visualize/external commonjs \"@visx/shape\"","webpack://@performant-software/visualize/external commonjs \"d3-shape\"","webpack://@performant-software/visualize/external commonjs2 \"react\"","webpack://@performant-software/visualize/external commonjs \"underscore\"","webpack://@performant-software/visualize/external commonjs \"@visx/event\"","webpack://@performant-software/visualize/external commonjs \"@visx/zoom\"","webpack://@performant-software/visualize/external commonjs \"i18next\"","webpack://@performant-software/visualize/./src/i18n/i18n.js","webpack://@performant-software/visualize/./src/hooks/Zoom.js","webpack://@performant-software/visualize/./src/components/TreeGraph.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/group\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/hierarchy\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/responsive\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/shape\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"d3-shape\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"underscore\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/event\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/zoom\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"i18next\");","import i18next from 'i18next';\n\nimport en from './en.json';\n\nconst resources = {\n en: {\n translation: en\n }\n};\n\nconst i18n = i18next.createInstance();\n\ni18n\n .init({\n debug: true,\n fallbackLng: 'en',\n lng: 'en',\n interpolation: {\n escapeValue: false,\n },\n resources\n });\n\nexport default i18n;\n","// @flow\n\nimport React, { useCallback, type ComponentType, type Element } from 'react';\nimport { localPoint } from '@visx/event';\nimport { Zoom } from '@visx/zoom';\nimport i18n from '../i18n/i18n';\nimport './Zoom.css';\n\ntype Props = {\n initialTransform?: {\n skewX: number,\n skewY: number,\n scaleX: number,\n scaleY: number,\n translateX: number,\n translateY: number\n },\n parentHeight: number,\n parentWidth: number,\n scaleXMax?: number,\n scaleXMin?: number,\n scaleYMax?: number,\n scaleYMin?: number\n};\n\ntype WithZoomType = (WrappedComponent: ComponentType<any>) => (props: Props) => Element<any>;\n\nconst DEFAULT_INITIAL_TRANSFORM = {\n scaleX: 1,\n scaleY: 1,\n translateX: 0,\n translateY: 0,\n skewX: 0,\n skewY: 0,\n};\n\nconst withZoom: WithZoomType = (WrappedComponent: ComponentType<any>) => (props: Props) => {\n const { parentWidth: width, parentHeight: height } = props;\n const { scaleXMin = 1 / 2, scaleXMax = 4 } = props;\n const { scaleYMin = 1 / 2, scaleYMax = 4 } = props;\n const { initialTransform = DEFAULT_INITIAL_TRANSFORM } = props;\n\n /**\n * Renders the container with zoom controls.\n *\n * @type {unknown}\n */\n const renderZoomContainer = useCallback((zoom) => (\n <rect\n width={width}\n height={height}\n rx={14}\n fill='transparent'\n onTouchStart={zoom.dragStart}\n onTouchMove={zoom.dragMove}\n onTouchEnd={zoom.dragEnd}\n onMouseDown={zoom.dragStart}\n onMouseMove={zoom.dragMove}\n onMouseUp={zoom.dragEnd}\n onMouseLeave={() => {\n if (zoom.isDragging) zoom.dragEnd();\n }}\n onDoubleClick={(event) => {\n const point = localPoint(event) || { x: 0, y: 0 };\n zoom.scale({ scaleX: 1.1, scaleY: 1.1, point });\n }}\n />\n ), [width, height]);\n\n return (\n <Zoom\n width={width}\n height={height}\n scaleXMin={scaleXMin}\n scaleXMax={scaleXMax}\n scaleYMin={scaleYMin}\n scaleYMax={scaleYMax}\n initialTransformMatrix={initialTransform}\n >\n { (zoom) => (\n <div\n className='zoom'\n >\n <WrappedComponent\n {...props}\n renderZoomContainer={renderZoomContainer.bind(this, zoom)}\n zoom={zoom}\n />\n <div\n className='controls'\n >\n <button\n type='button'\n className='btn btn-zoom'\n onClick={() => zoom.scale({ scaleX: 1.2, scaleY: 1.2 })}\n >\n { i18n.t('Zoom.buttons.zoomIn') }\n </button>\n <button\n type='button'\n className='btn btn-zoom btn-bottom'\n onClick={() => zoom.scale({ scaleX: 0.8, scaleY: 0.8 })}\n >\n { i18n.t('Zoom.buttons.zoomOut') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.center}\n >\n { i18n.t('Zoom.buttons.center') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.reset}\n >\n { i18n.t('Zoom.buttons.reset') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.clear}\n >\n { i18n.t('Zoom.buttons.clear') }\n </button>\n </div>\n </div>\n )}\n </Zoom>\n );\n};\n\nexport default withZoom;\n\nexport type ZoomProps = {\n renderZoomContainer: () => Element<any>,\n zoom: typeof Zoom\n};\n","// @flow\n\nimport { Group } from '@visx/group';\nimport { hierarchy, Tree } from '@visx/hierarchy';\nimport { withParentSize } from '@visx/responsive';\nimport {\n LinkHorizontal,\n LinkHorizontalCurve,\n LinkHorizontalLine,\n LinkHorizontalStep,\n LinkRadial,\n LinkRadialCurve,\n LinkRadialLine,\n LinkRadialStep,\n LinkVertical,\n LinkVerticalCurve,\n LinkVerticalLine,\n LinkVerticalStep\n} from '@visx/shape';\nimport { pointRadial } from 'd3-shape';\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n type ComponentType,\n type Element\n} from 'react';\nimport _ from 'underscore';\nimport withZoom, { type ZoomProps } from '../hooks/Zoom';\nimport './TreeGraph.css';\n\ntype Props = ZoomProps & {\n data: any,\n layout: string,\n linkType: string,\n offset: number,\n orientation: string,\n parentHeight: number,\n parentWidth: number,\n linkColor: string,\n linkWidth: number,\n margin: {\n top: number,\n right: number,\n bottom: number,\n left: number\n },\n renderNode?: (data: any) => Element<any>,\n stepPercent: number,\n};\n\nconst Layout = {\n cartesian: 'cartesian',\n polar: 'polar'\n};\n\nconst LinkType = {\n curve: 'curve',\n line: 'line',\n step: 'step'\n};\n\nconst Orientation = {\n horizontal: 'horizontal',\n vertical: 'vertical'\n};\n\nconst TreeGraph = (props: Props) => {\n const ref = useRef();\n\n const innerWidth = props.parentWidth - props.margin.left - props.margin.right;\n const innerHeight = props.parentHeight - props.margin.top - props.margin.bottom;\n\n /**\n * Sets the link component based on the layout, linkType, and orientation props.\n *\n * @type {*}\n */\n const LinkComponent = useMemo(() => {\n let value;\n\n if (props.layout === Layout.polar) {\n if (props.linkType === LinkType.step) {\n value = LinkRadialStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkRadialCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkRadialLine;\n } else {\n value = LinkRadial;\n }\n } else if (props.orientation === Orientation.vertical) {\n if (props.linkType === LinkType.step) {\n value = LinkVerticalStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkVerticalCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkVerticalLine;\n } else {\n value = LinkVertical;\n }\n } else if (props.linkType === LinkType.step) {\n value = LinkHorizontalStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkHorizontalCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkHorizontalLine;\n } else {\n value = LinkHorizontal;\n }\n\n return value;\n }, [props.layout, props.linkType, props.orientation]);\n\n /**\n * Returns the depth of the last expanded node.\n *\n * @type {function(*, *): *}\n */\n const getMaxDepth = useCallback((node, depth) => {\n let max = depth;\n\n if (node.isExpanded) {\n max = _.max(_.map(node.children, (child) => getMaxDepth(child, depth + 1)));\n }\n\n return max;\n }, []);\n\n /**\n * Returns the node position for the passed coordinates.\n *\n * @type {function(*, *): {top: *, left: *}}\n */\n const getNodePosition = useCallback((x, y) => {\n let top;\n let left;\n\n if (props.layout === Layout.polar) {\n const [radialX, radialY] = pointRadial(x, y);\n top = radialY;\n left = radialX;\n } else if (props.orientation === Orientation.vertical) {\n top = y;\n left = x;\n } else {\n top = x;\n left = y;\n }\n\n return {\n top,\n left\n };\n }, [props.layout, props.orientation]);\n\n /**\n * Returns the position and size of the root node.\n *\n * @type {{sizeWidth: *, origin: *, sizeHeight: *}}\n */\n const root = useMemo(() => {\n let sizeWidth;\n let sizeHeight;\n let origin;\n\n const depth = getMaxDepth(props.data, 1);\n\n if (props.layout === Layout.polar) {\n origin = {\n x: innerWidth / 2,\n y: innerHeight / 2,\n };\n sizeWidth = 2 * Math.PI;\n sizeHeight = (Math.min(innerWidth, innerHeight) / 2) * (depth / 2);\n } else {\n origin = { x: 0, y: 0 };\n if (props.orientation === Orientation.vertical) {\n sizeWidth = innerWidth;\n sizeHeight = innerHeight;\n } else {\n sizeWidth = innerHeight;\n sizeHeight = innerWidth;\n }\n }\n\n return {\n sizeWidth,\n sizeHeight,\n origin\n };\n }, [getMaxDepth, innerHeight, innerWidth, props.data, props.layout, props.orientation]);\n\n const renderNode = useCallback((node) => (\n <foreignObject>\n { props.renderNode(node.data) }\n </foreignObject>\n ), [props.renderNode]);\n\n /**\n * Renders the group element for the passed node.\n *\n * @type {unknown}\n */\n const renderGroup = useCallback((node, key) => {\n const { top, left } = getNodePosition(node.x, node.y);\n\n return (\n <Group\n nodeleft={left}\n nodetop={top}\n top={top}\n left={left}\n key={key}\n >\n { renderNode(node) }\n </Group>\n );\n }, [renderNode, props.layout, props.orientation, props.linkType]);\n\n /**\n * Resizes the \"circle\" and \"rect\" elements based on the text contained in the group. This effect will also\n * convert text into multiple lines.\n */\n useEffect(() => {\n const { current } = ref;\n if (current) {\n const groups = current.getElementsByTagName('g');\n _.each(groups, (group) => {\n const object = _.first(group.getElementsByTagName('foreignObject'));\n if (object && object.firstChild) {\n const { offsetWidth: width, offsetHeight: height } = object.firstChild;\n\n // Set the width and height of the foreignObject element\n object.setAttribute('width', width);\n object.setAttribute('height', height);\n\n // Transform the position of the group element based on the width and height of the contents\n const leftPosition = parseFloat(group.getAttribute('nodeleft'));\n const topPosition = parseFloat(group.getAttribute('nodetop'));\n\n const transform = `translate(${leftPosition - (width / 2.0)}, ${topPosition - (height / 2.0)})`;\n group.setAttribute('transform', transform);\n }\n });\n }\n }, [props.data, props.layout, props.orientation, props.linkType]);\n\n return (\n <div\n className='tree-graph'\n style={{\n display: 'flex',\n flexGrow: '1'\n }}\n >\n <svg\n width={props.parentWidth}\n height={props.parentHeight - props.offset}\n ref={props.zoom.containerRef}\n >\n { props.renderZoomContainer() }\n <Group\n top={props.margin.top}\n left={props.margin.left}\n transform={props.zoom.toString()}\n >\n <Tree\n root={hierarchy(props.data, (d) => (d.isExpanded ? d.children : null))}\n size={[root.sizeWidth, root.sizeHeight]}\n separation={(a, b) => (a.parent === b.parent ? 1 : 2) / a.depth}\n >\n { (tree) => (\n <Group\n innerRef={ref}\n left={root.origin.x}\n top={root.origin.y}\n >\n { tree.links().map((link, i) => (\n <LinkComponent\n key={i}\n data={link}\n percent={props.stepPercent}\n stroke={props.linkColor}\n strokeWidth={props.linkWidth}\n fill='none'\n />\n ))}\n { _.map(tree.descendants(), renderGroup) }\n </Group>\n )}\n </Tree>\n </Group>\n </svg>\n </div>\n );\n};\n\nTreeGraph.defaultProps = {\n layout: Layout.cartesian,\n linkColor: '#B2B09B',\n linkType: LinkType.line,\n linkWidth: 1,\n margin: {\n top: 30,\n left: 30,\n right: 30,\n bottom: 70\n },\n offset: 0,\n orientation: Orientation.horizontal,\n stepPercent: 0.5\n};\n\nconst TreeGraphComponent: ComponentType<any> = withParentSize(withZoom(TreeGraph));\nexport default TreeGraphComponent;\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","resources","en","translation","i18n","i18next","init","debug","fallbackLng","lng","interpolation","escapeValue","DEFAULT_INITIAL_TRANSFORM","scaleX","scaleY","translateX","translateY","skewX","skewY","WrappedComponent","props","parentWidth","width","parentHeight","height","scaleXMin","scaleXMax","scaleYMin","scaleYMax","initialTransform","renderZoomContainer","useCallback","zoom","rx","fill","onTouchStart","dragStart","onTouchMove","dragMove","onTouchEnd","dragEnd","onMouseDown","onMouseMove","onMouseUp","onMouseLeave","isDragging","onDoubleClick","event","point","localPoint","x","y","scale","Zoom","initialTransformMatrix","className","bind","type","onClick","center","reset","clear","Layout","LinkType","Orientation","TreeGraph","ref","useRef","innerWidth","margin","left","right","innerHeight","top","bottom","LinkComponent","useMemo","layout","linkType","LinkRadialStep","LinkRadialCurve","LinkRadialLine","LinkRadial","orientation","LinkVerticalStep","LinkVerticalCurve","LinkVerticalLine","LinkVertical","LinkHorizontalStep","LinkHorizontalCurve","LinkHorizontalLine","LinkHorizontal","getMaxDepth","node","depth","max","isExpanded","_","children","child","getNodePosition","radialX","radialY","pointRadial","root","sizeWidth","sizeHeight","origin","data","Math","PI","min","renderNode","renderGroup","Group","nodeleft","nodetop","useEffect","current","groups","getElementsByTagName","group","object","firstChild","offsetWidth","offsetHeight","setAttribute","transform","parseFloat","getAttribute","style","display","flexGrow","offset","containerRef","toString","Tree","hierarchy","size","separation","b","parent","tree","innerRef","links","map","link","i","percent","stepPercent","stroke","linkColor","strokeWidth","linkWidth","descendants","defaultProps","withParentSize","withZoom"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@performant-software/visualize",
3
- "version": "1.0.7-beta.0",
3
+ "version": "1.0.7-beta.2",
4
4
  "description": "A package of components used for data visualization",
5
5
  "license": "MIT",
6
6
  "main": "./build/index.js",
@@ -32,7 +32,6 @@ import './TreeGraph.css';
32
32
 
33
33
  type Props = ZoomProps & {
34
34
  data: any,
35
- fontSize: number,
36
35
  layout: string,
37
36
  linkType: string,
38
37
  offset: number,
@@ -47,12 +46,8 @@ type Props = ZoomProps & {
47
46
  bottom: number,
48
47
  left: number
49
48
  },
50
- nodeWidth: number,
51
- onClick?: (data: any) => void,
52
49
  renderNode?: (data: any) => Element<any>,
53
- renderText?: (data: any) => Element<any>,
54
50
  stepPercent: number,
55
- textColor: string
56
51
  };
57
52
 
58
53
  const Layout = {
@@ -71,19 +66,6 @@ const Orientation = {
71
66
  vertical: 'vertical'
72
67
  };
73
68
 
74
- const Circle: ComponentType<any> = (props: any) => (
75
- <circle
76
- r={props.radius}
77
- {...props}
78
- />
79
- );
80
-
81
- const Rectangle: ComponentType<any> = (props: any) => (
82
- <rect
83
- {...props}
84
- />
85
- );
86
-
87
69
  const TreeGraph = (props: Props) => {
88
70
  const ref = useRef();
89
71
 
@@ -210,59 +192,11 @@ const TreeGraph = (props: Props) => {
210
192
  };
211
193
  }, [getMaxDepth, innerHeight, innerWidth, props.data, props.layout, props.orientation]);
212
194
 
213
- /**
214
- * Renders the passed node. If provided, only the "renderNode" prop is called.
215
- *
216
- * @type {(function(*): (*))|*}
217
- */
218
- const renderNode = useCallback((node) => {
219
- if (props.renderNode) {
220
- return props.renderNode(node.data);
221
- }
222
-
223
- if (node.depth === 0) {
224
- return (
225
- <Circle
226
- fill='#FF4A4A'
227
- onClick={props.onClick && props.onClick.bind(this, node.data)}
228
- />
229
- );
230
- }
231
-
232
- return (
233
- <Rectangle
234
- fill='#272b4d'
235
- stroke={node.data.children ? '#03c0dc' : '#26deb0'}
236
- strokeWidth={1}
237
- strokeDasharray={node.data.children ? '0' : '2,2'}
238
- strokeOpacity={node.data.children ? 1 : 0.6}
239
- rx={node.data.children ? 0 : 10}
240
- onClick={props.onClick && props.onClick.bind(this, node.data)}
241
- />
242
- );
243
- }, [props.onClick, props.renderNode]);
244
-
245
- /**
246
- * Renders the text for the passed node.
247
- *
248
- * @type {(function(*): (*))|*}
249
- */
250
- const renderText = useCallback((node) => {
251
- if (props.renderText) {
252
- return props.renderText(node.data);
253
- }
254
-
255
- return (
256
- <text
257
- dy='0.33em'
258
- fontSize={props.fontSize}
259
- textAnchor='middle'
260
- fill={props.textColor}
261
- >
262
- { node.data.name }
263
- </text>
264
- );
265
- }, [props.renderText]);
195
+ const renderNode = useCallback((node) => (
196
+ <foreignObject>
197
+ { props.renderNode(node.data) }
198
+ </foreignObject>
199
+ ), [props.renderNode]);
266
200
 
267
201
  /**
268
202
  * Renders the group element for the passed node.
@@ -274,15 +208,16 @@ const TreeGraph = (props: Props) => {
274
208
 
275
209
  return (
276
210
  <Group
211
+ nodeleft={left}
212
+ nodetop={top}
277
213
  top={top}
278
214
  left={left}
279
215
  key={key}
280
216
  >
281
217
  { renderNode(node) }
282
- { renderText(node) }
283
218
  </Group>
284
219
  );
285
- }, [renderNode, renderText, props.layout, props.orientation]);
220
+ }, [renderNode, props.layout, props.orientation, props.linkType]);
286
221
 
287
222
  /**
288
223
  * Resizes the "circle" and "rect" elements based on the text contained in the group. This effect will also
@@ -291,83 +226,30 @@ const TreeGraph = (props: Props) => {
291
226
  useEffect(() => {
292
227
  const { current } = ref;
293
228
  if (current) {
294
- const padding = 15;
295
229
  const groups = current.getElementsByTagName('g');
296
230
  _.each(groups, (group) => {
297
- const circle = _.first(group.getElementsByTagName('circle'));
298
- const rect = _.first(group.getElementsByTagName('rect'));
299
- const text = _.first(group.getElementsByTagName('text'));
300
-
301
- if (text) {
302
- const { height } = text.getBBox();
303
-
304
- if (!text.getElementsByTagName('tspan').length) {
305
- const words = text.innerHTML.split(/\s+/);
306
-
307
- const lines = [];
308
- let lineIndex = 0;
309
-
310
- for (let i = 0; i < words.length; i += 1) {
311
- // Initialize the line array for the current line
312
- if (!lines[lineIndex]) {
313
- lines[lineIndex] = [];
314
- }
315
-
316
- // Add the current word to the current line
317
- lines[lineIndex].push(words[i]);
231
+ const object = _.first(group.getElementsByTagName('foreignObject'));
232
+ if (object && object.firstChild) {
233
+ const { offsetWidth: width, offsetHeight: height } = object.firstChild;
318
234
 
319
- // Look ahead to the next word and increment the line index if necessary
320
- if (i < words.length - 1) {
321
- const testElement = text.cloneNode();
322
- testElement.innerHTML = [...lines[lineIndex], words[i + 1]].join(' ');
323
- group.append(testElement);
235
+ // Set the width and height of the foreignObject element
236
+ object.setAttribute('width', width);
237
+ object.setAttribute('height', height);
324
238
 
325
- if (testElement.getBBox().width > props.nodeWidth) {
326
- lineIndex += 1;
327
- }
239
+ // Transform the position of the group element based on the width and height of the contents
240
+ const leftPosition = parseFloat(group.getAttribute('nodeleft'));
241
+ const topPosition = parseFloat(group.getAttribute('nodetop'));
328
242
 
329
- testElement.remove();
330
- }
331
- }
332
-
333
- // Append the lines to the text element
334
- _.each(lines, (line, index) => {
335
- const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
336
- tspan.setAttribute('x', '0');
337
- if (index > 0) {
338
- tspan.setAttribute('dy', `${height}px`);
339
- }
340
- tspan.appendChild(document.createTextNode(line.join(' ')));
341
-
342
- if (index === 0) {
343
- text.replaceChildren(tspan);
344
- } else {
345
- text.appendChild(tspan);
346
- }
347
- });
348
-
349
- // Set the shape attributes based on the text size
350
- const bbox = text.getBBox();
351
- if (circle && text) {
352
- circle.setAttribute('x', bbox.x - padding);
353
- circle.setAttribute('y', bbox.y - padding);
354
- circle.setAttribute('r', (bbox.width / 2) + padding);
355
- } else if (rect && text) {
356
- rect.setAttribute('x', bbox.x - padding);
357
- rect.setAttribute('y', bbox.y - padding);
358
- rect.setAttribute('width', bbox.width + 2 * padding);
359
- rect.setAttribute('height', bbox.height + 2 * padding);
360
- }
361
- }
243
+ const transform = `translate(${leftPosition - (width / 2.0)}, ${topPosition - (height / 2.0)})`;
244
+ group.setAttribute('transform', transform);
362
245
  }
363
246
  });
364
247
  }
365
- }, [props.data]);
248
+ }, [props.data, props.layout, props.orientation, props.linkType]);
366
249
 
367
250
  return (
368
251
  <div
369
252
  className='tree-graph'
370
- ref={ref}
371
253
  style={{
372
254
  display: 'flex',
373
255
  flexGrow: '1'
@@ -391,8 +273,9 @@ const TreeGraph = (props: Props) => {
391
273
  >
392
274
  { (tree) => (
393
275
  <Group
394
- top={root.origin.y}
276
+ innerRef={ref}
395
277
  left={root.origin.x}
278
+ top={root.origin.y}
396
279
  >
397
280
  { tree.links().map((link, i) => (
398
281
  <LinkComponent
@@ -415,7 +298,6 @@ const TreeGraph = (props: Props) => {
415
298
  };
416
299
 
417
300
  TreeGraph.defaultProps = {
418
- fontSize: 12,
419
301
  layout: Layout.cartesian,
420
302
  linkColor: '#B2B09B',
421
303
  linkType: LinkType.line,
@@ -426,20 +308,10 @@ TreeGraph.defaultProps = {
426
308
  right: 30,
427
309
  bottom: 70
428
310
  },
429
- nodeWidth: 75,
430
311
  offset: 0,
431
312
  orientation: Orientation.horizontal,
432
- stepPercent: 0.5,
433
- textColor: '#FFFFFF'
434
- };
435
-
436
- type TreeGraphType = ComponentType<any> & {
437
- Circle: typeof Circle,
438
- Rectangle: typeof Rectangle
313
+ stepPercent: 0.5
439
314
  };
440
315
 
441
- const TreeGraphComponent: TreeGraphType = withParentSize(withZoom(TreeGraph));
442
- TreeGraphComponent.Circle = Circle;
443
- TreeGraphComponent.Rectangle = Rectangle;
444
-
316
+ const TreeGraphComponent: ComponentType<any> = withParentSize(withZoom(TreeGraph));
445
317
  export default TreeGraphComponent;
@@ -32,7 +32,6 @@ import './TreeGraph.css';
32
32
 
33
33
  type Props = ZoomProps & {
34
34
  data: any,
35
- fontSize: number,
36
35
  layout: string,
37
36
  linkType: string,
38
37
  offset: number,
@@ -47,12 +46,8 @@ type Props = ZoomProps & {
47
46
  bottom: number,
48
47
  left: number
49
48
  },
50
- nodeWidth: number,
51
- onClick?: (data: any) => void,
52
49
  renderNode?: (data: any) => Element<any>,
53
- renderText?: (data: any) => Element<any>,
54
50
  stepPercent: number,
55
- textColor: string
56
51
  };
57
52
 
58
53
  const Layout = {
@@ -71,19 +66,6 @@ const Orientation = {
71
66
  vertical: 'vertical'
72
67
  };
73
68
 
74
- const Circle: ComponentType<any> = (props: any) => (
75
- <circle
76
- r={props.radius}
77
- {...props}
78
- />
79
- );
80
-
81
- const Rectangle: ComponentType<any> = (props: any) => (
82
- <rect
83
- {...props}
84
- />
85
- );
86
-
87
69
  const TreeGraph = (props: Props) => {
88
70
  const ref = useRef();
89
71
 
@@ -210,59 +192,11 @@ const TreeGraph = (props: Props) => {
210
192
  };
211
193
  }, [getMaxDepth, innerHeight, innerWidth, props.data, props.layout, props.orientation]);
212
194
 
213
- /**
214
- * Renders the passed node. If provided, only the "renderNode" prop is called.
215
- *
216
- * @type {(function(*): (*))|*}
217
- */
218
- const renderNode = useCallback((node) => {
219
- if (props.renderNode) {
220
- return props.renderNode(node.data);
221
- }
222
-
223
- if (node.depth === 0) {
224
- return (
225
- <Circle
226
- fill='#FF4A4A'
227
- onClick={props.onClick && props.onClick.bind(this, node.data)}
228
- />
229
- );
230
- }
231
-
232
- return (
233
- <Rectangle
234
- fill='#272b4d'
235
- stroke={node.data.children ? '#03c0dc' : '#26deb0'}
236
- strokeWidth={1}
237
- strokeDasharray={node.data.children ? '0' : '2,2'}
238
- strokeOpacity={node.data.children ? 1 : 0.6}
239
- rx={node.data.children ? 0 : 10}
240
- onClick={props.onClick && props.onClick.bind(this, node.data)}
241
- />
242
- );
243
- }, [props.onClick, props.renderNode]);
244
-
245
- /**
246
- * Renders the text for the passed node.
247
- *
248
- * @type {(function(*): (*))|*}
249
- */
250
- const renderText = useCallback((node) => {
251
- if (props.renderText) {
252
- return props.renderText(node.data);
253
- }
254
-
255
- return (
256
- <text
257
- dy='0.33em'
258
- fontSize={props.fontSize}
259
- textAnchor='middle'
260
- fill={props.textColor}
261
- >
262
- { node.data.name }
263
- </text>
264
- );
265
- }, [props.renderText]);
195
+ const renderNode = useCallback((node) => (
196
+ <foreignObject>
197
+ { props.renderNode(node.data) }
198
+ </foreignObject>
199
+ ), [props.renderNode]);
266
200
 
267
201
  /**
268
202
  * Renders the group element for the passed node.
@@ -274,15 +208,16 @@ const TreeGraph = (props: Props) => {
274
208
 
275
209
  return (
276
210
  <Group
211
+ nodeleft={left}
212
+ nodetop={top}
277
213
  top={top}
278
214
  left={left}
279
215
  key={key}
280
216
  >
281
217
  { renderNode(node) }
282
- { renderText(node) }
283
218
  </Group>
284
219
  );
285
- }, [renderNode, renderText, props.layout, props.orientation]);
220
+ }, [renderNode, props.layout, props.orientation, props.linkType]);
286
221
 
287
222
  /**
288
223
  * Resizes the "circle" and "rect" elements based on the text contained in the group. This effect will also
@@ -291,83 +226,30 @@ const TreeGraph = (props: Props) => {
291
226
  useEffect(() => {
292
227
  const { current } = ref;
293
228
  if (current) {
294
- const padding = 15;
295
229
  const groups = current.getElementsByTagName('g');
296
230
  _.each(groups, (group) => {
297
- const circle = _.first(group.getElementsByTagName('circle'));
298
- const rect = _.first(group.getElementsByTagName('rect'));
299
- const text = _.first(group.getElementsByTagName('text'));
300
-
301
- if (text) {
302
- const { height } = text.getBBox();
303
-
304
- if (!text.getElementsByTagName('tspan').length) {
305
- const words = text.innerHTML.split(/\s+/);
306
-
307
- const lines = [];
308
- let lineIndex = 0;
309
-
310
- for (let i = 0; i < words.length; i += 1) {
311
- // Initialize the line array for the current line
312
- if (!lines[lineIndex]) {
313
- lines[lineIndex] = [];
314
- }
315
-
316
- // Add the current word to the current line
317
- lines[lineIndex].push(words[i]);
231
+ const object = _.first(group.getElementsByTagName('foreignObject'));
232
+ if (object && object.firstChild) {
233
+ const { offsetWidth: width, offsetHeight: height } = object.firstChild;
318
234
 
319
- // Look ahead to the next word and increment the line index if necessary
320
- if (i < words.length - 1) {
321
- const testElement = text.cloneNode();
322
- testElement.innerHTML = [...lines[lineIndex], words[i + 1]].join(' ');
323
- group.append(testElement);
235
+ // Set the width and height of the foreignObject element
236
+ object.setAttribute('width', width);
237
+ object.setAttribute('height', height);
324
238
 
325
- if (testElement.getBBox().width > props.nodeWidth) {
326
- lineIndex += 1;
327
- }
239
+ // Transform the position of the group element based on the width and height of the contents
240
+ const leftPosition = parseFloat(group.getAttribute('nodeleft'));
241
+ const topPosition = parseFloat(group.getAttribute('nodetop'));
328
242
 
329
- testElement.remove();
330
- }
331
- }
332
-
333
- // Append the lines to the text element
334
- _.each(lines, (line, index) => {
335
- const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
336
- tspan.setAttribute('x', '0');
337
- if (index > 0) {
338
- tspan.setAttribute('dy', `${height}px`);
339
- }
340
- tspan.appendChild(document.createTextNode(line.join(' ')));
341
-
342
- if (index === 0) {
343
- text.replaceChildren(tspan);
344
- } else {
345
- text.appendChild(tspan);
346
- }
347
- });
348
-
349
- // Set the shape attributes based on the text size
350
- const bbox = text.getBBox();
351
- if (circle && text) {
352
- circle.setAttribute('x', bbox.x - padding);
353
- circle.setAttribute('y', bbox.y - padding);
354
- circle.setAttribute('r', (bbox.width / 2) + padding);
355
- } else if (rect && text) {
356
- rect.setAttribute('x', bbox.x - padding);
357
- rect.setAttribute('y', bbox.y - padding);
358
- rect.setAttribute('width', bbox.width + 2 * padding);
359
- rect.setAttribute('height', bbox.height + 2 * padding);
360
- }
361
- }
243
+ const transform = `translate(${leftPosition - (width / 2.0)}, ${topPosition - (height / 2.0)})`;
244
+ group.setAttribute('transform', transform);
362
245
  }
363
246
  });
364
247
  }
365
- }, [props.data]);
248
+ }, [props.data, props.layout, props.orientation, props.linkType]);
366
249
 
367
250
  return (
368
251
  <div
369
252
  className='tree-graph'
370
- ref={ref}
371
253
  style={{
372
254
  display: 'flex',
373
255
  flexGrow: '1'
@@ -391,8 +273,9 @@ const TreeGraph = (props: Props) => {
391
273
  >
392
274
  { (tree) => (
393
275
  <Group
394
- top={root.origin.y}
276
+ innerRef={ref}
395
277
  left={root.origin.x}
278
+ top={root.origin.y}
396
279
  >
397
280
  { tree.links().map((link, i) => (
398
281
  <LinkComponent
@@ -415,7 +298,6 @@ const TreeGraph = (props: Props) => {
415
298
  };
416
299
 
417
300
  TreeGraph.defaultProps = {
418
- fontSize: 12,
419
301
  layout: Layout.cartesian,
420
302
  linkColor: '#B2B09B',
421
303
  linkType: LinkType.line,
@@ -426,20 +308,10 @@ TreeGraph.defaultProps = {
426
308
  right: 30,
427
309
  bottom: 70
428
310
  },
429
- nodeWidth: 75,
430
311
  offset: 0,
431
312
  orientation: Orientation.horizontal,
432
- stepPercent: 0.5,
433
- textColor: '#FFFFFF'
434
- };
435
-
436
- type TreeGraphType = ComponentType<any> & {
437
- Circle: typeof Circle,
438
- Rectangle: typeof Rectangle
313
+ stepPercent: 0.5
439
314
  };
440
315
 
441
- const TreeGraphComponent: TreeGraphType = withParentSize(withZoom(TreeGraph));
442
- TreeGraphComponent.Circle = Circle;
443
- TreeGraphComponent.Rectangle = Rectangle;
444
-
316
+ const TreeGraphComponent: ComponentType<any> = withParentSize(withZoom(TreeGraph));
445
317
  export default TreeGraphComponent;