Skip to content

feat: add Treemap and Sunburst trace types#1

Open
jqnatividad wants to merge 1 commit into
masterfrom
feat/treemap-sunburst-traces
Open

feat: add Treemap and Sunburst trace types#1
jqnatividad wants to merge 1 commit into
masterfrom
feat/treemap-sunburst-traces

Conversation

@jqnatividad

Copy link
Copy Markdown

Summary

Adds two hierarchical trace types — Treemap and Sunburst — to the plotly crate, following the existing Pie trace pattern.

Library

  • Treemap<V> (plotly/src/traces/treemap.rs): labels/parents/values hierarchy with branch_values, count, level, max_depth, domain, shared Marker, full text/hover field set, plus treemap-specific Tiling (with Packing) and PathBar (with Side) helper structs and a shared BranchValues enum.
  • Sunburst<V> (plotly/src/traces/sunburst.rs): same hierarchy/text/hover set plus Leaf (opacity), rotation, and inside_text_orientation.
  • New PlotType::Treemap / PlotType::Sunburst variants and top-level re-exports (plotly::Treemap, plotly::Sunburst, and the treemap/sunburst modules).
  • New Layout options treemapcolorway / extendtreemapcolors (mirroring the existing sunburst pair).

Tests, examples & docs

  • Unit tests + doctests for both traces; layout serialization tests extended to cover the new colorway options.
  • Four runnable examples in examples/basic_charts (basic_treemap, styled_treemap, basic_sunburst, styled_sunburst).
  • Book pages treemap_charts.md and sunburst_charts.md, linked in SUMMARY.md and the basic-charts overview table.

Verification

  • cargo test -p plotly — new unit tests + doctests pass (pre-existing browser static-export tests are unaffected).
  • cargo clippy --features ... -- -D warnings clean (lib + examples).
  • cargo +nightly fmt --all applied to both workspaces.
  • Examples build & run, generating the inline HTML the book embeds.

Notes

  • marker.pad/cornerradius/depthfade (treemap-only) are not yet exposed — documented in the Treemap doc comment; the shared Marker covers colors/colorscale/colorbar/line.
  • No CHANGELOG.md entry is included (the working-tree edit was reverted intentionally); happy to add one referencing this PR's number.

🤖 Generated with Claude Code

Add hierarchical Treemap and Sunburst traces, mirroring the existing Pie
trace pattern:

- Treemap<V>: labels/parents/values hierarchy with BranchValues, plus
  Tiling (Packing) and PathBar (Side) helper structs
- Sunburst<V>: same hierarchy plus Leaf, rotation and
  inside_text_orientation
- New Treemap/Sunburst PlotType variants and top-level re-exports
- treemapcolorway/extendtreemapcolors Layout options
- Unit tests, doctests, basic_charts examples and book pages

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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