Skip to content

Add Layer and Rectangle components to Recharts - #6729

Merged
masenf merged 3 commits into
mainfrom
claude/recharts-layer-rectangle-wrappers-wsq24d
Aug 3, 2026
Merged

Add Layer and Rectangle components to Recharts#6729
masenf merged 3 commits into
mainfrom
claude/recharts-layer-rectangle-wrappers-wsq24d

Conversation

@masenf

@masenf masenf commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Type of change

  • New feature (non-breaking change which adds functionality)

New Feature Submission

This PR adds two new Recharts components to support constructing custom node elements:

  • Layer: A wrapper around the Recharts Layer component that renders an SVG <g> element for grouping other SVG elements.
  • Rectangle: A shape component for rendering rectangles with full support for positioning, sizing, styling, and animation properties.

Changes

  1. packages/reflex-components-recharts/src/reflex_components_recharts/general.py:

    • Added Layer class with tag "Layer" and alias "RechartsLayer"
    • Added Rectangle class with comprehensive properties:
      • Positioning: x, y
      • Sizing: width, height, radius
      • Styling: fill, fill_opacity, stroke, stroke_width
      • Animation: is_animation_active, is_update_animation_active, animation_begin, animation_duration, animation_easing
    • Exported layer and rectangle factory functions
  2. packages/reflex-components-recharts/src/reflex_components_recharts/__init__.py:

    • Added exports for Layer, layer, Rectangle, and rectangle to the public API
  3. tests/units/components/recharts/test_general.py (new file):

    • Added unit tests covering:
      • Basic Layer rendering
      • Layer with children (nesting Rectangle)
      • Basic Rectangle rendering
      • Rectangle with all supported properties
  4. packages/reflex-components-recharts/news/+layer_rectangle.feature.md (new file):

    • Added changelog entry documenting the new components

Testing

  • Added comprehensive unit tests in test_general.py covering component creation, rendering, and property handling
  • Tests verify correct component names, child nesting, and property serialization

Checklist

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?
  • Have you written new tests for your core changes, as applicable?
  • pyi_hashes.json updated for modified .pyi files

https://claude.ai/code/session_01XqtAPUo84EBNq6c8Ext3mC

Wrap the Recharts Layer (SVG <g> grouping) and Rectangle (SVG shape)
components, which are used as building blocks for constructing custom
node elements. Exposed as rx.recharts.layer and rx.recharts.rectangle.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XqtAPUo84EBNq6c8Ext3mC
@masenf
masenf requested a review from a team as a code owner July 9, 2026 22:36
@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Layer and Rectangle wrappers for Recharts. The main changes are:

  • New rx.recharts.layer and rx.recharts.rectangle component APIs.
  • Public exports for the new classes and factory functions.
  • Chart child allowlists updated to accept the new components.
  • Unit tests for rendering, props, style handling, and chart nesting.
  • A feature news entry and updated generated stub hashes.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
packages/reflex-components-recharts/src/reflex_components_recharts/general.py Adds the new SVG-style Recharts base wrapper plus Layer, Rectangle, and their factory aliases.
packages/reflex-components-recharts/src/reflex_components_recharts/charts.py Allows Layer and Rectangle as children for the supported chart wrappers.
packages/reflex-components-recharts/src/reflex_components_recharts/init.py Exposes the new Recharts components through the package lazy export map.
tests/units/components/recharts/test_general.py Adds tests for the new components, nesting, serialized props, and style passthrough.
tests/units/components/recharts/test_charts.py Adds chart-level tests that verify the new components are accepted as children.

Reviews (3): Last reviewed commit: "fix(recharts): allow Layer/Rectangle in ..." | Re-trigger Greptile

@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 claude/recharts-layer-rectangle-wrappers-wsq24d (25b8df4) with main (2981e71)

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.

@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: 7a5ebe831e

ℹ️ 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/general.py Outdated
masenf and others added 2 commits August 3, 2026 12:18
Add Layer and Rectangle to every chart's _valid_children so they can be
used as chart overlays (recharts renders them inside the chart surface).
Route their style prop through the default Component styling instead of
the Recharts wrapperStyle remap, which only container components
understand and silently dropped styles on plain SVG elements.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread tests/units/components/recharts/test_general.py
Comment thread tests/units/components/recharts/test_general.py
Comment thread tests/units/components/recharts/test_general.py
@masenf
masenf merged commit e326260 into main Aug 3, 2026
131 of 132 checks passed
@masenf
masenf deleted the claude/recharts-layer-rectangle-wrappers-wsq24d branch August 3, 2026 20:35
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.

3 participants