@@ -12,7 +12,8 @@ import useForceUpdate from './useForceUpdate';
12
12
import LinkControls from './LinkControls' ;
13
13
import getLinkComponent from './getLinkComponent' ;
14
14
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 } ;
16
17
17
18
export type LinkTypesProps = {
18
19
width : number ;
@@ -28,23 +29,26 @@ export default function ComponentMap({
28
29
margin = defaultMargin ,
29
30
snapshots : snapshots ,
30
31
} : LinkTypesProps ) {
32
+ console . log ( totalHeight ) ;
31
33
// preparing the data to be used for render
32
34
const lastNode = snapshots . length - 1 ;
33
35
const data = snapshots [ lastNode ] ;
36
+ // importing custom hooks for the selection tabs.
34
37
const [ layout , setLayout ] = useState < string > ( 'cartesian' ) ;
35
38
const [ orientation , setOrientation ] = useState < string > ( 'horizontal' ) ;
36
39
const [ linkType , setLinkType ] = useState < string > ( 'diagonal' ) ;
37
- const [ stepPercent , setStepPercent ] = useState < number > ( 0.5 ) ;
40
+ const [ stepPercent , setStepPercent ] = useState < number > ( 10 ) ;
38
41
const forceUpdate = useForceUpdate ( ) ;
39
- // setting the margins for the Map to render in the tab
42
+
40
43
const innerWidth = totalWidth - margin . left - margin . right ;
41
44
const innerHeight = totalHeight - margin . top - margin . bottom ;
42
45
43
46
let origin : { x : number ; y : number } ;
44
47
let sizeWidth : number ;
45
48
let sizeHeight : number ;
46
49
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.
48
52
if ( layout === 'polar' ) {
49
53
origin = {
50
54
x : innerWidth / 2 ,
@@ -62,7 +66,12 @@ export default function ComponentMap({
62
66
sizeHeight = innerWidth ;
63
67
}
64
68
}
69
+
65
70
// 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.
66
75
const LinkComponent = getLinkComponent ( { layout, linkType, orientation } ) ;
67
76
return totalWidth < 10 ? null : (
68
77
< div >
@@ -84,7 +93,7 @@ export default function ComponentMap({
84
93
< Tree
85
94
root = { hierarchy ( data , ( d ) => ( d . isExpanded ? null : d . children ) ) }
86
95
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 }
88
97
>
89
98
{ ( tree ) => (
90
99
< Group top = { origin . y } left = { origin . x } >
@@ -98,7 +107,7 @@ export default function ComponentMap({
98
107
fill = 'none'
99
108
/>
100
109
) ) }
101
-
110
+ translate
102
111
{ tree . descendants ( ) . map ( ( node , key ) => {
103
112
const width = 40 ;
104
113
const height = 15 ;
0 commit comments