@@ -12,7 +12,8 @@ import useForceUpdate from './useForceUpdate';
1212import LinkControls from './LinkControls' ;
1313import getLinkComponent from './getLinkComponent' ;
1414
15- const defaultMargin = { top : 30 , left : 30 , right : 30 , bottom : 70 } ;
15+ // setting the base margins for the Map to render in the window.
16+ const defaultMargin = { top : 30 , left : 30 , right : 30 , bottom : 30 } ;
1617
1718export type LinkTypesProps = {
1819 width : number ;
@@ -28,23 +29,26 @@ export default function ComponentMap({
2829 margin = defaultMargin ,
2930 snapshots : snapshots ,
3031} : LinkTypesProps ) {
32+ console . log ( totalHeight ) ;
3133 // preparing the data to be used for render
3234 const lastNode = snapshots . length - 1 ;
3335 const data = snapshots [ lastNode ] ;
36+ // importing custom hooks for the selection tabs.
3437 const [ layout , setLayout ] = useState < string > ( 'cartesian' ) ;
3538 const [ orientation , setOrientation ] = useState < string > ( 'horizontal' ) ;
3639 const [ linkType , setLinkType ] = useState < string > ( 'diagonal' ) ;
37- const [ stepPercent , setStepPercent ] = useState < number > ( 0.5 ) ;
40+ const [ stepPercent , setStepPercent ] = useState < number > ( 10 ) ;
3841 const forceUpdate = useForceUpdate ( ) ;
39- // setting the margins for the Map to render in the tab
42+
4043 const innerWidth = totalWidth - margin . left - margin . right ;
4144 const innerHeight = totalHeight - margin . top - margin . bottom ;
4245
4346 let origin : { x : number ; y : number } ;
4447 let sizeWidth : number ;
4548 let sizeHeight : number ;
4649
47- // rendering for the different tab selections
50+ // Conditional statement sets the location of the root node in the middle of the window
51+ // Else statement sets the location of the root node to the right or top of the window per dropdown selection.
4852 if ( layout === 'polar' ) {
4953 origin = {
5054 x : innerWidth / 2 ,
@@ -62,7 +66,12 @@ export default function ComponentMap({
6266 sizeHeight = innerWidth ;
6367 }
6468 }
69+
6570 // render controls for the map
71+
72+ // Tree is rendering each component from the component tree.
73+ // rect- Contains both text and rectangle node information for rendering each component.
74+ // circle- setup and layout for the root node.
6675 const LinkComponent = getLinkComponent ( { layout, linkType, orientation } ) ;
6776 return totalWidth < 10 ? null : (
6877 < div >
@@ -84,7 +93,7 @@ export default function ComponentMap({
8493 < Tree
8594 root = { hierarchy ( data , ( d ) => ( d . isExpanded ? null : d . children ) ) }
8695 size = { [ sizeWidth , sizeHeight ] }
87- separation = { ( a , b ) => ( a . parent === b . parent ? 1 : 0.5 ) / a . depth }
96+ separation = { ( a , b ) => ( a . parent === b . parent ? 1000 : 0 ) / a . depth }
8897 >
8998 { ( tree ) => (
9099 < Group top = { origin . y } left = { origin . x } >
@@ -98,7 +107,7 @@ export default function ComponentMap({
98107 fill = 'none'
99108 />
100109 ) ) }
101-
110+ translate
102111 { tree . descendants ( ) . map ( ( node , key ) => {
103112 const width = 40 ;
104113 const height = 15 ;
0 commit comments