@@ -25,8 +25,8 @@ export function BeautifulTree({
25
25
const { tree : treeWithLayout , maxX, maxY } = computeLayout ( tree )
26
26
const { width, height, sizeUnit = 'px' } = svgProps
27
27
28
- const xDivisor = maxX + 2
29
- const yDivisor = maxY + 2
28
+ const xCoef = width / ( maxX + 2 )
29
+ const yCoef = height / ( maxY + 2 )
30
30
31
31
return (
32
32
< svg
@@ -48,10 +48,10 @@ export function BeautifulTree({
48
48
return (
49
49
< line
50
50
key = { `${ id } -edge-${ idx } ` }
51
- x1 = { ( ( edge . start . x + 1 ) * width ) / xDivisor }
52
- y1 = { ( ( edge . start . y + 1 ) * height ) / yDivisor }
53
- x2 = { ( ( edge . end . x + 1 ) * width ) / xDivisor }
54
- y2 = { ( ( edge . end . y + 1 ) * height ) / yDivisor }
51
+ x1 = { ( edge . start . x + 1 ) * xCoef }
52
+ y1 = { ( edge . start . y + 1 ) * yCoef }
53
+ x2 = { ( edge . end . x + 1 ) * xCoef }
54
+ y2 = { ( edge . end . y + 1 ) * yCoef }
55
55
/>
56
56
)
57
57
} ) }
@@ -61,9 +61,11 @@ export function BeautifulTree({
61
61
return (
62
62
< circle
63
63
key = { `${ id } -node-${ idx } ` }
64
- className = { 'beautiful-tree-node' }
65
- cx = { ( ( aX + 1 ) * width ) / xDivisor }
66
- cy = { ( ( aY + 1 ) * height ) / yDivisor }
64
+ className = { `beautiful-tree-node${
65
+ node . meta . isRoot ? ' beautiful-tree-root' : ''
66
+ } ${ node . meta . isLeaf ? ' beautiful-tree-leaf' : '' } `}
67
+ cx = { ( aX + 1 ) * xCoef }
68
+ cy = { ( aY + 1 ) * yCoef }
67
69
r = "5"
68
70
/>
69
71
)
0 commit comments