feat(viz): treemap & sunburst hierarchy charts (smart panels + standalone subcommands)#4080
Merged
Conversation
Add categorical part-to-whole hierarchy charts to `viz`, backed by the Treemap/Sunburst trace types from the plotly.rs fork (PR plotly/plotly.rs#406). `viz smart` now adds a hierarchy panel when the dataset has 2+ genuine (String) low-cardinality dimensions, auto-selecting the chart by depth per visualization best practice: a treemap for a shallow (2-level) hierarchy (area encodes size for accurate comparison) and a sunburst for a deeper (3-level) one (rings emphasize parent-child structure). Override with `--hierarchy-style auto|treemap|sunburst`. The chosen dimensions keep their own frequency bars; the panel is domain-based, so (like map/geo/3D) it renders via the inline path. Restricting dims to String type with cardinality >= 3 keeps numeric codes/booleans out and avoids forcing small dashboards inline. Also add standalone `viz treemap` / `viz sunburst` subcommands (--cols for the hierarchy levels, optional additive --value/--agg). Treemap tiles use the fork's treemap-specific Marker (rounded corners, inner padding, white outline). - one-pass leaf accumulation + pure flat-array builder (top-N per level with an "Other (k)" bucket, path-joined ids, rolled-up branchvalues=total) - 5 unit + 6 integration tests - regenerated docs/help/viz.md, the qsv-viz MCP skill, and the examples gallery (incl. two `viz smart --dictionary infer` dashboards showcasing both charts) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
In value mode, `accumulate_hierarchy_counts` silently coerced parse failures to 0.0 and accepted negative / non-finite values, so a typo'd or non-numeric --value column produced a blank or misleading area chart while the command succeeded. Now non-empty value cells must parse to a finite, non-negative number; empty cells stay a benign missing measure (skipped). Unusable cells are skipped and tallied with a warning, and an all-unusable measure column returns a clear error instead of charting zeros. Adds value-sum and all-invalid-value tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…orev #3191) Follow-up to #3190: invalid non-empty --value cells only warned (when at least one valid value existed), so a partially-malformed measure column still produced a "successful" treemap/sunburst with rows silently dropped — quietly misstating every part-to-whole proportion. Make any unusable measure cell (non-numeric, negative, or non-finite) a hard error reporting the bad-cell count; empty cells remain a benign missing measure (skipped). Adds a mixed valid/invalid test alongside the all-invalid case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…gallery The gallery showcased the treemap/sunburst hierarchy only via the `viz smart` dashboards; add the two standalone chart types as individual figures too: - treemap: customer_spend plan -> region, sized by summed monthly_spend (exercises the validated --value path + the treemap-specific marker) - sunburst: sales_sample region -> product_category -> payment_method Regenerated gallery.html (29 figures). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 26 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds categorical part-to-whole hierarchy charts to
viz, backed by the Treemap/Sunburst trace types from a plotly.rs fork (upstream PR plotly/plotly.rs#406).viz smartauto-dashboardsA hierarchy panel is added when the dataset has 2+ genuine (String) low-cardinality dimensions, and the chart is auto-selected by depth per visualization best practice:
Override with
--hierarchy-style auto|treemap|sunburst. The chosen dimensions keep their own frequency bars; the panel is domain-based, so (like map/geo/3D) it renders via the inline path. Dimensions are restricted toStringtype with cardinality ≥ 3, which keeps numeric codes/booleans out and avoids forcing small dashboards onto the inline path.Standalone
viz treemap/viz sunburst--colsare the hierarchy levels (outer first); optional additive--value/--agg(count by default, or sum). Treemap tiles use the fork's treemap-specificMarker(rounded corners, inner padding, white outline). The--valuemeasure is validated: empty cells are a benign missing measure, but any non-numeric / negative / non-finite cell is a hard error (a part-to-whole chart silently dropping rows would misstate every proportion).Implementation
Other (k)bucket, path-joinedids, rolled-upbranchvalues=total).Scatter3Dinline-only pattern (no churn to the typed subplot grid).docs/help/viz.md, theqsv-vizMCP skill, and the examples gallery (29 figures) — including standalone treemap/sunburst figures and twoviz smart --dictionary inferdashboards showcasing both charts.Dependency note
Cargo.tomlpinsplotlyto the PR branch via[patch.crates-io](dathere/plotly). Swap this back to a crates.io version once plotly.rs#406 is merged & released.🤖 Generated with Claude Code