reflex-tanstack-charts
Custom Reflex component wrapping TanStack Charts: a typed, layer-composable and accessible chart grammar (SVG, keyboard focus, ~16 KiB gzip for a compact line chart). Declare charts 100% in Python; no JavaScript.
Built on TanStack Charts 1.1.0 (stable since 1.0); the npm versions are pinned and bumps go through a Delta Spec (see
specs/andchanges/).
Installation
uv add reflex-tanstack-charts # or pip install reflex-tanstack-charts
Minimal example
import reflex as rx
from reflex_tanstack_charts import tanstack_chart, bar_y, axis, scale
data = [{"letter": "E", "frequency": 0.127}, {"letter": "T", "frequency": 0.091}]
def page() -> rx.Component:
return tanstack_chart(
marks=[bar_y(data, x="letter", y="frequency")],
x=axis(scale=scale("band", padding=0.18)),
y=axis(grid=True, label="Frequency", ticks={"format": {"style": "percent"}}),
tooltip=True,
aria_label="Letter frequencies",
)
Supported marks (v1 contract)
| Python helper | TanStack mark | Typical use |
|---|---|---|
line_y / line_x |
lineY / lineX |
trends, time series |
area_y / area_x |
areaY / areaX |
areas and bands (y1+y2 / x1+x2) |
bar_y / bar_x |
barY / barX |
vertical bars / horizontal ranking |
dot |
dot |
scatter, bubbles (r as a number or a field) |
rule_x / rule_y |
ruleX / ruleY |
reference lines and targets |
tick_x / tick_y |
tickX / tickY |
strip plots, ranges |
cell |
cell |
ordinal heatmaps |
text |
text |
annotations |
pie |
pie (polar) |
pie and donut (inner_radius) |
Marks compose in layers over shared scales, just like in TanStack:
tanstack_chart(
marks=[
area_y(weeks, x="week", y1="lo", y2="hi", fill_opacity=0.2),
rule_y([70], stroke_dasharray="7 7"),
line_y(weeks, x="week", y="rate", curve="monotone-x", points=True),
text(releases, x="week", y="rate", text="label", dy=-16),
],
x=axis(scale=scale("utc"), ticks={"format": {"month": "short", "day": "numeric"}}),
y=axis(grid=True, label="Activation (%)"),
aria_label="Weekly activation",
)
Scales
linear, band, point, ordinal (compact ones from @tanstack/charts/scales/*)
and utc, time, log, sqrt (via d3-scale). Python datetime/date values
are serialized to ISO-8601 and the bridge rehydrates them back to Date.
Events into Python
class S(rx.State):
@rx.event
def pick(self, point: dict | None): # {"mark_id", "key", "x_value", "y_value", "datum"}
...
tanstack_chart(..., on_focus_change=S.pick, on_select=S.pick)
Reactive data
Pass an rx.Var as the dataset and the chart re-renders when the state mutates
(with animate=True, using a transition):
tanstack_chart(marks=[bar_y(State.data, x="cat", y="val")], animate=True, ...)
Theming
tanstack_chart(..., theme={"--ts-chart-grid": "#33415555"})
Demo
Gallery with the 14 marks, events, reactivity and graceful degradation:
uv sync
cd tanstack_charts_demo
uv run reflex run
Development
Spec-anchored project (SDD): the specs live in specs/ (constitution, PRD with
EARS criteria, API spec, tech design, data model, plan, tasks and the Analyze
gate). Tests cite the REQs they verify.
uv sync
uv run pytest
uv run ruff check custom_components tests
License
MIT © Ernesto Crespo
Metadata
Release files for reflex-tanstack-charts 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| reflex_tanstack_charts-0.2.0.tar.gz | 46.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| reflex_tanstack_charts-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 65.0 kB
Release files / reflex_tanstack_charts-0.2.0.tar.gz
| Download URL | reflex_tanstack_charts-0.2.0.tar.gz |
|---|---|
| Size | 46.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c6333a181b762c887643b634b9c2ade1147cd9035419204a488acde4c56884e
|
|
BLAKE2b-256 checksum How to use checksums |
9ca04f17ec12a820d66662b6a1f37fadb384e9d52c8ff3aa6ca742407c7fefe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Release files / reflex_tanstack_charts-0.2.0-py3-none-any.whl
| Download URL | reflex_tanstack_charts-0.2.0-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
227ee0645266d8f0e457f441e01b6e143b70562073dd606aaf5ba873ee5faac8
|
|
BLAKE2b-256 checksum How to use checksums |
d874023232a229253e6abd6c03d1d3d3224602bb498af7006104bcbf210bffd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Security for reflex-tanstack-charts 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.