Skip to content

Wrap Recharts Sankey chart#6708

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

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

Conversation

@harsh21234i

Copy link
Copy Markdown

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 ChartBaseResponsiveContainer pattern used by other chart types. It also adds SankeyNode, SankeyLink, and SankeyData TypedDicts for typed data, exports the new component through the package __init__, registers SankeyChart as a valid ResponsiveContainer child, and includes documentation examples and a unit test.

  • SankeyChart exposes one prop — link_width — that does not exist in the Recharts Sankey API; link widths are computed internally by the layout algorithm and cannot be overridden via a top-level prop, so any value passed will be silently ignored.
  • SankeyNode correctly keeps name required while making styling fields optional via NotRequired, and SankeyLink correctly exposes optional per-link styling fields, both addressing concerns raised in prior review threads.

Confidence Score: 4/5

Safe to merge after removing the link_width prop, which will silently do nothing at runtime.

The link_width prop is forwarded to Recharts as linkWidth, but the Recharts Sankey component does not recognise this prop — link widths are derived from each link's value by the layout algorithm. Any user who sets link_width will see no visual change and receive no error or warning, making it a misleading dead API surface. Everything else — the TypedDicts, the ResponsiveContainer wrapping, the export wiring, the event handlers inherited from ChartBase — looks correct and consistent with the other chart wrappers in this package.

packages/reflex-components-recharts/src/reflex_components_recharts/charts.py — the link_width field on SankeyChart should be removed.

Important Files Changed

Filename Overview
packages/reflex-components-recharts/src/reflex_components_recharts/charts.py Adds SankeyChart, SankeyNode, SankeyLink, and SankeyData types; exposes link_width prop that does not exist in the Recharts Sankey API and will silently have no effect
packages/reflex-components-recharts/src/reflex_components_recharts/init.py Exports sankey_chart and SankeyChart correctly alongside existing chart symbols
packages/reflex-components-recharts/src/reflex_components_recharts/general.py Adds SankeyChart to ResponsiveContainer's valid children list, enabling correct wrapping behavior
tests/units/components/graphing/test_recharts.py Adds test verifying SankeyChart wraps in ResponsiveContainer and renders with the correct alias
docs/library/graphing/charts/sankeychart.md Adds Sankey chart docs with simple, stateful, and custom-styled examples; none of the examples exercise the invalid link_width prop
pyi_hashes.json Updates pyi hashes for the recharts init and charts stubs to reflect new SankeyChart exports

Reviews (2): Last reviewed commit: "Tighten Sankey data typing" | 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 on lines +556 to +558
data: Var[SankeyData] = field(
doc="The source data, including nodes and the weighted links between them."
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Accept State vars for Sankey data

With data typed as the exact SankeyData TypedDict, data=SankeyState.data is rejected before rendering when the State var is inferred or annotated as a normal mapping, which is exactly what the new stateful docs example does with its unannotated dict. Component._post_init checks a Var's _var_type against this prop hint, and a Mapping[...]/dict[...] State var is not a subclass of this TypedDict, so dynamic Sankey charts fail even though direct dict literals work. Use a less restrictive mapping-based prop type, or make the exact annotation part of the public API and docs.

Useful? React with 👍 / 👎.

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

1 participant