@performant-software/visualize 0.6.0-beta.1
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/LICENSE +21 -0
- package/README.md +0 -0
- package/build/index.js +2 -0
- package/build/index.js.map +1 -0
- package/build/main.css +43 -0
- package/index.js +1 -0
- package/package.json +32 -0
- package/src/components/TreeGraph.css +13 -0
- package/src/components/TreeGraph.js +443 -0
- package/src/hooks/Zoom.css +34 -0
- package/src/hooks/Zoom.js +139 -0
- package/src/i18n/en.json +11 -0
- package/src/i18n/i18n.js +24 -0
- package/src/index.js +7 -0
- package/types/components/TreeGraph.js.flow +443 -0
- package/types/hooks/Zoom.js.flow +139 -0
- package/types/i18n/i18n.js.flow +24 -0
- package/types/index.js.flow +7 -0
- package/webpack.config.js +3 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Performant Software Solutions LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
File without changes
|
package/build/index.js
ADDED
|
@@ -0,0 +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 B},withZoom:function(){return k}});var n=require("@visx/group"),r=require("@visx/hierarchy"),o=require("@visx/responsive"),a=require("@visx/shape"),i=require("d3-shape"),l=require("react"),c=e.n(l),u=require("underscore"),s=e.n(u),d=require("@visx/event"),f=require("@visx/zoom"),p=require("i18next"),m=e.n(p),h={en:{translation:JSON.parse('{"Zoom":{"buttons":{"center":"Center","clear":"Clear","reset":"Reset","zoomIn":"+","zoomOut":"-"}}}')}},y=m().createInstance();y.init({debug:!0,fallbackLng:"en",lng:"en",interpolation:{escapeValue:!1},resources:h});var b=y;function g(){return g=Object.assign||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},g.apply(this,arguments)}var v={scaleX:1,scaleY:1,translateX:0,translateY:0,skewX:0,skewY:0},k=function(e){return function(t){var n=t.parentWidth,r=t.parentHeight,o=t.scaleXMin,a=void 0===o?.5:o,i=t.scaleXMax,u=void 0===i?4:i,s=t.scaleYMin,p=void 0===s?.5:s,m=t.scaleYMax,h=void 0===m?4:m,y=t.initialTransform,k=void 0===y?v:y,x=(0,l.useCallback)((function(e){return c().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:function(){e.isDragging&&e.dragEnd()},onDoubleClick:function(t){var n=(0,d.localPoint)(t)||{x:0,y:0};e.scale({scaleX:1.1,scaleY:1.1,point:n})}})}),[n,r]);return c().createElement(f.Zoom,{width:n,height:r,scaleXMin:a,scaleXMax:u,scaleYMin:p,scaleYMax:h,initialTransformMatrix:k},(function(n){return c().createElement("div",{className:"zoom"},c().createElement(e,g({},t,{renderZoomContainer:x.bind(void 0,n),zoom:n})),c().createElement("div",{className:"controls"},c().createElement("button",{type:"button",className:"btn btn-zoom",onClick:function(){return n.scale({scaleX:1.2,scaleY:1.2})}},b.t("Zoom.buttons.zoomIn")),c().createElement("button",{type:"button",className:"btn btn-zoom btn-bottom",onClick:function(){return n.scale({scaleX:.8,scaleY:.8})}},b.t("Zoom.buttons.zoomOut")),c().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.center},b.t("Zoom.buttons.center")),c().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.reset},b.t("Zoom.buttons.reset")),c().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.clear},b.t("Zoom.buttons.clear"))))}))}},x=void 0;function E(e,t){if(e){if("string"==typeof e)return C(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function T(){return T=Object.assign||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},T.apply(this,arguments)}var M="polar",w="curve",S="line",z="step",A="vertical",N=function(e){return c().createElement("circle",T({r:e.radius},e))},L=function(e){return c().createElement("rect",e)},O=function(e){var t=(0,l.useRef)(),o=e.parentWidth-e.margin.left-e.margin.right,u=e.parentHeight-e.margin.top-e.margin.bottom,d=(0,l.useMemo)((function(){return e.layout===M?e.linkType===z?a.LinkRadialStep:e.linkType===w?a.LinkRadialCurve:e.linkType===S?a.LinkRadialLine:a.LinkRadial:e.orientation===A?e.linkType===z?a.LinkVerticalStep:e.linkType===w?a.LinkVerticalCurve:e.linkType===S?a.LinkVerticalLine:a.LinkVertical:e.linkType===z?a.LinkHorizontalStep:e.linkType===w?a.LinkHorizontalCurve:e.linkType===S?a.LinkHorizontalLine:a.LinkHorizontal}),[e.layout,e.linkType,e.orientation]),f=(0,l.useCallback)((function(e,t){var n=t;return e.isExpanded&&(n=s().max(s().map(e.children,(function(e){return f(e,t+1)})))),n}),[]),p=(0,l.useCallback)((function(t,n){var r,o,a,l;if(e.layout===M){var c=(a=(0,i.pointRadial)(t,n),l=2,function(e){if(Array.isArray(e))return e}(a)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(l)throw o}}return a}}(a,l)||E(a,l)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=c[0];r=c[1],o=u}else e.orientation===A?(r=n,o=t):(r=t,o=n);return{top:r,left:o}}),[e.layout,e.orientation]),m=(0,l.useMemo)((function(){var t,n,r,a=f(e.data,1);return e.layout===M?(r={x:o/2,y:u/2},t=2*Math.PI,n=Math.min(o,u)/2*(a/2)):(r={x:0,y:0},e.orientation===A?(t=o,n=u):(t=u,n=o)),{sizeWidth:t,sizeHeight:n,origin:r}}),[f,u,o,e.data,e.layout,e.orientation]),h=(0,l.useCallback)((function(t){return e.renderNode?e.renderNode(t.data):0===t.depth?c().createElement(N,{fill:"#FF4A4A",onClick:e.onClick&&e.onClick.bind(x,t.data)}):c().createElement(L,{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(x,t.data)})}),[e.onClick,e.renderNode]),y=(0,l.useCallback)((function(t){return e.renderText?e.renderText(t.data):c().createElement("text",{dy:"0.33em",fontSize:e.fontSize,textAnchor:"middle",fill:e.textColor},t.data.name)}),[e.renderText]),b=(0,l.useCallback)((function(e,t){var r=p(e.x,e.y),o=r.top,a=r.left;return c().createElement(n.Group,{top:o,left:a,key:t},h(e),y(e))}),[h,y,e.layout,e.orientation]);return(0,l.useEffect)((function(){var n=t.current;if(n){var r=n.getElementsByTagName("g");s().each(r,(function(t){var n,r=s().first(t.getElementsByTagName("circle")),o=s().first(t.getElementsByTagName("rect")),a=s().first(t.getElementsByTagName("text")),i=a.getBBox().height;if(!a.getElementsByTagName("tspan").length){for(var l=a.innerHTML.split(/\s+/),c=[],u=0,d=0;d<l.length;d+=1)if(c[u]||(c[u]=[]),c[u].push(l[d]),d<l.length-1){var f=a.cloneNode();f.innerHTML=[].concat((n=c[u],function(e){if(Array.isArray(e))return C(e)}(n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||E(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),[l[d+1]]).join(" "),t.append(f),f.getBBox().width>e.nodeWidth&&(u+=1),f.remove()}s().each(c,(function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","tspan");n.setAttribute("x","0"),t>0&&n.setAttribute("dy","".concat(i,"px")),n.appendChild(document.createTextNode(e.join(" "))),0===t?a.replaceChildren(n):a.appendChild(n)}));var p=a.getBBox();r&&a?(r.setAttribute("x",p.x-15),r.setAttribute("y",p.y-15),r.setAttribute("r",p.width/2+15)):o&&a&&(o.setAttribute("x",p.x-15),o.setAttribute("y",p.y-15),o.setAttribute("width",p.width+30),o.setAttribute("height",p.height+30))}}))}}),[e.data]),c().createElement("div",{className:"tree-graph",ref:t,style:{display:"flex",flexGrow:"1"}},c().createElement("svg",{width:e.parentWidth,height:e.parentHeight-e.offset,ref:e.zoom.containerRef},e.renderZoomContainer(),c().createElement(n.Group,{top:e.margin.top,left:e.margin.left,transform:e.zoom.toString()},c().createElement(r.Tree,{root:(0,r.hierarchy)(e.data,(function(e){return e.isExpanded?e.children:null})),size:[m.sizeWidth,m.sizeHeight],separation:function(e,t){return(e.parent===t.parent?1:2)/e.depth}},(function(t){return c().createElement(n.Group,{top:m.origin.y,left:m.origin.x},t.links().map((function(t,n){return c().createElement(d,{key:n,data:t,percent:e.stepPercent,stroke:e.linkColor,strokeWidth:e.linkWidth,fill:"none"})})),s().map(t.descendants(),b))})))))};O.defaultProps={fontSize:12,layout:"cartesian",linkColor:"#B2B09B",linkType:S,linkWidth:1,margin:{top:30,left:30,right:30,bottom:70},nodeWidth:75,offset:0,orientation:"horizontal",stepPercent:.5,textColor:"#FFFFFF"};var j=(0,o.withParentSize)(k(O));j.Circle=N,j.Rectangle=L;var B=j;module.exports=t}();
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","mappings":"yBACA,IAAIA,EAAsB,CCA1BA,EAAwB,SAASC,GAChC,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,WAAa,OAAOF,EAAgB,SACpC,WAAa,OAAOA,GAErB,OADAD,EAAoBI,EAAEF,EAAQ,CAAE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ACElD,IAAKzD,EAAMqD,OAAOI,IAClBH,KAAMtD,EAAMqD,OAAOC,KACnB4F,UAAWlJ,EAAMY,KAAKuI,YAEtB,kBAAC,EAAAC,KAAD,CACE7D,MAAM8D,EAAAA,EAAAA,WAAUrJ,EAAM2F,MAAM,SAACjI,GAAD,OAAQA,EAAEsH,WAAatH,EAAEwH,SAAW,QAChEoE,KAAM,CAAC/D,EAAKC,UAAWD,EAAKE,YAC5B8D,WAAY,SAAC5L,EAAG6L,GAAJ,OAAW7L,EAAE8L,SAAWD,EAAEC,OAAS,EAAI,GAAK9L,EAAEmH,SAExD,SAAC4E,GAAD,OACA,kBAAC,EAAA/C,MAAD,CACElD,IAAK8B,EAAKG,OAAO3D,EACjBuB,KAAMiC,EAAKG,OAAO5D,GAEhB4H,EAAKC,QAAQC,KAAI,SAACC,EAAMlC,GAAP,OACjB,kBAAChE,EAAD,CACE7F,IAAK6J,EACLhC,KAAMkE,EACNC,QAAS9J,EAAM+J,YACf/D,OAAQhG,EAAMgK,UACd/D,YAAajG,EAAMiK,UACnBnJ,KAAK,YAGPmE,IAAAA,IAAMyE,EAAKQ,cAAexD,WAU5CzD,EAAUkH,aAAe,CACvB7D,SAAU,GACVzC,OAtWW,YAuWXmG,UAAW,UACXlG,SAAUnB,EACVsH,UAAW,EACX5G,OAAQ,CACNI,IAAK,GACLH,KAAM,GACNC,MAAO,GACPG,OAAQ,IAEVuE,UAAW,GACXe,OAAQ,EACR7E,YAvWY,aAwWZ4F,YAAa,GACbvD,UAAW,WAQb,IAAM4D,GAAoCC,EAAAA,EAAAA,gBAAeC,EAASrH,IAClEmH,EAAmBvH,OAASA,EAC5BuH,EAAmBpH,UAAYA,EAE/B,Q","sources":["webpack://@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\n const text = _.first(group.getElementsByTagName('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 }, [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","width","parentWidth","height","parentHeight","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","pointRadial","radialX","root","sizeWidth","sizeHeight","origin","data","Math","PI","min","renderNode","stroke","strokeWidth","strokeDasharray","strokeOpacity","renderText","dy","fontSize","textAnchor","textColor","name","renderGroup","Group","useEffect","current","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":""}
|
package/build/main.css
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.zoom .btn {
|
|
2
|
+
margin: 0;
|
|
3
|
+
text-align: center;
|
|
4
|
+
border: none;
|
|
5
|
+
background: #2f2f2f;
|
|
6
|
+
color: #d3d3d3;
|
|
7
|
+
padding: 0 4px;
|
|
8
|
+
border-top: 1px solid #0a0a0a;
|
|
9
|
+
}
|
|
10
|
+
.zoom .btn-lg {
|
|
11
|
+
font-size: 1em;
|
|
12
|
+
line-height: 1;
|
|
13
|
+
padding: 7px;
|
|
14
|
+
}
|
|
15
|
+
.zoom .btn-zoom {
|
|
16
|
+
width: 30px;
|
|
17
|
+
font-size: 2em;
|
|
18
|
+
}
|
|
19
|
+
.zoom .btn-bottom {
|
|
20
|
+
font-size: 2em;
|
|
21
|
+
margin-bottom: 1rem;
|
|
22
|
+
}
|
|
23
|
+
.zoom .controls {
|
|
24
|
+
position: absolute;
|
|
25
|
+
top: 15px;
|
|
26
|
+
right: 15px;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
align-items: flex-end;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.tree-graph {
|
|
33
|
+
position: relative;
|
|
34
|
+
height: 100%;
|
|
35
|
+
}
|
|
36
|
+
.tree-graph circle,
|
|
37
|
+
.tree-graph rectangle {
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
}
|
|
40
|
+
.tree-graph text {
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
}
|
|
43
|
+
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./build/index');
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@performant-software/visualize",
|
|
3
|
+
"version": "0.6.0-beta.1",
|
|
4
|
+
"description": "A package of components used for data visualization",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"private": false,
|
|
7
|
+
"main": "./build/index.js",
|
|
8
|
+
"style": "./build/main.css",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "webpack --mode production && flow-copy-source -v src types"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@visx/event": "^2.6.0",
|
|
14
|
+
"@visx/group": "^2.10.0",
|
|
15
|
+
"@visx/hierarchy": "^2.10.0",
|
|
16
|
+
"@visx/responsive": "^2.10.0",
|
|
17
|
+
"@visx/shape": "^2.12.2",
|
|
18
|
+
"@visx/zoom": "^2.10.0",
|
|
19
|
+
"d3-shape": "^3.1.0",
|
|
20
|
+
"i18next": "^21.9.1",
|
|
21
|
+
"underscore": "^1.13.2"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": ">= 16.13.1 < 18.0.0",
|
|
25
|
+
"react-dom": ">= 16.13.1 < 18.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@performant-software/webpack-config": "^1.0.0",
|
|
29
|
+
"react": "^17.0.2",
|
|
30
|
+
"react-dom": "^17.0.2"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import { Group } from '@visx/group';
|
|
4
|
+
import { hierarchy, Tree } from '@visx/hierarchy';
|
|
5
|
+
import { withParentSize } from '@visx/responsive';
|
|
6
|
+
import {
|
|
7
|
+
LinkHorizontal,
|
|
8
|
+
LinkHorizontalCurve,
|
|
9
|
+
LinkHorizontalLine,
|
|
10
|
+
LinkHorizontalStep,
|
|
11
|
+
LinkRadial,
|
|
12
|
+
LinkRadialCurve,
|
|
13
|
+
LinkRadialLine,
|
|
14
|
+
LinkRadialStep,
|
|
15
|
+
LinkVertical,
|
|
16
|
+
LinkVerticalCurve,
|
|
17
|
+
LinkVerticalLine,
|
|
18
|
+
LinkVerticalStep
|
|
19
|
+
} from '@visx/shape';
|
|
20
|
+
import { pointRadial } from 'd3-shape';
|
|
21
|
+
import React, {
|
|
22
|
+
useCallback,
|
|
23
|
+
useEffect,
|
|
24
|
+
useMemo,
|
|
25
|
+
useRef,
|
|
26
|
+
type ComponentType,
|
|
27
|
+
type Element
|
|
28
|
+
} from 'react';
|
|
29
|
+
import _ from 'underscore';
|
|
30
|
+
import withZoom, { type ZoomProps } from '../hooks/Zoom';
|
|
31
|
+
import './TreeGraph.css';
|
|
32
|
+
|
|
33
|
+
type Props = ZoomProps & {
|
|
34
|
+
data: any,
|
|
35
|
+
fontSize: number,
|
|
36
|
+
layout: string,
|
|
37
|
+
linkType: string,
|
|
38
|
+
offset: number,
|
|
39
|
+
orientation: string,
|
|
40
|
+
parentHeight: number,
|
|
41
|
+
parentWidth: number,
|
|
42
|
+
linkColor: string,
|
|
43
|
+
linkWidth: number,
|
|
44
|
+
margin: {
|
|
45
|
+
top: number,
|
|
46
|
+
right: number,
|
|
47
|
+
bottom: number,
|
|
48
|
+
left: number
|
|
49
|
+
},
|
|
50
|
+
nodeWidth: number,
|
|
51
|
+
onClick?: (data: any) => void,
|
|
52
|
+
renderNode?: (data: any) => Element<any>,
|
|
53
|
+
renderText?: (data: any) => Element<any>,
|
|
54
|
+
stepPercent: number,
|
|
55
|
+
textColor: string
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const Layout = {
|
|
59
|
+
cartesian: 'cartesian',
|
|
60
|
+
polar: 'polar'
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const LinkType = {
|
|
64
|
+
curve: 'curve',
|
|
65
|
+
line: 'line',
|
|
66
|
+
step: 'step'
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const Orientation = {
|
|
70
|
+
horizontal: 'horizontal',
|
|
71
|
+
vertical: 'vertical'
|
|
72
|
+
};
|
|
73
|
+
|
|
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
|
+
const TreeGraph = (props: Props) => {
|
|
88
|
+
const ref = useRef();
|
|
89
|
+
|
|
90
|
+
const innerWidth = props.parentWidth - props.margin.left - props.margin.right;
|
|
91
|
+
const innerHeight = props.parentHeight - props.margin.top - props.margin.bottom;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Sets the link component based on the layout, linkType, and orientation props.
|
|
95
|
+
*
|
|
96
|
+
* @type {*}
|
|
97
|
+
*/
|
|
98
|
+
const LinkComponent = useMemo(() => {
|
|
99
|
+
let value;
|
|
100
|
+
|
|
101
|
+
if (props.layout === Layout.polar) {
|
|
102
|
+
if (props.linkType === LinkType.step) {
|
|
103
|
+
value = LinkRadialStep;
|
|
104
|
+
} else if (props.linkType === LinkType.curve) {
|
|
105
|
+
value = LinkRadialCurve;
|
|
106
|
+
} else if (props.linkType === LinkType.line) {
|
|
107
|
+
value = LinkRadialLine;
|
|
108
|
+
} else {
|
|
109
|
+
value = LinkRadial;
|
|
110
|
+
}
|
|
111
|
+
} else if (props.orientation === Orientation.vertical) {
|
|
112
|
+
if (props.linkType === LinkType.step) {
|
|
113
|
+
value = LinkVerticalStep;
|
|
114
|
+
} else if (props.linkType === LinkType.curve) {
|
|
115
|
+
value = LinkVerticalCurve;
|
|
116
|
+
} else if (props.linkType === LinkType.line) {
|
|
117
|
+
value = LinkVerticalLine;
|
|
118
|
+
} else {
|
|
119
|
+
value = LinkVertical;
|
|
120
|
+
}
|
|
121
|
+
} else if (props.linkType === LinkType.step) {
|
|
122
|
+
value = LinkHorizontalStep;
|
|
123
|
+
} else if (props.linkType === LinkType.curve) {
|
|
124
|
+
value = LinkHorizontalCurve;
|
|
125
|
+
} else if (props.linkType === LinkType.line) {
|
|
126
|
+
value = LinkHorizontalLine;
|
|
127
|
+
} else {
|
|
128
|
+
value = LinkHorizontal;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return value;
|
|
132
|
+
}, [props.layout, props.linkType, props.orientation]);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns the depth of the last expanded node.
|
|
136
|
+
*
|
|
137
|
+
* @type {function(*, *): *}
|
|
138
|
+
*/
|
|
139
|
+
const getMaxDepth = useCallback((node, depth) => {
|
|
140
|
+
let max = depth;
|
|
141
|
+
|
|
142
|
+
if (node.isExpanded) {
|
|
143
|
+
max = _.max(_.map(node.children, (child) => getMaxDepth(child, depth + 1)));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return max;
|
|
147
|
+
}, []);
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Returns the node position for the passed coordinates.
|
|
151
|
+
*
|
|
152
|
+
* @type {function(*, *): {top: *, left: *}}
|
|
153
|
+
*/
|
|
154
|
+
const getNodePosition = useCallback((x, y) => {
|
|
155
|
+
let top;
|
|
156
|
+
let left;
|
|
157
|
+
|
|
158
|
+
if (props.layout === Layout.polar) {
|
|
159
|
+
const [radialX, radialY] = pointRadial(x, y);
|
|
160
|
+
top = radialY;
|
|
161
|
+
left = radialX;
|
|
162
|
+
} else if (props.orientation === Orientation.vertical) {
|
|
163
|
+
top = y;
|
|
164
|
+
left = x;
|
|
165
|
+
} else {
|
|
166
|
+
top = x;
|
|
167
|
+
left = y;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
top,
|
|
172
|
+
left
|
|
173
|
+
};
|
|
174
|
+
}, [props.layout, props.orientation]);
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Returns the position and size of the root node.
|
|
178
|
+
*
|
|
179
|
+
* @type {{sizeWidth: *, origin: *, sizeHeight: *}}
|
|
180
|
+
*/
|
|
181
|
+
const root = useMemo(() => {
|
|
182
|
+
let sizeWidth;
|
|
183
|
+
let sizeHeight;
|
|
184
|
+
let origin;
|
|
185
|
+
|
|
186
|
+
const depth = getMaxDepth(props.data, 1);
|
|
187
|
+
|
|
188
|
+
if (props.layout === Layout.polar) {
|
|
189
|
+
origin = {
|
|
190
|
+
x: innerWidth / 2,
|
|
191
|
+
y: innerHeight / 2,
|
|
192
|
+
};
|
|
193
|
+
sizeWidth = 2 * Math.PI;
|
|
194
|
+
sizeHeight = (Math.min(innerWidth, innerHeight) / 2) * (depth / 2);
|
|
195
|
+
} else {
|
|
196
|
+
origin = { x: 0, y: 0 };
|
|
197
|
+
if (props.orientation === Orientation.vertical) {
|
|
198
|
+
sizeWidth = innerWidth;
|
|
199
|
+
sizeHeight = innerHeight;
|
|
200
|
+
} else {
|
|
201
|
+
sizeWidth = innerHeight;
|
|
202
|
+
sizeHeight = innerWidth;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
sizeWidth,
|
|
208
|
+
sizeHeight,
|
|
209
|
+
origin
|
|
210
|
+
};
|
|
211
|
+
}, [getMaxDepth, innerHeight, innerWidth, props.data, props.layout, props.orientation]);
|
|
212
|
+
|
|
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]);
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Renders the group element for the passed node.
|
|
269
|
+
*
|
|
270
|
+
* @type {unknown}
|
|
271
|
+
*/
|
|
272
|
+
const renderGroup = useCallback((node, key) => {
|
|
273
|
+
const { top, left } = getNodePosition(node.x, node.y);
|
|
274
|
+
|
|
275
|
+
return (
|
|
276
|
+
<Group
|
|
277
|
+
top={top}
|
|
278
|
+
left={left}
|
|
279
|
+
key={key}
|
|
280
|
+
>
|
|
281
|
+
{ renderNode(node) }
|
|
282
|
+
{ renderText(node) }
|
|
283
|
+
</Group>
|
|
284
|
+
);
|
|
285
|
+
}, [renderNode, renderText, props.layout, props.orientation]);
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Resizes the "circle" and "rect" elements based on the text contained in the group. This effect will also
|
|
289
|
+
* convert text into multiple lines.
|
|
290
|
+
*/
|
|
291
|
+
useEffect(() => {
|
|
292
|
+
const { current } = ref;
|
|
293
|
+
if (current) {
|
|
294
|
+
const padding = 15;
|
|
295
|
+
const groups = current.getElementsByTagName('g');
|
|
296
|
+
_.each(groups, (group) => {
|
|
297
|
+
const circle = _.first(group.getElementsByTagName('circle'));
|
|
298
|
+
const rect = _.first(group.getElementsByTagName('rect'));
|
|
299
|
+
|
|
300
|
+
const text = _.first(group.getElementsByTagName('text'));
|
|
301
|
+
const { height } = text.getBBox();
|
|
302
|
+
|
|
303
|
+
if (!text.getElementsByTagName('tspan').length) {
|
|
304
|
+
const words = text.innerHTML.split(/\s+/);
|
|
305
|
+
|
|
306
|
+
const lines = [];
|
|
307
|
+
let lineIndex = 0;
|
|
308
|
+
|
|
309
|
+
for (let i = 0; i < words.length; i += 1) {
|
|
310
|
+
// Initialize the line array for the current line
|
|
311
|
+
if (!lines[lineIndex]) {
|
|
312
|
+
lines[lineIndex] = [];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Add the current word to the current line
|
|
316
|
+
lines[lineIndex].push(words[i]);
|
|
317
|
+
|
|
318
|
+
// Look ahead to the next word and increment the line index if necessary
|
|
319
|
+
if (i < words.length - 1) {
|
|
320
|
+
const testElement = text.cloneNode();
|
|
321
|
+
testElement.innerHTML = [...lines[lineIndex], words[i + 1]].join(' ');
|
|
322
|
+
group.append(testElement);
|
|
323
|
+
|
|
324
|
+
if (testElement.getBBox().width > props.nodeWidth) {
|
|
325
|
+
lineIndex += 1;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
testElement.remove();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Append the lines to the text element
|
|
333
|
+
_.each(lines, (line, index) => {
|
|
334
|
+
const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
|
|
335
|
+
tspan.setAttribute('x', '0');
|
|
336
|
+
if (index > 0) {
|
|
337
|
+
tspan.setAttribute('dy', `${height}px`);
|
|
338
|
+
}
|
|
339
|
+
tspan.appendChild(document.createTextNode(line.join(' ')));
|
|
340
|
+
|
|
341
|
+
if (index === 0) {
|
|
342
|
+
text.replaceChildren(tspan);
|
|
343
|
+
} else {
|
|
344
|
+
text.appendChild(tspan);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// Set the shape attributes based on the text size
|
|
349
|
+
const bbox = text.getBBox();
|
|
350
|
+
if (circle && text) {
|
|
351
|
+
circle.setAttribute('x', bbox.x - padding);
|
|
352
|
+
circle.setAttribute('y', bbox.y - padding);
|
|
353
|
+
circle.setAttribute('r', (bbox.width / 2) + padding);
|
|
354
|
+
} else if (rect && text) {
|
|
355
|
+
rect.setAttribute('x', bbox.x - padding);
|
|
356
|
+
rect.setAttribute('y', bbox.y - padding);
|
|
357
|
+
rect.setAttribute('width', bbox.width + 2 * padding);
|
|
358
|
+
rect.setAttribute('height', bbox.height + 2 * padding);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}, [props.data]);
|
|
364
|
+
|
|
365
|
+
return (
|
|
366
|
+
<div
|
|
367
|
+
className='tree-graph'
|
|
368
|
+
ref={ref}
|
|
369
|
+
style={{
|
|
370
|
+
display: 'flex',
|
|
371
|
+
flexGrow: '1'
|
|
372
|
+
}}
|
|
373
|
+
>
|
|
374
|
+
<svg
|
|
375
|
+
width={props.parentWidth}
|
|
376
|
+
height={props.parentHeight - props.offset}
|
|
377
|
+
ref={props.zoom.containerRef}
|
|
378
|
+
>
|
|
379
|
+
{ props.renderZoomContainer() }
|
|
380
|
+
<Group
|
|
381
|
+
top={props.margin.top}
|
|
382
|
+
left={props.margin.left}
|
|
383
|
+
transform={props.zoom.toString()}
|
|
384
|
+
>
|
|
385
|
+
<Tree
|
|
386
|
+
root={hierarchy(props.data, (d) => (d.isExpanded ? d.children : null))}
|
|
387
|
+
size={[root.sizeWidth, root.sizeHeight]}
|
|
388
|
+
separation={(a, b) => (a.parent === b.parent ? 1 : 2) / a.depth}
|
|
389
|
+
>
|
|
390
|
+
{ (tree) => (
|
|
391
|
+
<Group
|
|
392
|
+
top={root.origin.y}
|
|
393
|
+
left={root.origin.x}
|
|
394
|
+
>
|
|
395
|
+
{ tree.links().map((link, i) => (
|
|
396
|
+
<LinkComponent
|
|
397
|
+
key={i}
|
|
398
|
+
data={link}
|
|
399
|
+
percent={props.stepPercent}
|
|
400
|
+
stroke={props.linkColor}
|
|
401
|
+
strokeWidth={props.linkWidth}
|
|
402
|
+
fill='none'
|
|
403
|
+
/>
|
|
404
|
+
))}
|
|
405
|
+
{ _.map(tree.descendants(), renderGroup) }
|
|
406
|
+
</Group>
|
|
407
|
+
)}
|
|
408
|
+
</Tree>
|
|
409
|
+
</Group>
|
|
410
|
+
</svg>
|
|
411
|
+
</div>
|
|
412
|
+
);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
TreeGraph.defaultProps = {
|
|
416
|
+
fontSize: 12,
|
|
417
|
+
layout: Layout.cartesian,
|
|
418
|
+
linkColor: '#B2B09B',
|
|
419
|
+
linkType: LinkType.line,
|
|
420
|
+
linkWidth: 1,
|
|
421
|
+
margin: {
|
|
422
|
+
top: 30,
|
|
423
|
+
left: 30,
|
|
424
|
+
right: 30,
|
|
425
|
+
bottom: 70
|
|
426
|
+
},
|
|
427
|
+
nodeWidth: 75,
|
|
428
|
+
offset: 0,
|
|
429
|
+
orientation: Orientation.horizontal,
|
|
430
|
+
stepPercent: 0.5,
|
|
431
|
+
textColor: '#FFFFFF'
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
type TreeGraphType = ComponentType<any> & {
|
|
435
|
+
Circle: typeof Circle,
|
|
436
|
+
Rectangle: typeof Rectangle
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
const TreeGraphComponent: TreeGraphType = withParentSize(withZoom(TreeGraph));
|
|
440
|
+
TreeGraphComponent.Circle = Circle;
|
|
441
|
+
TreeGraphComponent.Rectangle = Rectangle;
|
|
442
|
+
|
|
443
|
+
export default TreeGraphComponent;
|