Skip to content

feat(viz): treemap & sunburst hierarchy charts (smart panels + standalone subcommands)#4080

Merged
jqnatividad merged 4 commits into
masterfrom
feat-viz-treemap-sunburst
Jun 26, 2026
Merged

feat(viz): treemap & sunburst hierarchy charts (smart panels + standalone subcommands)#4080
jqnatividad merged 4 commits into
masterfrom
feat-viz-treemap-sunburst

Conversation

@jqnatividad

Copy link
Copy Markdown
Collaborator

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 smart auto-dashboards

A 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:

  • treemap for a shallow (2-level) hierarchy — area encodes size, for accurate comparison
  • sunburst for a deeper (3-level) one — concentric 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. Dimensions are restricted to String type with cardinality ≥ 3, which keeps numeric codes/booleans out and avoids forcing small dashboards onto the inline path.

Standalone viz treemap / viz sunburst

--cols are the hierarchy levels (outer first); optional additive --value/--agg (count by default, or sum). Treemap tiles use the fork's treemap-specific Marker (rounded corners, inner padding, white outline). The --value measure 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

  • One-pass leaf accumulation + a pure flat-array builder (top-N per level with an Other (k) bucket, path-joined ids, rolled-up branchvalues=total).
  • Domain-based panels reuse the existing Scatter3D inline-only pattern (no churn to the typed subplot grid).
  • 8 unit + 9 integration tests.
  • Regenerated docs/help/viz.md, the qsv-viz MCP skill, and the examples gallery (29 figures) — including standalone treemap/sunburst figures and two viz smart --dictionary infer dashboards showcasing both charts.

Dependency note

Cargo.toml pins plotly to 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

jqnatividad and others added 4 commits June 26, 2026 07:54
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>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 26 complexity

Metric Results
Complexity 26

View in Codacy

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.

@jqnatividad jqnatividad merged commit 9fa1f05 into master Jun 26, 2026
29 checks passed
@jqnatividad jqnatividad deleted the feat-viz-treemap-sunburst branch June 26, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant