Skip to main content

reflex-rosencharts

A port of the rosencharts charting library (43 React/TSX components built with D3.js + Tailwind) to a custom component for Reflex, so the charts can be used from pure Python.

Status: scaffold + SDD plan. The charts are implemented in phases according to specs/plans/implementation-plan.md.

Why?

rosencharts is not an npm package: it's a set of .tsx components to copy and paste, with hardcoded data and Tailwind styling. This project wraps them as local Reflex components (rx.asset + library="$/public..."), parametrizes them to receive data from rx.State, and exposes them as Python functions:

import reflex as rx
import reflex_rosencharts as rxc

class State(rx.State):
    sales: list[dict] = [{"date": "2023-05-01", "value": 6}, {"date": "2023-05-02", "value": 8}]

def index() -> rx.Component:
    return rxc.line_chart(data=State.sales)

Charts (43 across 8 families)

Family # Examples
Area 4 area_chart, area_chart_gradient
Bar 12 bar_chart_horizontal, bar_chart_benchmark
Line 8 line_chart, line_chart_multiple
Pie/Donut 8 pie_chart, donut_chart_center_text
Scatter 4 scatter_chart, scatter_chart_interactive
Treemap 3 treemap_chart, treemap_chart_images
Radar 2 radar_chart, radar_chart_rounded
Other 2 bubble_chart, funnel_chart

Full catalog and props: specs/api/component-api-v1.md.

Axis options (scatter and line charts)

The scatter charts build both axes from the extent of the data, label them with regular ticks that line up with the grid lines, and reserve room for the dots so none is clipped at the edges — the data does not have to arrive sorted:

rxc.scatter_chart(
    data=State.repos,      # [{"revenue": x, "value": y, "company": label}, ...]
    x_scale="log",         # "linear" (default), "log" or "symlog"
    margin_left="46px",    # optional; by default it fits the longest y label
)
Prop Charts Default
margin_left the 4 scatter charts, line_chart, line_chart_curved, line_chart_multiple, line_chart_pulse, line_chart_step, line_chart_stocks_curved computed from the longest y label
x_scale / y_scale the 4 scatter charts "linear"

"log" needs strictly positive values and falls back to "symlog" when any value is <= 0. See CHANGELOG.md for what changed in 0.2.2.

Installation

pip install reflex-rosencharts
# or, with uv:
uv add reflex-rosencharts

Project layout

This repo is a Reflex custom component:

custom_components/
└── reflex_rosencharts/          # the published package (import name: reflex_rosencharts)
    ├── __init__.py              # public API surface
    ├── reflex_rosencharts.py    # shared base wrapper (RosenChart)
    └── components/<family>/     # chart wrappers, ported in phases
reflex_rosencharts_demo/         # demo app (reflex run) showcasing the component
pyproject.toml                   # packaging metadata (where = ["custom_components"])

Development

Managed with uv:

uv sync --extra dev --group test   # install runtime + publishing + test tooling
uv run reflex run                  # start the demo app / gallery

Axis regression check for the scatter and line charts (server-renders them with clustered, unsorted and extreme-valued data and asserts the tick, margin and clipping guarantees). It uses the frontend dependencies Reflex installs on the first reflex run:

node scripts/check_scatter_axes.mjs

Build & publish (custom component)

# 1. Build the sdist + wheel into dist/ (PYTHONPATH=. lets the .pyi step resolve
#    the package under custom_components/).
PYTHONPATH=. uv run reflex component build

# 2. Sanity-check the artifacts.
uv run twine check dist/*

# 3. Publish to PyPI with uv (needs a PyPI API token):
uv publish --token "$PYPI_TOKEN"
# …or to TestPyPI first:
uv publish --publish-url https://test.pypi.org/legacy/ --token "$TEST_PYPI_TOKEN"

See Reflex's command reference and publishing prerequisites.

Specifications (SDD)

The project follows Spec-Driven Design. The specs are the primary artifact:

The original code (reference, read-only) lives in reference/rosencharts/.

License and attribution

MIT. This project is a port of rosencharts by Filsommer (MIT). See LICENSE and NOTICE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reflex_rosencharts-0.2.2.tar.gz (78.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reflex_rosencharts-0.2.2-py3-none-any.whl (211.8 kB view details)

Uploaded Python 3

File details

Details for the file reflex_rosencharts-0.2.2.tar.gz.

File metadata

  • Download URL: reflex_rosencharts-0.2.2.tar.gz
  • Upload date:
  • Size: 78.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for reflex_rosencharts-0.2.2.tar.gz
Algorithm Hash digest
SHA256 57270a52f830739a12bf28c74fdf86c1eec420119235f0896b4771a567ec7484
MD5 ba2e5a314567c16de65dc5747db1e624
BLAKE2b-256 564493a148110d57e89496f2394ba4c344736e5b0554c8d5397fe559deee76ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for reflex_rosencharts-0.2.2.tar.gz:

Publisher: release.yml on ecrespo/reflex-rosencharts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file reflex_rosencharts-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for reflex_rosencharts-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7acb3364709ffdc0a0a2109f820a907579ca86c9f14e8f552bd55f9df2bb6b7f
MD5 f822c37d8e84af82c7219727819789ca
BLAKE2b-256 66ab9f471d13541b46956fe8563ead0f83c21927fcd6daf50b6c7eabbcb00993

See more details on using hashes here.

Provenance

The following attestation bundles were made for reflex_rosencharts-0.2.2-py3-none-any.whl:

Publisher: release.yml on ecrespo/reflex-rosencharts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.4

2 files

0.2.3

2 files

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page