Commit 9fa1f05
feat(viz): treemap & sunburst hierarchy charts (smart panels + standalone subcommands) (#4080)
* feat(viz): treemap & sunburst hierarchy panels + standalone subcommands
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>
* fix(viz): validate --value measure for treemap/sunburst (roborev #3190)
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>
* fix(viz): error on any invalid --value cell for treemap/sunburst (roborev #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>
* docs(viz): add standalone treemap & sunburst figures to the examples 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>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 887976b commit 9fa1f05
15 files changed
Lines changed: 1478 additions & 184 deletions
File tree
- .claude/skills/qsv
- docs/help
- examples/viz
- src/cmd
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
44 | | - | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | | - | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
107 | 114 | | |
108 | 115 | | |
109 | 116 | | |
| |||
238 | 245 | | |
239 | 246 | | |
240 | 247 | | |
241 | | - | |
| 248 | + | |
242 | 249 | | |
243 | 250 | | |
244 | 251 | | |
| |||
355 | 362 | | |
356 | 363 | | |
357 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
358 | 373 | | |
359 | 374 | | |
360 | 375 | | |
0 commit comments