-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
d3.packSiblings overlaps, hangs. #109
Comments
Related #74. |
I’m not entirely sure I know what I’m doing here, so I’m sorry if this is completely irrelevant. Anyway, if I run this: const data = [
{name: "a", value: 19492797890},
{name: "b", value: 4196176},
{name: "c", value: 14565064},
{name: "d", value: 1243655681},
{name: "e", value: 9756222871},
{name: "f", value: 85483881441},
{name: "g", value: 206472827707}
];
const packed = d3.packSiblings(data.map(d => ({
name: d.name,
r: Math.sqrt(d.value)
}))); then the resulting If I instrument the --- a/src/pack/siblings.js
+++ b/src/pack/siblings.js
@@ -88,6 +88,7 @@ export function packEnclose(circles) {
} while (j !== k.next);
// Success! Insert the new circle c between a and b.
+ console.log(`Inserting ${c._.name} between ${a._.name} and ${b._.name}`);
c.previous = a, c.next = b, a.next = b.previous = b = c;
// Compute the new closest circle pair to the centroid. then it says:
I am rather suspicious of the “between a and a” here! |
The same thing happens with the data cut down to just these four: {name: "a", value: 19492797890},
{name: "b", value: 4196176},
{name: "d", value: 1243655681},
{name: "e", value: 9756222871} |
(I’ve deleted my previous comment, which was nonsense.) With a bit more instrumentation, the failing run looks like this:
The So the following example illustrates the essential problem, with const a = { x: -2048.456980265878, y: 0, r: 139616.61036567247 },
d = { x: 171813.78765611292, y: 18859.304384921452, r: 35265.50270448445 },
e = { r: 98773.5939965738 };
place(a, d, e);
console.log(intersects(a, e)); // true Nasty. I’m not sure what the answer is, other than making the return dr * dr * (1 - 1e-9) - 1e-6 > dx * dx + dy * dy; |
Reference: https://beta.observablehq.com/@jediwarpraptor/market-capitalization-by-segment
Dividing the data by ten should produce the same result, but apparently avoids the overlap:
Dividing the data by two results in an infinite loop!
Here’s a slightly reduced overlap case:
The text was updated successfully, but these errors were encountered: