Skip to content

Wrap Recharts Sankey chart#6708

Open
harsh21234i wants to merge 4 commits into
reflex-dev:mainfrom
harsh21234i:fix/wrap-recharts-sankey-6558
Open

Wrap Recharts Sankey chart#6708
harsh21234i wants to merge 4 commits into
reflex-dev:mainfrom
harsh21234i:fix/wrap-recharts-sankey-6558

Conversation

@harsh21234i

Copy link
Copy Markdown
Contributor

Closes #6558

Summary

  • Add rx.recharts.SankeyChart / rx.recharts.sankey_chart
  • Export Sankey through the Recharts package API
  • Add docs with simple, stateful, and custom typed/styled node examples
  • Add unit coverage for responsive-container wrapping and render alias

Tests

  • uv run pytest tests/units/components/graphing/test_recharts.py -q
  • uv run ruff check ...
  • uv run ruff format --check ...
  • uv run pyright ...

@harsh21234i harsh21234i requested review from a team and Alek99 as code owners July 6, 2026 16:13
@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR wraps the Recharts Sankey component as rx.recharts.SankeyChart / rx.recharts.sankey_chart, following the same ChartBase + ResponsiveContainer pattern used by every other chart in the package.

  • SankeyNode, SankeyLink, and SankeyData TypedDicts use NotRequired for optional fields while keeping required fields (name, source, target, value) mandatory — correctly addressing concerns from earlier review threads.
  • All Recharts Sankey props are declared; the component is exported from __init__.py and registered in ResponsiveContainer._valid_children.
  • Two unit tests cover the wrapping structure and unannotated state var acceptance; docs include simple, stateful, and custom-styled examples.

Confidence Score: 5/5

Safe to merge — the implementation follows the established chart-wrapping pattern exactly and all TypedDict contracts are correctly modeled.

The change is a straightforward addition of a new chart type. No existing behaviour is modified, TypedDict optionality is correctly modelled with NotRequired, and all wiring is consistent with every other chart in the package.

The _valid_children list in the new SankeyChart class is the only spot worth a second look.

Important Files Changed

Filename Overview
packages/reflex-components-recharts/src/reflex_components_recharts/charts.py Adds SankeyNode, SankeyLink, SankeyData TypedDicts and SankeyChart component; TypedDict field optionality is correctly modeled with NotRequired; one minor concern around Legend in _valid_children
packages/reflex-components-recharts/src/reflex_components_recharts/general.py Adds SankeyChart to ResponsiveContainer._valid_children — one-line change, correct and consistent with other chart types
packages/reflex-components-recharts/src/reflex_components_recharts/init.py Exports sankey_chart and SankeyChart in the correct alphabetical position within the charts submodule
tests/units/components/graphing/test_recharts.py Adds two test cases — ResponsiveContainer wrapping and alias name, plus unannotated State var acceptance; coverage is adequate
docs/library/graphing/charts/sankeychart.md New docs page with simple, stateful, and styled examples; all three examples are well-structured and demonstrate realistic usage

Reviews (4): Last reviewed commit: "Add Sankey chart changelog fragment" | Re-trigger Greptile

Comment thread packages/reflex-components-recharts/src/reflex_components_recharts/charts.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e94c1102db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/reflex-components-recharts/src/reflex_components_recharts/charts.py Outdated
@codspeed-hq

codspeed-hq Bot commented Jul 9, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing harsh21234i:fix/wrap-recharts-sankey-6558 (cc9bd95) with main (948c619)2

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (3b97060) during the generation of this report, so 948c619 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@masenf masenf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a changelog entry.

doesn't build

TypeError: Invalid var passed for prop SankeyChart.data, expected type <class 
'reflex_components_recharts.charts.SankeyData'>, got value 
reflex___state____state___docgen_exec___docs_library_graphing_charts_sankeychart_md____sankey_state
.data_rx_state_ of type collections.abc.Mapping[str, 
collections.abc.Sequence[collections.abc.Mapping[str, int]] | 
collections.abc.Sequence[collections.abc.Mapping[str, str]]].
While rendering demo block in docs/library/graphing/charts/sankeychart.md:
class SankeyState(rx.State):
    data = {
        "nodes": [
            {"name": "Marketing"},
            {"name": "Trial"},
            {"name": "Sales"},
            {"name": "Support"},
         
Happened while evaluating page 'library/graphing/charts/sankeychart'

@harsh21234i

Copy link
Copy Markdown
Contributor Author

Removed link_width because Recharts does not expose a top-level Sankey prop for link width. Link width is
computed from link values and exposed only to custom link renderers.
Widened SankeyChart.data to accept mapping-shaped state vars as well as the explicit SankeyData TypedDict, so
the stateful docs example with unannotated state data works at component construction.
Added regression coverage for both the removed dead prop and unannotated state data.

The earlier SankeyNode.name and SankeyLink optional styling comments were already addressed in the current branch.

@harsh21234i harsh21234i requested a review from masenf July 10, 2026 03:17
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.

Wrap recharts SankeyChart

2 participants