Skip to content

Commit 5c0faf1

Browse files
authored
docs: redesign the XY information architecture and chart gallery (#64)
* docs: redesign XY documentation * docs: adapt gallery charts for dark mode * docs: polish gallery toolbar states * docs: add uv-first install tabs * docs: render the first chart live * docs: sync hero toolbar with color mode * docs: render core concepts composition live * docs: group live examples in docdemos * chore: satisfy CI formatting checks
1 parent 8907a57 commit 5c0faf1

80 files changed

Lines changed: 5484 additions & 1100 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/api-reference/changelog.md‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Changelog
3+
description: Review migration notes and notable changes in the XY alpha series.
4+
---
5+
6+
# Changelog
7+
8+
The canonical, complete history lives in the repository's
9+
[CHANGELOG.md](https://github.com/reflex-dev/xy/blob/main/CHANGELOG.md). It
10+
follows Keep a Changelog; semantic-versioning compatibility becomes the firm
11+
contract at 1.0. Before 1.0, a minor release can contain breaking changes.
12+
13+
## Current Unreleased Migration Notes
14+
15+
- The fluent public `Figure` builder has been removed. Build with declarative
16+
chart and component factories; use `Chart` for display, export, streaming,
17+
and readout. `Chart.figure()` remains an advanced internal-engine escape
18+
hatch.
19+
- Mark `style=` now uses paint-specific CSS: `stroke` for line-like marks and
20+
`fill` for filled marks. The legacy factory `color=` argument remains, but
21+
`color` is not an alias inside a style dictionary.
22+
- The former `MarkStyle`/`mark_style()` state-styling surface is removed.
23+
Framework applications should derive ordinary props and styles from
24+
application state.
25+
- PNG export defaults to the browser-free native renderer. Select
26+
`Engine.chromium` for browser CSS/WebGL fidelity.
27+
- Chromium PNG accepts `custom_css=`. Native PNG rejects author CSS; complete
28+
chart-level tokens can still resolve through renderable chart styles.
29+
- Browser executable parameters were replaced by automatic discovery or the
30+
`XY_BROWSER` environment variable.
31+
32+
## Recent Additions
33+
34+
The current alpha line added the compact accessible toolbar and editable lasso
35+
selection, the versioned binary frame transport, declarative statistical and
36+
density families, facets, live `Chart.append()`/`pick()`/`select_range()`,
37+
browser-free native PNG, pure SVG export, CSS-compiled mark styling, and the
38+
experimental `xy.pyplot` compatibility layer.
39+
40+
Read [Chart methods](/docs/xy/api-reference/figure-methods/),
41+
[Mark styles](/docs/xy/styling/mark-styles/), and
42+
[Limitations and alpha status](/docs/xy/api-reference/limitations-and-alpha-status/)
43+
when upgrading code across alpha releases.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: Chart Factories
3+
description: Reference XY chart containers, shared props, and facet construction.
4+
---
5+
6+
# Chart Factories
7+
8+
Chart factories compose marks, axes, annotations, and chrome into a public
9+
`Chart`. The generated inventory below follows the same taxonomy as the
10+
[Chart Gallery](/docs/xy/charts/). Its names, signatures, and defaults come
11+
directly from XY's public Python callables.
12+
13+
Use `chart()` when different mark kinds share a panel. A family container is
14+
usually clearer when the children represent one chart family.
15+
16+
## Generated Factory API
17+
18+
~~~python exec
19+
from xy_docs.api_reference import chart_containers_api, chart_factories_api
20+
~~~
21+
22+
~~~python eval
23+
chart_factories_api()
24+
~~~
25+
26+
Annotation-only compositions use the neutral `chart()` container, so that
27+
factory appears under Annotations. It also appears beside `facet_chart()` in
28+
Facets and Layers because layered marks use the same neutral container.
29+
30+
## Shared Chart Props
31+
32+
~~~python eval
33+
chart_containers_api()
34+
~~~
35+
36+
The “Shared chart props” table is generated from the public `Chart`
37+
constructor. Every ordinary factory accepts those props through `**props`;
38+
`facet_chart` exposes its grid controls directly in its generated factory
39+
table and forwards the remaining props to each panel.
40+
41+
## Facet Constraints
42+
43+
`facet_chart` requires `by=` values or a column name resolved from chart-level
44+
`data=`. Its width and height must be positive integer pixel counts; panel
45+
columns and gap are integers. Marks that use row-aligned raw channels must use
46+
compatible arrays or column names so each panel can be subset safely.
47+
48+
Shared facet axes coordinate panel domains and browser viewport changes.
49+
`FacetChart` supports display, export, and memory reporting, but does not expose
50+
`Chart.append()`, `pick()`, or `select_range()`.
51+
52+
See [Composition model](/docs/xy/core-concepts/) for usage and
53+
[Chart methods](/docs/xy/api-reference/figure-methods/) for the returned
54+
objects.

‎docs/api-reference/components.md‎

Lines changed: 0 additions & 102 deletions
This file was deleted.

‎docs/api-reference/contributing.md‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: Contributing
3+
description: Set up XY development, run the right gates, and prepare a focused change.
4+
---
5+
6+
# Contributing
7+
8+
XY welcomes focused bug fixes, documentation improvements, tests, and chart
9+
surface work. The canonical contributor guide is
10+
[CONTRIBUTING.md](https://github.com/reflex-dev/xy/blob/main/CONTRIBUTING.md);
11+
the engineering version contains the complete release and browser checklists.
12+
13+
## Local Setup
14+
15+
~~~bash
16+
git clone https://github.com/reflex-dev/xy.git
17+
cd xy
18+
uv venv
19+
uv pip install -e ".[dev]"
20+
make check
21+
~~~
22+
23+
Source development needs Python 3.11+, a Rust toolchain for the native core,
24+
and Node 18+ for bundle checks. Confirm the active compute backend explicitly:
25+
26+
~~~bash
27+
python -c "import xy.kernels as k; print(k.BACKEND)"
28+
~~~
29+
30+
The supported value is `native`. An unavailable core should raise a clear
31+
import error rather than silently selecting another backend.
32+
33+
## Choose the Focused Gate
34+
35+
| Change | Check |
36+
| --- | --- |
37+
| Fast local verification | `make check` |
38+
| Production-facing change | `make check-full` |
39+
| Public docs, examples, or claims | `make check-docs` |
40+
| Public exports or annotations | `make check-api` |
41+
| Lazy imports and dependency boundaries | `make check-import` |
42+
| Validation and mutation behavior | `make check-errors` |
43+
| Standalone HTML and text safety | `make check-security` |
44+
| Browser lifecycle and interaction | `make check-browser CHROMIUM=/path/to/chrome` |
45+
46+
Run `make check-claims` before publishing performance prose. Every comparison
47+
must name the chart type, data size and shape, representation mode, backend,
48+
render target, and whether browser time-to-first-render is included.
49+
50+
## Adding a Chart Type
51+
52+
A complete chart-family contribution normally spans:
53+
54+
1. Builder validation and rollback tests.
55+
2. Canonical column ingest or an aggregate kernel.
56+
3. Payload metadata with an explicit direct, decimated, density, sampled, or
57+
adaptive mode.
58+
4. Renderer support or reuse of an existing primitive.
59+
5. Standalone/export coverage, including hostile text values.
60+
6. A declarative factory and generated API documentation.
61+
7. A normal-size visual example, plus a benchmark only when the methodology is
62+
honest and reproducible.
63+
64+
Keep generated assets derived from their source generator, preserve lazy
65+
`import xy` behavior, and include new public symbols in `xy.__all__` with type
66+
surface tests.
67+
68+
Before opening a pull request, read the relevant architecture material in the
69+
repository and open a focused
70+
[GitHub issue](https://github.com/reflex-dev/xy/issues/new) when the desired
71+
behavior changes a public contract.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: Events and Callbacks
3+
description: Reference core Chart callbacks, Selection payloads, browser events, and adapter names.
4+
---
5+
6+
# Events and Callbacks
7+
8+
Core `Chart` callbacks run in Python through a live notebook widget or framework
9+
transport. Browser interactions continue to work in standalone HTML, but a
10+
self-contained file has no Python process to call.
11+
12+
## Core Python Callbacks
13+
14+
| Chart prop | Python payload |
15+
| --- | --- |
16+
| `on_hover` | Exact canonical row dictionary for the hovered point |
17+
| `on_click` | Exact canonical row dictionary for the clicked point |
18+
| `on_brush` | Selection geometry: normalized `x0`/`x1`/`y0`/`y1` or a `polygon` |
19+
| `on_select` | A `Selection` with canonical row indices grouped by trace |
20+
| `on_view_change` | Normalized `x0`, `x1`, `y0`, `y1`, and `source` |
21+
22+
Supplying a callback enables its corresponding browser interaction. Callback
23+
payload details are still experimental during the alpha series.
24+
25+
Hover and click rows contain `trace`, canonical `index`, `x`, `y`, `x_kind`,
26+
and `y_kind`. Depending on the mark's channels, they can also contain
27+
`color_value`, `color_category`, or `size_value`. These are data dictionaries,
28+
not DOM event objects or formatted tooltip strings.
29+
30+
~~~python
31+
import xy
32+
33+
34+
def selected(selection: xy.Selection) -> None:
35+
print(len(selection), selection.per_trace)
36+
37+
38+
chart = xy.scatter_chart(
39+
xy.scatter([0, 1, 2], [2, 4, 3]),
40+
on_select=selected,
41+
)
42+
~~~
43+
44+
## Selection
45+
46+
`Selection` exposes:
47+
48+
- `per_trace` — `{trace_id: numpy_uint32_indices}` in canonical row space.
49+
- `index` — all selected indices concatenated; use `per_trace` when trace
50+
identity matters.
51+
- `xy(trace_id=0)` — canonical f64 x/y arrays for one selected trace.
52+
- `len(selection)` — total selected rows across traces.
53+
54+
Clearing selection delivers an empty `Selection`. `Chart.select_range()`
55+
returns the same type without requiring a browser gesture.
56+
57+
## Browser DOM Events
58+
59+
The client dispatches bubbling custom events from the chart root:
60+
61+
| Event | Detail |
62+
| --- | --- |
63+
| `xy:hover` | Resident or exact `row`, `trace`, `index`, viewport, and optional `exact` flag |
64+
| `xy:click` | Data-space `x`/`y`, optional row hit, trace/index, and viewport |
65+
| `xy:select` | Selected `total`, viewport, and range or polygon when resolved locally |
66+
| `xy:view_change` | `x0`, `x1`, `y0`, `y1`, and interaction `source` |
67+
68+
A live hover can emit an immediate resident readout followed by an exact update.
69+
Consumers that only need the canonical Python row should use `on_hover`.
70+
71+
## Reflex Adapter Events
72+
73+
The separate `reflex-xy` adapter intentionally uses semantic component props:
74+
`on_point_hover`, `on_point_click`, `on_select_end`, and `on_view_change`.
75+
Those are adapter props, not aliases accepted by core `Chart`. See the
76+
[Reflex integration](/docs/xy/integrations/reflex/) for state-backed payloads.
77+
78+
Linked charts broadcast viewport ranges only. They do not automatically link
79+
selection state or cross-filter data.

0 commit comments

Comments
 (0)