reflex-silverpoint-react 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- reflex_silverpoint_react-0.1.0/LICENSE +21 -0
- reflex_silverpoint_react-0.1.0/PKG-INFO +224 -0
- reflex_silverpoint_react-0.1.0/README.md +198 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react/__init__.py +170 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react/base.py +180 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react/base.pyi +270 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react/catalog.py +637 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react/charts.py +645 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react/charts.pyi +3944 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react/helpers.py +148 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react.egg-info/PKG-INFO +224 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react.egg-info/SOURCES.txt +16 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react.egg-info/dependency_links.txt +1 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react.egg-info/requires.txt +7 -0
- reflex_silverpoint_react-0.1.0/custom_components/reflex_silverpoint_react.egg-info/top_level.txt +1 -0
- reflex_silverpoint_react-0.1.0/pyproject.toml +45 -0
- reflex_silverpoint_react-0.1.0/setup.cfg +4 -0
- reflex_silverpoint_react-0.1.0/tests/test_components.py +84 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ernesto Crespo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: reflex-silverpoint-react
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The 33 silverpoint charts (Renaissance silverpoint drawing style) for Reflex, wrapping @silverpoint/react
|
|
5
|
+
Author-email: Ernesto Crespo <ecrespo@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ecrespo/reflex-silverpoint-react
|
|
8
|
+
Project-URL: Source, https://github.com/ecrespo/reflex-silverpoint-react
|
|
9
|
+
Project-URL: Issues, https://github.com/ecrespo/reflex-silverpoint-react/issues
|
|
10
|
+
Project-URL: Upstream, https://github.com/ecrespo/silverpoint
|
|
11
|
+
Keywords: reflex,reflex-custom-components,charts,silverpoint,data-visualization,svg
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: reflex>=0.9.12
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: build; extra == "dev"
|
|
22
|
+
Requires-Dist: twine; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest; extra == "dev"
|
|
24
|
+
Requires-Dist: ruff; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# reflex-silverpoint-react
|
|
28
|
+
|
|
29
|
+
A [Reflex](https://reflex.dev) custom component for **[silverpoint](https://github.com/ecrespo/silverpoint)**:
|
|
30
|
+
charts drawn in the manner of a Renaissance silverpoint drawing, with a fine silver line on a
|
|
31
|
+
prepared ground, tone built from hatching, and white heightening on the live value.
|
|
32
|
+
|
|
33
|
+
The hand-drawn irregularity lives only in the ornament. The data geometry is exact, and every chart
|
|
34
|
+
has a `precision` mode that turns the inking off.
|
|
35
|
+
|
|
36
|
+
It wraps [`@silverpoint/react`](https://www.npmjs.com/package/@silverpoint/react) 0.1.1 and exposes
|
|
37
|
+
**all 33 charts**, the `SilverpointProvider`, the interaction events, custom readouts and the
|
|
38
|
+
imperative handle (SVG export and geometry) as Python.
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install reflex-silverpoint-react
|
|
46
|
+
# or
|
|
47
|
+
uv add reflex-silverpoint-react
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Nothing else to do on the JavaScript side: Reflex installs `@silverpoint/react`,
|
|
51
|
+
`@silverpoint/core`, `@silverpoint/grounds` and `@silverpoint/fonts`, and every chart imports the two
|
|
52
|
+
stylesheets it needs (`@silverpoint/grounds/styles.css` and the self-hosted EB Garamond of
|
|
53
|
+
`@silverpoint/fonts/fonts.css`). No Tailwind, no CDN.
|
|
54
|
+
|
|
55
|
+
Requires Reflex 0.9.12 or later (React 19).
|
|
56
|
+
|
|
57
|
+
## Quickstart
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
import reflex as rx
|
|
61
|
+
from reflex_silverpoint_react import line_chart
|
|
62
|
+
|
|
63
|
+
DATA = [
|
|
64
|
+
{"hour": "00", "hits": 18},
|
|
65
|
+
{"hour": "04", "hits": 11},
|
|
66
|
+
{"hour": "08", "hits": 42},
|
|
67
|
+
{"hour": "12", "hits": 64},
|
|
68
|
+
{"hour": "16", "hits": 57},
|
|
69
|
+
{"hour": "20", "hits": 30},
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def index() -> rx.Component:
|
|
74
|
+
return rx.box(
|
|
75
|
+
line_chart(data=DATA, x_key="hour", value_key="hits", title="Hits per hour"),
|
|
76
|
+
width="480px",
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
app = rx.App()
|
|
81
|
+
app.add_page(index)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The chart takes the width of its container; `height` is the height of the drawing area (160 px by
|
|
85
|
+
default). Omit `data` and a chart draws its own demo dataset.
|
|
86
|
+
|
|
87
|
+
Props are the React props in `snake_case`: `xKey` → `x_key`, `hatchFill` → `hatch_fill`,
|
|
88
|
+
`footerRight` → `footer_right`, `centerLabel` → `center_label`, and so on. `data` and every prop can
|
|
89
|
+
be a Reflex state var.
|
|
90
|
+
|
|
91
|
+
## The 33 charts
|
|
92
|
+
|
|
93
|
+
| Family | Charts |
|
|
94
|
+
|---|---|
|
|
95
|
+
| Lines | `line_chart`, `step_chart`, `sparkline_rows`, `kpi_card` |
|
|
96
|
+
| Bars | `bar_chart`, `stacked_bar_chart`, `composed_chart`, `waterfall_chart`, `funnel_chart`, `bullet_chart`, `pyramid_chart`, `candlestick_chart` |
|
|
97
|
+
| Areas | `area_chart`, `range_band_chart`, `stream_chart` |
|
|
98
|
+
| Points & grids | `scatter_chart`, `bubble_chart`, `heatmap_chart`, `treemap_chart`, `activity_grid` |
|
|
99
|
+
| Flows | `sankey_chart`, `chord_ring` |
|
|
100
|
+
| Radial | `donut_chart`, `radar_chart`, `polar_bar_chart`, `radial_arc_group`, `radial_rings`, `gauge_arc`, `meter_chart`, `coxcomb_chart`, `wind_rose`, `volvelle_chart`, `orbit_chart` |
|
|
101
|
+
|
|
102
|
+
Every factory has a class of the same name in `PascalCase` (`LineChart`, `WindRose`…).
|
|
103
|
+
`reflex_silverpoint_react.CHARTS` is the whole catalog with each chart's family and the reference of
|
|
104
|
+
its own props (`COMMON_PROPS` holds the shared ones), handy for galleries and documentation.
|
|
105
|
+
|
|
106
|
+
## Props every chart shares
|
|
107
|
+
|
|
108
|
+
| Prop | Default | |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| `data` | demo dataset | The rows to draw: a list of dicts. |
|
|
111
|
+
| `ground` / `substrate` / `mode` | `"silverpoint"` / `"cream"` / `"ink"` | Style. Substrates: `cream`, `green`, `blue`, `ochre`. `mode="precision"` turns the inking off. |
|
|
112
|
+
| `seed`, `id` | derived, stable | The hand drawing is deterministic: same props, same strokes. |
|
|
113
|
+
| `height`, `width` | `160`, container width | Size of the drawing area in px. |
|
|
114
|
+
| `chrome` | `"card"` | `"bare"` draws only the plot. |
|
|
115
|
+
| `title`, `badge`, `value`, `unit`, `footer_left`, `footer_right` | — | The card's text. |
|
|
116
|
+
| `label`, `description`, `data_table` | from `title`, —, `"hidden"` | Accessibility. |
|
|
117
|
+
| `locale`, `number_format` | environment | Number formatting (`number_format` is a dict of `Intl.NumberFormatOptions`). |
|
|
118
|
+
| `hatch_fill` | `"tile"` | `"per-shape"` gives richer hatching at a much greater weight. |
|
|
119
|
+
| `tooltip` | built-in readout | A custom readout; see `tooltip_template`. |
|
|
120
|
+
| `on_active_change`, `on_select` | — | Events; see below. |
|
|
121
|
+
|
|
122
|
+
## One ground for the whole app
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from reflex_silverpoint_react import bar_chart, donut_chart, silverpoint_provider
|
|
126
|
+
|
|
127
|
+
silverpoint_provider(
|
|
128
|
+
bar_chart(data=sales, x_key="month", value_key="units", title="Units sold", unit="units"),
|
|
129
|
+
donut_chart(data=channels, name_key="channel", value_key="share", title="Sales by channel", center_label="%"),
|
|
130
|
+
ground="silverpoint",
|
|
131
|
+
substrate="green",
|
|
132
|
+
locale="en-GB",
|
|
133
|
+
)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
A prop on a chart always wins over the provider. The provider's props can be state vars, so one
|
|
137
|
+
select can re-ground a whole dashboard.
|
|
138
|
+
|
|
139
|
+
## Interaction
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
class State(rx.State):
|
|
143
|
+
active: str = "—"
|
|
144
|
+
|
|
145
|
+
@rx.event
|
|
146
|
+
def on_active(self, item: dict | None):
|
|
147
|
+
self.active = "—" if item is None else f"{item['datum']['hour']}: {item['value']}"
|
|
148
|
+
|
|
149
|
+
@rx.event
|
|
150
|
+
def on_select(self, item: dict):
|
|
151
|
+
print("selected", item["datum"])
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
line_chart(
|
|
155
|
+
data=DATA,
|
|
156
|
+
x_key="hour",
|
|
157
|
+
value_key="hits",
|
|
158
|
+
on_active_change=State.on_active,
|
|
159
|
+
on_select=State.on_select,
|
|
160
|
+
tooltip=tooltip_template("{datum.hour} h · {value} hits"),
|
|
161
|
+
)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
- `on_active_change` receives the item under the pointer or keyboard focus, and `None` when it
|
|
165
|
+
leaves. `on_select` fires on click, `Enter` or `Space`. The item is
|
|
166
|
+
`{"seriesKey", "index", "datum", "value", "point": {"x", "y"}}`.
|
|
167
|
+
- `tooltip_template(text)` builds the `tooltip` render function from a format string. Placeholders:
|
|
168
|
+
`{heading}`, `{text}` (the built-in readout's two lines), `{announcement}`, `{value}`, `{index}`,
|
|
169
|
+
`{series}` and `{datum.<field>}`. `{{` and `}}` print literal braces.
|
|
170
|
+
|
|
171
|
+
## Export: the imperative handle
|
|
172
|
+
|
|
173
|
+
Give a chart an `id` and its `ChartHandle` is reachable from Python:
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from reflex_silverpoint_react import download_svg, get_geometry, get_svg
|
|
177
|
+
|
|
178
|
+
line_chart(id="hits", data=DATA, x_key="hour", value_key="hits")
|
|
179
|
+
|
|
180
|
+
rx.button("Download SVG", on_click=download_svg("hits", "hits.svg")) # in the browser
|
|
181
|
+
rx.button("SVG to Python", on_click=get_svg("hits", State.receive_svg)) # handler gets a str
|
|
182
|
+
rx.button("Geometry", on_click=get_geometry("hits", State.receive_geometry)) # handler gets a dict
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The exported SVG carries its own ground colours, so it renders the same outside the app.
|
|
186
|
+
|
|
187
|
+
## Notes
|
|
188
|
+
|
|
189
|
+
- `volvelle_chart`: `index_ring` and `index_value` apply to your own rings, so pass `data` when you
|
|
190
|
+
use them (the demo dataset keeps its own index).
|
|
191
|
+
- `gauge_arc` and `meter_chart` take `percent` (0-100) instead of `data`.
|
|
192
|
+
- Charts switch to `precision` by themselves under `prefers-contrast: more` or
|
|
193
|
+
`forced-colors: active`; no prop overrides that.
|
|
194
|
+
- Accessors are field names (strings). The JavaScript API also accepts functions; from Python, shape
|
|
195
|
+
your rows instead.
|
|
196
|
+
|
|
197
|
+
## Demo app
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
uv venv && uv pip install -e .
|
|
201
|
+
cd silverpoint_react_demo
|
|
202
|
+
uv run reflex run
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Pages: **Start** (quickstart, provider, ink vs precision), **Gallery** (the 33 charts, ground
|
|
206
|
+
controls, demo datasets vs data from Python state with a re-roll), **Playground** (one chart, every
|
|
207
|
+
rendering choice and the Python that reproduces it), **Interaction** (events, custom readout, a
|
|
208
|
+
volvelle that turns on click, live KPI/gauge/meter, SVG and geometry export) and one **reference
|
|
209
|
+
page per chart** (`/chart/<slug>`) with its props.
|
|
210
|
+
|
|
211
|
+

|
|
212
|
+
|
|
213
|
+
## Development
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
uv venv && uv pip install -e ".[dev]"
|
|
217
|
+
uv run pytest
|
|
218
|
+
uv run ruff check .
|
|
219
|
+
uv run reflex component build # .pyi stubs + sdist and wheel in dist/
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT. silverpoint is MIT; the EB Garamond typeface is under the SIL Open Font License.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# reflex-silverpoint-react
|
|
2
|
+
|
|
3
|
+
A [Reflex](https://reflex.dev) custom component for **[silverpoint](https://github.com/ecrespo/silverpoint)**:
|
|
4
|
+
charts drawn in the manner of a Renaissance silverpoint drawing, with a fine silver line on a
|
|
5
|
+
prepared ground, tone built from hatching, and white heightening on the live value.
|
|
6
|
+
|
|
7
|
+
The hand-drawn irregularity lives only in the ornament. The data geometry is exact, and every chart
|
|
8
|
+
has a `precision` mode that turns the inking off.
|
|
9
|
+
|
|
10
|
+
It wraps [`@silverpoint/react`](https://www.npmjs.com/package/@silverpoint/react) 0.1.1 and exposes
|
|
11
|
+
**all 33 charts**, the `SilverpointProvider`, the interaction events, custom readouts and the
|
|
12
|
+
imperative handle (SVG export and geometry) as Python.
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install reflex-silverpoint-react
|
|
20
|
+
# or
|
|
21
|
+
uv add reflex-silverpoint-react
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Nothing else to do on the JavaScript side: Reflex installs `@silverpoint/react`,
|
|
25
|
+
`@silverpoint/core`, `@silverpoint/grounds` and `@silverpoint/fonts`, and every chart imports the two
|
|
26
|
+
stylesheets it needs (`@silverpoint/grounds/styles.css` and the self-hosted EB Garamond of
|
|
27
|
+
`@silverpoint/fonts/fonts.css`). No Tailwind, no CDN.
|
|
28
|
+
|
|
29
|
+
Requires Reflex 0.9.12 or later (React 19).
|
|
30
|
+
|
|
31
|
+
## Quickstart
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import reflex as rx
|
|
35
|
+
from reflex_silverpoint_react import line_chart
|
|
36
|
+
|
|
37
|
+
DATA = [
|
|
38
|
+
{"hour": "00", "hits": 18},
|
|
39
|
+
{"hour": "04", "hits": 11},
|
|
40
|
+
{"hour": "08", "hits": 42},
|
|
41
|
+
{"hour": "12", "hits": 64},
|
|
42
|
+
{"hour": "16", "hits": 57},
|
|
43
|
+
{"hour": "20", "hits": 30},
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def index() -> rx.Component:
|
|
48
|
+
return rx.box(
|
|
49
|
+
line_chart(data=DATA, x_key="hour", value_key="hits", title="Hits per hour"),
|
|
50
|
+
width="480px",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
app = rx.App()
|
|
55
|
+
app.add_page(index)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The chart takes the width of its container; `height` is the height of the drawing area (160 px by
|
|
59
|
+
default). Omit `data` and a chart draws its own demo dataset.
|
|
60
|
+
|
|
61
|
+
Props are the React props in `snake_case`: `xKey` → `x_key`, `hatchFill` → `hatch_fill`,
|
|
62
|
+
`footerRight` → `footer_right`, `centerLabel` → `center_label`, and so on. `data` and every prop can
|
|
63
|
+
be a Reflex state var.
|
|
64
|
+
|
|
65
|
+
## The 33 charts
|
|
66
|
+
|
|
67
|
+
| Family | Charts |
|
|
68
|
+
|---|---|
|
|
69
|
+
| Lines | `line_chart`, `step_chart`, `sparkline_rows`, `kpi_card` |
|
|
70
|
+
| Bars | `bar_chart`, `stacked_bar_chart`, `composed_chart`, `waterfall_chart`, `funnel_chart`, `bullet_chart`, `pyramid_chart`, `candlestick_chart` |
|
|
71
|
+
| Areas | `area_chart`, `range_band_chart`, `stream_chart` |
|
|
72
|
+
| Points & grids | `scatter_chart`, `bubble_chart`, `heatmap_chart`, `treemap_chart`, `activity_grid` |
|
|
73
|
+
| Flows | `sankey_chart`, `chord_ring` |
|
|
74
|
+
| Radial | `donut_chart`, `radar_chart`, `polar_bar_chart`, `radial_arc_group`, `radial_rings`, `gauge_arc`, `meter_chart`, `coxcomb_chart`, `wind_rose`, `volvelle_chart`, `orbit_chart` |
|
|
75
|
+
|
|
76
|
+
Every factory has a class of the same name in `PascalCase` (`LineChart`, `WindRose`…).
|
|
77
|
+
`reflex_silverpoint_react.CHARTS` is the whole catalog with each chart's family and the reference of
|
|
78
|
+
its own props (`COMMON_PROPS` holds the shared ones), handy for galleries and documentation.
|
|
79
|
+
|
|
80
|
+
## Props every chart shares
|
|
81
|
+
|
|
82
|
+
| Prop | Default | |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `data` | demo dataset | The rows to draw: a list of dicts. |
|
|
85
|
+
| `ground` / `substrate` / `mode` | `"silverpoint"` / `"cream"` / `"ink"` | Style. Substrates: `cream`, `green`, `blue`, `ochre`. `mode="precision"` turns the inking off. |
|
|
86
|
+
| `seed`, `id` | derived, stable | The hand drawing is deterministic: same props, same strokes. |
|
|
87
|
+
| `height`, `width` | `160`, container width | Size of the drawing area in px. |
|
|
88
|
+
| `chrome` | `"card"` | `"bare"` draws only the plot. |
|
|
89
|
+
| `title`, `badge`, `value`, `unit`, `footer_left`, `footer_right` | — | The card's text. |
|
|
90
|
+
| `label`, `description`, `data_table` | from `title`, —, `"hidden"` | Accessibility. |
|
|
91
|
+
| `locale`, `number_format` | environment | Number formatting (`number_format` is a dict of `Intl.NumberFormatOptions`). |
|
|
92
|
+
| `hatch_fill` | `"tile"` | `"per-shape"` gives richer hatching at a much greater weight. |
|
|
93
|
+
| `tooltip` | built-in readout | A custom readout; see `tooltip_template`. |
|
|
94
|
+
| `on_active_change`, `on_select` | — | Events; see below. |
|
|
95
|
+
|
|
96
|
+
## One ground for the whole app
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from reflex_silverpoint_react import bar_chart, donut_chart, silverpoint_provider
|
|
100
|
+
|
|
101
|
+
silverpoint_provider(
|
|
102
|
+
bar_chart(data=sales, x_key="month", value_key="units", title="Units sold", unit="units"),
|
|
103
|
+
donut_chart(data=channels, name_key="channel", value_key="share", title="Sales by channel", center_label="%"),
|
|
104
|
+
ground="silverpoint",
|
|
105
|
+
substrate="green",
|
|
106
|
+
locale="en-GB",
|
|
107
|
+
)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
A prop on a chart always wins over the provider. The provider's props can be state vars, so one
|
|
111
|
+
select can re-ground a whole dashboard.
|
|
112
|
+
|
|
113
|
+
## Interaction
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
class State(rx.State):
|
|
117
|
+
active: str = "—"
|
|
118
|
+
|
|
119
|
+
@rx.event
|
|
120
|
+
def on_active(self, item: dict | None):
|
|
121
|
+
self.active = "—" if item is None else f"{item['datum']['hour']}: {item['value']}"
|
|
122
|
+
|
|
123
|
+
@rx.event
|
|
124
|
+
def on_select(self, item: dict):
|
|
125
|
+
print("selected", item["datum"])
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
line_chart(
|
|
129
|
+
data=DATA,
|
|
130
|
+
x_key="hour",
|
|
131
|
+
value_key="hits",
|
|
132
|
+
on_active_change=State.on_active,
|
|
133
|
+
on_select=State.on_select,
|
|
134
|
+
tooltip=tooltip_template("{datum.hour} h · {value} hits"),
|
|
135
|
+
)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
- `on_active_change` receives the item under the pointer or keyboard focus, and `None` when it
|
|
139
|
+
leaves. `on_select` fires on click, `Enter` or `Space`. The item is
|
|
140
|
+
`{"seriesKey", "index", "datum", "value", "point": {"x", "y"}}`.
|
|
141
|
+
- `tooltip_template(text)` builds the `tooltip` render function from a format string. Placeholders:
|
|
142
|
+
`{heading}`, `{text}` (the built-in readout's two lines), `{announcement}`, `{value}`, `{index}`,
|
|
143
|
+
`{series}` and `{datum.<field>}`. `{{` and `}}` print literal braces.
|
|
144
|
+
|
|
145
|
+
## Export: the imperative handle
|
|
146
|
+
|
|
147
|
+
Give a chart an `id` and its `ChartHandle` is reachable from Python:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from reflex_silverpoint_react import download_svg, get_geometry, get_svg
|
|
151
|
+
|
|
152
|
+
line_chart(id="hits", data=DATA, x_key="hour", value_key="hits")
|
|
153
|
+
|
|
154
|
+
rx.button("Download SVG", on_click=download_svg("hits", "hits.svg")) # in the browser
|
|
155
|
+
rx.button("SVG to Python", on_click=get_svg("hits", State.receive_svg)) # handler gets a str
|
|
156
|
+
rx.button("Geometry", on_click=get_geometry("hits", State.receive_geometry)) # handler gets a dict
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The exported SVG carries its own ground colours, so it renders the same outside the app.
|
|
160
|
+
|
|
161
|
+
## Notes
|
|
162
|
+
|
|
163
|
+
- `volvelle_chart`: `index_ring` and `index_value` apply to your own rings, so pass `data` when you
|
|
164
|
+
use them (the demo dataset keeps its own index).
|
|
165
|
+
- `gauge_arc` and `meter_chart` take `percent` (0-100) instead of `data`.
|
|
166
|
+
- Charts switch to `precision` by themselves under `prefers-contrast: more` or
|
|
167
|
+
`forced-colors: active`; no prop overrides that.
|
|
168
|
+
- Accessors are field names (strings). The JavaScript API also accepts functions; from Python, shape
|
|
169
|
+
your rows instead.
|
|
170
|
+
|
|
171
|
+
## Demo app
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
uv venv && uv pip install -e .
|
|
175
|
+
cd silverpoint_react_demo
|
|
176
|
+
uv run reflex run
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Pages: **Start** (quickstart, provider, ink vs precision), **Gallery** (the 33 charts, ground
|
|
180
|
+
controls, demo datasets vs data from Python state with a re-roll), **Playground** (one chart, every
|
|
181
|
+
rendering choice and the Python that reproduces it), **Interaction** (events, custom readout, a
|
|
182
|
+
volvelle that turns on click, live KPI/gauge/meter, SVG and geometry export) and one **reference
|
|
183
|
+
page per chart** (`/chart/<slug>`) with its props.
|
|
184
|
+
|
|
185
|
+

|
|
186
|
+
|
|
187
|
+
## Development
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
uv venv && uv pip install -e ".[dev]"
|
|
191
|
+
uv run pytest
|
|
192
|
+
uv run ruff check .
|
|
193
|
+
uv run reflex component build # .pyi stubs + sdist and wheel in dist/
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
MIT. silverpoint is MIT; the EB Garamond typeface is under the SIL Open Font License.
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""reflex-silverpoint-react: silverpoint charts for Reflex.
|
|
2
|
+
|
|
3
|
+
Charts drawn in the manner of a Renaissance silverpoint drawing, wrapping ``@silverpoint/react``.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .base import (
|
|
7
|
+
SILVERPOINT_LIBRARY,
|
|
8
|
+
SILVERPOINT_STYLESHEETS,
|
|
9
|
+
SILVERPOINT_VERSION,
|
|
10
|
+
SilverpointChart,
|
|
11
|
+
SilverpointProvider,
|
|
12
|
+
silverpoint_provider,
|
|
13
|
+
)
|
|
14
|
+
from .catalog import CHARTS, COMMON_PROPS, FAMILIES, ChartInfo, PropDoc, chart_by_name, chart_by_slug
|
|
15
|
+
from .charts import (
|
|
16
|
+
ActivityGrid,
|
|
17
|
+
AreaChart,
|
|
18
|
+
BarChart,
|
|
19
|
+
BubbleChart,
|
|
20
|
+
BulletChart,
|
|
21
|
+
CandlestickChart,
|
|
22
|
+
ChordRing,
|
|
23
|
+
ComposedChart,
|
|
24
|
+
CoxcombChart,
|
|
25
|
+
DonutChart,
|
|
26
|
+
FunnelChart,
|
|
27
|
+
GaugeArc,
|
|
28
|
+
HeatmapChart,
|
|
29
|
+
KpiCard,
|
|
30
|
+
LineChart,
|
|
31
|
+
MeterChart,
|
|
32
|
+
OrbitChart,
|
|
33
|
+
PolarBarChart,
|
|
34
|
+
PyramidChart,
|
|
35
|
+
RadarChart,
|
|
36
|
+
RadialArcGroup,
|
|
37
|
+
RadialRings,
|
|
38
|
+
RangeBandChart,
|
|
39
|
+
SankeyChart,
|
|
40
|
+
ScatterChart,
|
|
41
|
+
SparklineRows,
|
|
42
|
+
StackedBarChart,
|
|
43
|
+
StepChart,
|
|
44
|
+
StreamChart,
|
|
45
|
+
TreemapChart,
|
|
46
|
+
VolvelleChart,
|
|
47
|
+
WaterfallChart,
|
|
48
|
+
WindRose,
|
|
49
|
+
activity_grid,
|
|
50
|
+
area_chart,
|
|
51
|
+
bar_chart,
|
|
52
|
+
bubble_chart,
|
|
53
|
+
bullet_chart,
|
|
54
|
+
candlestick_chart,
|
|
55
|
+
chord_ring,
|
|
56
|
+
composed_chart,
|
|
57
|
+
coxcomb_chart,
|
|
58
|
+
donut_chart,
|
|
59
|
+
funnel_chart,
|
|
60
|
+
gauge_arc,
|
|
61
|
+
heatmap_chart,
|
|
62
|
+
kpi_card,
|
|
63
|
+
line_chart,
|
|
64
|
+
meter_chart,
|
|
65
|
+
orbit_chart,
|
|
66
|
+
polar_bar_chart,
|
|
67
|
+
pyramid_chart,
|
|
68
|
+
radar_chart,
|
|
69
|
+
radial_arc_group,
|
|
70
|
+
radial_rings,
|
|
71
|
+
range_band_chart,
|
|
72
|
+
sankey_chart,
|
|
73
|
+
scatter_chart,
|
|
74
|
+
sparkline_rows,
|
|
75
|
+
stacked_bar_chart,
|
|
76
|
+
step_chart,
|
|
77
|
+
stream_chart,
|
|
78
|
+
treemap_chart,
|
|
79
|
+
volvelle_chart,
|
|
80
|
+
waterfall_chart,
|
|
81
|
+
wind_rose,
|
|
82
|
+
)
|
|
83
|
+
from .helpers import chart_ref, download_svg, get_geometry, get_svg, tooltip_template
|
|
84
|
+
|
|
85
|
+
__all__ = [
|
|
86
|
+
"CHARTS",
|
|
87
|
+
"COMMON_PROPS",
|
|
88
|
+
"FAMILIES",
|
|
89
|
+
"SILVERPOINT_LIBRARY",
|
|
90
|
+
"SILVERPOINT_STYLESHEETS",
|
|
91
|
+
"SILVERPOINT_VERSION",
|
|
92
|
+
"ActivityGrid",
|
|
93
|
+
"AreaChart",
|
|
94
|
+
"BarChart",
|
|
95
|
+
"BubbleChart",
|
|
96
|
+
"BulletChart",
|
|
97
|
+
"CandlestickChart",
|
|
98
|
+
"ChartInfo",
|
|
99
|
+
"ChordRing",
|
|
100
|
+
"ComposedChart",
|
|
101
|
+
"CoxcombChart",
|
|
102
|
+
"DonutChart",
|
|
103
|
+
"FunnelChart",
|
|
104
|
+
"GaugeArc",
|
|
105
|
+
"HeatmapChart",
|
|
106
|
+
"KpiCard",
|
|
107
|
+
"LineChart",
|
|
108
|
+
"MeterChart",
|
|
109
|
+
"OrbitChart",
|
|
110
|
+
"PolarBarChart",
|
|
111
|
+
"PropDoc",
|
|
112
|
+
"PyramidChart",
|
|
113
|
+
"RadarChart",
|
|
114
|
+
"RadialArcGroup",
|
|
115
|
+
"RadialRings",
|
|
116
|
+
"RangeBandChart",
|
|
117
|
+
"SankeyChart",
|
|
118
|
+
"ScatterChart",
|
|
119
|
+
"SilverpointChart",
|
|
120
|
+
"SilverpointProvider",
|
|
121
|
+
"SparklineRows",
|
|
122
|
+
"StackedBarChart",
|
|
123
|
+
"StepChart",
|
|
124
|
+
"StreamChart",
|
|
125
|
+
"TreemapChart",
|
|
126
|
+
"VolvelleChart",
|
|
127
|
+
"WaterfallChart",
|
|
128
|
+
"WindRose",
|
|
129
|
+
"activity_grid",
|
|
130
|
+
"area_chart",
|
|
131
|
+
"bar_chart",
|
|
132
|
+
"bubble_chart",
|
|
133
|
+
"bullet_chart",
|
|
134
|
+
"candlestick_chart",
|
|
135
|
+
"chart_by_name",
|
|
136
|
+
"chart_by_slug",
|
|
137
|
+
"chart_ref",
|
|
138
|
+
"chord_ring",
|
|
139
|
+
"composed_chart",
|
|
140
|
+
"coxcomb_chart",
|
|
141
|
+
"donut_chart",
|
|
142
|
+
"download_svg",
|
|
143
|
+
"funnel_chart",
|
|
144
|
+
"gauge_arc",
|
|
145
|
+
"get_geometry",
|
|
146
|
+
"get_svg",
|
|
147
|
+
"heatmap_chart",
|
|
148
|
+
"kpi_card",
|
|
149
|
+
"line_chart",
|
|
150
|
+
"meter_chart",
|
|
151
|
+
"orbit_chart",
|
|
152
|
+
"polar_bar_chart",
|
|
153
|
+
"pyramid_chart",
|
|
154
|
+
"radar_chart",
|
|
155
|
+
"radial_arc_group",
|
|
156
|
+
"radial_rings",
|
|
157
|
+
"range_band_chart",
|
|
158
|
+
"sankey_chart",
|
|
159
|
+
"scatter_chart",
|
|
160
|
+
"silverpoint_provider",
|
|
161
|
+
"sparkline_rows",
|
|
162
|
+
"stacked_bar_chart",
|
|
163
|
+
"step_chart",
|
|
164
|
+
"stream_chart",
|
|
165
|
+
"tooltip_template",
|
|
166
|
+
"treemap_chart",
|
|
167
|
+
"volvelle_chart",
|
|
168
|
+
"waterfall_chart",
|
|
169
|
+
"wind_rose",
|
|
170
|
+
]
|