feat: add Treemap and Sunburst trace types#1
Open
jqnatividad wants to merge 8 commits into
Open
Conversation
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>
Replace the shared common::Marker on Treemap with a treemap-specific
Marker exposing the treemap-only attributes: pad (Pad{t,l,r,b}),
corner_radius, and depth_fade (true/false/"reversed"). The shared
color/colorscale/colorbar/line/pattern machinery is retained, and the
scatter-only fields (size, symbol, ...) that don't apply to treemaps are
dropped. Showcased in the styled_treemap example.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replaces the three vendored plotly.min.js copies (plotly, plotly_static, docs/book) with v3.6.0 and bumps the pinned CDN version strings in plot.rs, the jupyter notebook template, plotly_static template, and the book header. Closes plotly#407 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Surfaces the user-facing attributes added across plotly.js 3.1.0 through 3.6.0 (now bundled), following the existing Option<T> + FieldSetter pattern: - Layout: hoversort (HoverSort), hoveranywhere, clickanywhere - Axis: zerolinelayer (ZeroLineLayer), minorloglabels, modebardisable (ModeBarDisable), ticklabelposition (TickLabelPosition), unifiedhovertitle (UnifiedHoverTitle), and ExponentFormat::SIExtended - Legend: maxheight - Configuration: displayNotifier - common::Label (hover labels): showarrow - common::Pattern: path (arbitrary SVG path fill) - Candlestick/Ohlc: hovertemplate - hovertemplatefallback / texttemplatefallback across applicable traces These are additive (new fields/enums/variants). Because FieldSetter and layout_structs generate per-field Restyle/Relayout enum variants, adding any field is a semver-breaking change; this targets the next breaking release (0.15.0), consistent with the Treemap/Sunburst additions already on this branch. Refs plotly#407 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Plotly.js pattern schema marks `path` as arrayOk (pathsrc present), like shape/bgcolor/fgcolor/size/solidity. Modeling it as Option<String> prevented per-point custom SVG path fills. Switch to Option<Dim<String>> so FieldSetter generates both scalar and array setters, and add a serialize_pattern_path test covering both forms. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Plotly's `insidetextorientation` attribute expects the full words `horizontal`/`radial`/`tangential`/`auto`, but the field reused the general `Orientation` enum which serializes to single-letter codes (`h`/`v`/`r`/`t`). `Orientation::Radial` emitted `"r"`, which plotly.js silently coerces to the default `"auto"` — so setting a radial sunburst orientation was a no-op. Add a sunburst-specific `InsideTextOrientation` enum (`#[serde(rename_all = "lowercase")]` -> full words) and switch the field to it. The shared `Orientation` enum is left untouched so bars, boxes, legends and sankey keep their correct `h`/`v` codes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Sunburst inside_text_orientation setter takes the Sunburst-specific InsideTextOrientation enum, not common::Orientation. Update the example import and call so the basic-charts example crate compiles. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Adds two hierarchical trace types —
TreemapandSunburst— to theplotlycrate, following the existingPietrace pattern.Library
Treemap<V>(plotly/src/traces/treemap.rs):labels/parents/valueshierarchy withbranch_values,count,level,max_depth,domain, sharedMarker, full text/hover field set, plus treemap-specificTiling(withPacking) andPathBar(withSide) helper structs and a sharedBranchValuesenum.Sunburst<V>(plotly/src/traces/sunburst.rs): same hierarchy/text/hover set plusLeaf(opacity),rotation, andinside_text_orientation.PlotType::Treemap/PlotType::Sunburstvariants and top-level re-exports (plotly::Treemap,plotly::Sunburst, and thetreemap/sunburstmodules).Layoutoptionstreemapcolorway/extendtreemapcolors(mirroring the existing sunburst pair).Tests, examples & docs
examples/basic_charts(basic_treemap,styled_treemap,basic_sunburst,styled_sunburst).treemap_charts.mdandsunburst_charts.md, linked inSUMMARY.mdand 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 warningsclean (lib + examples).cargo +nightly fmt --allapplied to both workspaces.Notes
marker.pad/cornerradius/depthfade(treemap-only) are not yet exposed — documented in theTreemapdoc comment; the sharedMarkercovers colors/colorscale/colorbar/line.CHANGELOG.mdentry is included (the working-tree edit was reverted intentionally); happy to add one referencing this PR's number.🤖 Generated with Claude Code