@@ -128,6 +128,8 @@ const dataArray = [
128
128
}
129
129
]
130
130
131
+ const startNode : TreeNode = dataArray [ 0 ] ;
132
+
131
133
const defaultMargin = {
132
134
top : 30 ,
133
135
left : 30 ,
@@ -148,18 +150,23 @@ export type LinkTypesProps = {
148
150
margin ?: { top : number ; right : number ; bottom : number ; left : number } ;
149
151
} ;
150
152
151
- export default function AxTree ( props , {
152
- width : totalWidth ,
153
- height : totalHeight ,
154
- margin = defaultMargin ,
155
- } : LinkTypesProps ) {
153
+ export default function AxTree ( props ) {
154
+ const {
155
+ currLocation,
156
+ axSnapshots,
157
+ width,
158
+ height
159
+ } = props ;
160
+
161
+ let margin = defaultMargin ;
162
+ let totalWidth = width ;
163
+ let totalHeight = height ;
164
+
156
165
const [ layout , setLayout ] = useState ( 'cartesian' ) ;
157
166
const [ orientation , setOrientation ] = useState ( 'horizontal' ) ;
158
167
const [ linkType , setLinkType ] = useState ( 'diagonal' ) ;
159
168
const [ stepPercent , setStepPercent ] = useState ( 0.5 ) ;
160
169
161
- console . log ( 'total height access: ' , totalHeight ) ;
162
-
163
170
const innerWidth : number = totalWidth - margin . left - margin . right ;
164
171
const innerHeight : number = totalHeight - margin . top - margin . bottom - 60 ;
165
172
@@ -185,12 +192,9 @@ export default function AxTree(props, {
185
192
}
186
193
}
187
194
188
- const LinkComponent = getLinkComponent ( { layout , linkType , orientation } ) ;
195
+ console . log ( 'size width height ax: ' , sizeWidth , sizeHeight ) ;
189
196
190
- const {
191
- currLocation,
192
- axSnapshots
193
- } = props ;
197
+ const LinkComponent = getLinkComponent ( { layout, linkType, orientation } ) ;
194
198
195
199
const currAxSnapshot = JSON . parse ( JSON . stringify ( axSnapshots [ currLocation . index ] ) ) ;
196
200
@@ -282,12 +286,20 @@ export default function AxTree(props, {
282
286
setLinkType = { setLinkType }
283
287
setStepPercent = { setStepPercent }
284
288
/>
289
+
290
+ { /* svg references purple background */ }
285
291
< svg width = { totalWidth } height = { totalHeight + 0 } >
286
- < LinearGradient id = "links-gradient" from = "#fd9b93" to = "#fe6e9e" />
287
- < rect width = { totalWidth } height = { totalHeight } rx = { 14 } fill = "#272b4d" />
288
- < Group top = { margin . top } left = { margin . left } >
292
+ < LinearGradient id = 'root-gradient' from = '#488689' to = '#3c6e71' />
293
+ < LinearGradient id = 'parent-gradient' from = '#488689' to = '#3c6e71' />
294
+ < rect
295
+ className = 'componentMapContainer'
296
+ width = { sizeWidth / aspect }
297
+ height = { sizeHeight / aspect + 0 }
298
+ rx = { 14 }
299
+ />
300
+ < Group transform = { `scale(${ aspect } )` } top = { margin . top } left = { margin . left } >
289
301
< Tree
290
- root = { hierarchy ( data , ( d ) => ( d . isExpanded ? null : d . children ) ) }
302
+ root = { hierarchy ( startNode , ( d ) => ( d . isExpanded ? null : d . children ) ) }
291
303
size = { [ sizeWidth / aspect , sizeHeight / aspect ] }
292
304
separation = { ( a , b ) => ( a . parent === b . parent ? 0.5 : 0.5 ) / a . depth }
293
305
>
@@ -305,7 +317,6 @@ export default function AxTree(props, {
305
317
306
318
// code relating to each node in tree
307
319
{ tree . descendants ( ) . map ( ( node , key ) => {
308
- console . log ( 'node.data: ' , node . data ) ;
309
320
const widthFunc = ( name ) : number => {
310
321
//returns a number that is related to the length of the name. Used for determining the node width.
311
322
const nodeLength = name . length ;
@@ -322,6 +333,8 @@ export default function AxTree(props, {
322
333
323
334
if ( layout === 'polar' ) {
324
335
const [ radialX , radialY ] = pointRadial ( node . x , node . y ) ;
336
+ console . log ( 'ax tree, radial x y' , radialX , radialY ) ;
337
+ console . log ( 'ax tree node.x, node.y:' , node . x , node . y ) ;
325
338
top = radialY ;
326
339
left = radialX ;
327
340
} else if ( orientation === 'vertical' ) {
0 commit comments