Skip to content

Commit 33b2613

Browse files
author
Amelia Wattenbeger
committed
tweak padding
1 parent a736f99 commit 33b2613

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14556,7 +14556,7 @@ var getAngleFromPosition = (x2, y2) => {
1455614556
var keepCircleInsideCircle = (parentR, parentPosition, childR, childPosition) => {
1455714557
const distance = Math.sqrt(Math.pow(parentPosition[0] - childPosition[0], 2) + Math.pow(parentPosition[1] - childPosition[1], 2));
1455814558
const angle = getAngleFromPosition(childPosition[0] - parentPosition[0], childPosition[1] - parentPosition[1]);
14559-
const padding = angle < -40 && angle > -150 ? 13 : 2;
14559+
const padding = angle < -40 && angle > -150 ? 13 : 3;
1456014560
if (distance > parentR - childR - padding) {
1456114561
const diff = getPositionFromAngleAndDistance(angle, parentR - childR - padding);
1456214562
return [
@@ -14630,8 +14630,8 @@ var Tree = ({ data, filesChanged = [] }) => {
1463014630
return !((_a = d2.children) == null ? void 0 : _a.length);
1463114631
}).length > 1;
1463214632
if (hasChildWithNoChildren)
14633-
return 4;
14634-
return 9;
14633+
return 5;
14634+
return 11;
1463514635
})(hierarchicalData);
1463614636
packedTree.children = reflowSiblings(packedTree.children, cachedPositions.current);
1463714637
const children2 = packedTree.descendants();
@@ -14965,7 +14965,7 @@ var reflowSiblings = (siblings, cachedPositions = {}, parentRadius, parentPositi
1496514965
originalY: d.y
1496614966
};
1496714967
})];
14968-
const paddingScale = linear2().domain([10, 1]).range([3, 10]).clamp(true);
14968+
const paddingScale = linear2().domain([4, 1]).range([2, 10]).clamp(true);
1496914969
let simulation = simulation_default(items).force("centerX", x_default2(width / 2).strength(items[0].depth <= 2 ? 0.01 : 0)).force("centerY", y_default2(height / 2).strength(items[0].depth <= 2 ? 0.05 : 0)).force("centerX2", x_default2(parentPosition == null ? void 0 : parentPosition[0]).strength(parentPosition ? 0.5 : 0)).force("centerY2", y_default2(parentPosition == null ? void 0 : parentPosition[1]).strength(parentPosition ? 0.5 : 0)).force("x", x_default2((d) => {
1497014970
var _a;
1497114971
return ((_a = cachedPositions[d.data.path]) == null ? void 0 : _a[0]) || width / 2;
@@ -14978,8 +14978,8 @@ var reflowSiblings = (siblings, cachedPositions = {}, parentRadius, parentPositi
1497814978
}).strength((d) => {
1497914979
var _a;
1498014980
return ((_a = cachedPositions[d.data.path]) == null ? void 0 : _a[0]) ? 0.5 : 0.1;
14981-
})).force("collide", collide_default((d) => d.children ? d.r + paddingScale(d.depth) : d.r + 3).iterations(9).strength(1)).stop();
14982-
for (let i = 0; i < 190; i++) {
14981+
})).force("collide", collide_default((d) => d.children ? d.r + paddingScale(d.depth) : d.r + 2).iterations(9).strength(1)).stop();
14982+
for (let i = 0; i < 290; i++) {
1498314983
simulation.tick();
1498414984
items.forEach((d) => {
1498514985
d.x = keepBetween(d.r, d.x, width - d.r);

src/Tree.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ export const Tree = ({ data, filesChanged = [] }: Props) => {
123123
const hasChildWithNoChildren = d.children.filter((d) =>
124124
!d.children?.length
125125
).length > 1;
126-
if (hasChildWithNoChildren) return 4;
127-
return 9;
126+
if (hasChildWithNoChildren) return 5;
127+
return 11;
128128
// const hasChildren = !!d.children?.find((d) => d?.children?.length);
129129
// return hasChildren ? 60 : 8;
130130
// return [60, 20, 12][d.depth] || 5;
@@ -583,7 +583,7 @@ const reflowSiblings = (
583583
originalY: d.y,
584584
};
585585
})];
586-
const paddingScale = scaleLinear().domain([10, 1]).range([3, 10]).clamp(true);
586+
const paddingScale = scaleLinear().domain([4, 1]).range([2, 10]).clamp(true);
587587
let simulation = forceSimulation(items)
588588
.force(
589589
"centerX",
@@ -615,12 +615,12 @@ const reflowSiblings = (
615615
)
616616
.force(
617617
"collide",
618-
forceCollide((d) => d.children ? d.r + paddingScale(d.depth) : d.r + 3)
618+
forceCollide((d) => d.children ? d.r + paddingScale(d.depth) : d.r + 2)
619619
.iterations(9).strength(1),
620620
)
621621
.stop();
622622

623-
for (let i = 0; i < 190; i++) {
623+
for (let i = 0; i < 290; i++) {
624624
simulation.tick();
625625
items.forEach((d) => {
626626
d.x = keepBetween(d.r, d.x, width - d.r);

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const keepCircleInsideCircle = (
4141
childPosition[1] - parentPosition[1],
4242
);
4343
// leave space for labels
44-
const padding = angle < -40 && angle > -150 ? 13 : 2;
44+
const padding = angle < -40 && angle > -150 ? 13 : 3;
4545
if (distance > (parentR - childR - padding)) {
4646
const diff = getPositionFromAngleAndDistance(
4747
angle,

0 commit comments

Comments
 (0)