fparodimoraes opened a new pull request, #43732: URL: https://github.com/apache/superset/pull/43732
### SUMMARY Fixes #43727. `Partition.ts`'s `init()` layout function computes each node's horizontal position using a single shared "previous node" pointer and a depth-equality heuristic: ```ts n.x = prev.depth === n.parent.depth ? 0 : prev.x + prev.dx; ``` This only produces a correct position when the very first node encountered at each depth (in breadth-first order) happens to be a descendant of the tree's leftmost branch all the way up. That assumption breaks whenever a branch terminates before the deepest configured groupby level while an earlier sibling continues deeper -- which happens naturally whenever a category doesn't have data for every combination of the chosen dimensions (common with real-world sparse categorical data). When it breaks, descendant nodes get positioned outside their true parent's band, rendering as sibling categories visually bleeding into each other, especially when zooming into a segment. This is the same symptom reported in #10586 back in 2020, closed as stale without a fix. This PR replaces the shared "previous node" heuristic with a per-parent running offset (tracked via a `Map`), so every child's `x` is always computed as `parent.x + offset-of-prior-siblings-within-that-parent` -- correct regardless of tree shape or traversal-order quirks. Verified against a real 4-dimension Partition chart with 12,907 nodes: 350 nodes were positioned outside their true parent's bounds by the existing algorithm, 0 after this fix (checked programmatically, not just visually). See #43727 for the full analysis, a minimal hand-verifiable example, and before/after screenshots from a real Superset instance. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF See #43727 for before/after screenshots from a real Superset instance using the exact repro SQL below. ### TESTING INSTRUCTIONS Minimal repro (from #43727) -- register as a virtual dataset, build a Partition Chart with metric `SUM(val)` and Levels = `category`, `subcategory`, `sub_subcategory`: ```sql SELECT 'B' AS category, 'B1' AS subcategory, NULL AS sub_subcategory, 2 AS val UNION ALL SELECT 'A' AS category, 'A1' AS subcategory, 'A1a' AS sub_subcategory, 1 AS val UNION ALL SELECT 'A' AS category, 'A1' AS subcategory, 'A1b' AS sub_subcategory, 1 AS val ``` Before this fix, `A1a`/`A1b` render in the column under `B`, not `A`. After, they render correctly under `A`/`A1`. ### ADDITIONAL INFORMATION - [x] Has associated issue: #43727 - [ ] Required feature flags: - [x] Changes UI - [ ] Includes DB Migration - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
