Does d3.hierarchy require explicit sum and sort to match d3.layout.hierarchy behavior?
0 reputation · 26 Jan 2024, 18:29 UTC
I am migrating a tree visualization from d3.layout.hierarchy in d3.js v3 to d3.hierarchy in d3.js v5. The layout must preserve the same node aggregation and sibling ordering as the previous implementation.
Available notes indicate that d3.hierarchy does not apply a default sum accessor and that its sort method replaces the legacy sort property with a comparator. It is unclear whether omitting these calls silently changes aggregation or leaves children unsorted, and whether running mixed d3 versions in one bundle could cause namespace collisions.
Does d3.hierarchy default sum to null and leave children unsorted unless sum and sort are explicitly configured? Which comparator signature should replace the legacy sort property to preserve v3 ordering? Is checking d3.version at runtime sufficient to detect mixed-version conflicts?