fjader 0.2.3__tar.gz → 0.2.5__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.
- {fjader-0.2.3 → fjader-0.2.5}/PKG-INFO +4 -2
- {fjader-0.2.3 → fjader-0.2.5}/README.md +3 -1
- {fjader-0.2.3 → fjader-0.2.5}/fjader/__init__.py +2 -2
- fjader-0.2.5/fjader/_version.py +1 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/fields.py +42 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/marks/__init__.py +224 -78
- {fjader-0.2.3 → fjader-0.2.5}/fjader/marks/_base.py +17 -3
- {fjader-0.2.3 → fjader-0.2.5}/fjader/marks/area.py +3 -3
- {fjader-0.2.3 → fjader-0.2.5}/fjader/marks/bar.py +11 -5
- {fjader-0.2.3 → fjader-0.2.5}/fjader/marks/dot.py +2 -2
- {fjader-0.2.3 → fjader-0.2.5}/fjader/marks/line.py +2 -2
- {fjader-0.2.3 → fjader-0.2.5}/fjader/marks/rect.py +4 -5
- {fjader-0.2.3 → fjader-0.2.5}/fjader/marks/text.py +2 -2
- {fjader-0.2.3 → fjader-0.2.5}/fjader/plot.py +10 -1
- {fjader-0.2.3 → fjader-0.2.5}/fjader/static/THIRD_PARTY_LICENSES.txt +1 -1
- fjader-0.2.5/fjader/static/widget.css +1 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/static/widget.js +16854 -13835
- {fjader-0.2.3 → fjader-0.2.5}/fjader/streamlit_frontend/THIRD_PARTY_LICENSES.txt +1 -1
- fjader-0.2.5/fjader/streamlit_frontend/assets/index-DBI-Z-N4.css +1 -0
- fjader-0.2.5/fjader/streamlit_frontend/assets/index-il8PKhif.js +2161 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/streamlit_frontend/index.html +2 -2
- {fjader-0.2.3 → fjader-0.2.5}/fjader/tests/test_fields.py +32 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/tests/test_marks.py +36 -0
- {fjader-0.2.3 → fjader-0.2.5}/pyproject.toml +1 -1
- fjader-0.2.3/fjader/_version.py +0 -1
- fjader-0.2.3/fjader/static/widget.css +0 -1
- fjader-0.2.3/fjader/streamlit_frontend/assets/index-BCzXcSyo.js +0 -2011
- fjader-0.2.3/fjader/streamlit_frontend/assets/index-BQspEPyb.css +0 -1
- {fjader-0.2.3 → fjader-0.2.5}/LICENSE +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/NOTICE +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/_accessor.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/_convert.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/_data.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/_display.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/_from_spec.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/_streamlit.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/_types.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/_widget.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/data.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/interactors.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/layout.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/pandas.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/polars.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/tests/__init__.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/tests/conftest.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/tests/test_accessor.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/tests/test_composition.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/tests/test_convert.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/tests/test_from_spec.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/tests/test_serialization.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/tests/test_transforms.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/transforms/__init__.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/transforms/_base.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/transforms/js.py +0 -0
- {fjader-0.2.3 → fjader-0.2.5}/fjader/transforms/sql.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fjader
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: An experimental, declarative charting library for Svelte and Python that queries DuckDB and renders with WebGPU
|
|
5
5
|
License-Expression: BSD-3-Clause
|
|
6
6
|
License-File: LICENSE
|
|
@@ -42,12 +42,14 @@ pip install fjader # Python: marimo and Jupyter
|
|
|
42
42
|
pip install "fjader[streamlit]" # Python: Streamlit
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
`@uwdata/mosaic-sql` is a peer dependency (0.34 or 0.35), so your app and fjader share one copy. Two copies would not recognise each other's expressions: an aggregate such as `sum(...)` written with one would be misread by the other.
|
|
46
|
+
|
|
45
47
|
fjader needs Chrome 149 or later, or another Chromium browser on that version. It relies on two recent features other browsers don't ship yet: WebGPU's `immediate_address_space`, through which every chart passes its scales to the shaders (so every zoom and pan uses it), and the `Temporal` API, used for calendar offsets. There is no fallback renderer.
|
|
46
48
|
|
|
47
49
|
Three things to know before using it in a deployed app:
|
|
48
50
|
|
|
49
51
|
- **Data goes to the browser in full.** The Python widget and the Streamlit component send every column of a DataFrame to the browser, where DuckDB-WASM queries it. Anyone viewing the app can extract it, so pass only the columns you mean to show. In Jupyter, saved widget state can also store the data in the notebook file.
|
|
50
|
-
- **DuckDB-WASM loads from jsDelivr at runtime.**
|
|
52
|
+
- **DuckDB-WASM loads from jsDelivr at runtime by default.** A Svelte app can serve the files itself with `initFjader({ bundles })`, or pass a DuckDB instance it already has with `initFjader(connectionFrom(conn))`. `Fjader.render()`, the Python widget and Streamlit always load from the CDN, so locked-down networks that block it cannot render charts with them.
|
|
51
53
|
- **Specs are trusted input.** A spec's `{ "sql": "…" }` field runs as raw SQL in the viewer's DuckDB-WASM. Don't build specs from untrusted input.
|
|
52
54
|
|
|
53
55
|
## Svelte
|
|
@@ -16,12 +16,14 @@ pip install fjader # Python: marimo and Jupyter
|
|
|
16
16
|
pip install "fjader[streamlit]" # Python: Streamlit
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
`@uwdata/mosaic-sql` is a peer dependency (0.34 or 0.35), so your app and fjader share one copy. Two copies would not recognise each other's expressions: an aggregate such as `sum(...)` written with one would be misread by the other.
|
|
20
|
+
|
|
19
21
|
fjader needs Chrome 149 or later, or another Chromium browser on that version. It relies on two recent features other browsers don't ship yet: WebGPU's `immediate_address_space`, through which every chart passes its scales to the shaders (so every zoom and pan uses it), and the `Temporal` API, used for calendar offsets. There is no fallback renderer.
|
|
20
22
|
|
|
21
23
|
Three things to know before using it in a deployed app:
|
|
22
24
|
|
|
23
25
|
- **Data goes to the browser in full.** The Python widget and the Streamlit component send every column of a DataFrame to the browser, where DuckDB-WASM queries it. Anyone viewing the app can extract it, so pass only the columns you mean to show. In Jupyter, saved widget state can also store the data in the notebook file.
|
|
24
|
-
- **DuckDB-WASM loads from jsDelivr at runtime.**
|
|
26
|
+
- **DuckDB-WASM loads from jsDelivr at runtime by default.** A Svelte app can serve the files itself with `initFjader({ bundles })`, or pass a DuckDB instance it already has with `initFjader(connectionFrom(conn))`. `Fjader.render()`, the Python widget and Streamlit always load from the CDN, so locked-down networks that block it cannot render charts with them.
|
|
25
27
|
- **Specs are trusted input.** A spec's `{ "sql": "…" }` field runs as raw SQL in the viewer's DuckDB-WASM. Don't build specs from untrusted input.
|
|
26
28
|
|
|
27
29
|
## Svelte
|
|
@@ -47,7 +47,7 @@ from .transforms import (
|
|
|
47
47
|
)
|
|
48
48
|
|
|
49
49
|
# Field spec helpers
|
|
50
|
-
from .fields import count, sum, avg, min_, max_, median, bin, window, sql_expr
|
|
50
|
+
from .fields import count, sum, avg, min_, max_, median, bin, window, sql_expr, colors
|
|
51
51
|
|
|
52
52
|
# Data helpers
|
|
53
53
|
from .data import sql
|
|
@@ -85,7 +85,7 @@ __all__ = [
|
|
|
85
85
|
"filter", "having", "limit", "orderby",
|
|
86
86
|
"topN", "stack_y", "stack_x", "normalize", "dodge",
|
|
87
87
|
# Fields
|
|
88
|
-
"count", "sum", "avg", "min_", "max_", "median", "bin", "window", "sql_expr",
|
|
88
|
+
"count", "sum", "avg", "min_", "max_", "median", "bin", "window", "sql_expr", "colors",
|
|
89
89
|
# Data
|
|
90
90
|
"sql",
|
|
91
91
|
# Display
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.5"
|
|
@@ -103,6 +103,48 @@ class RawSqlField:
|
|
|
103
103
|
FieldSpec = str | AggregateField | BinField | WindowField | RawSqlField
|
|
104
104
|
|
|
105
105
|
|
|
106
|
+
@dataclass(frozen=True)
|
|
107
|
+
class ColorField:
|
|
108
|
+
"""A colour channel with explicit ordinal colours. Build it with :func:`colors`."""
|
|
109
|
+
|
|
110
|
+
field: str
|
|
111
|
+
domain: tuple[Any, ...] | None = None
|
|
112
|
+
range: tuple[str, ...] | None = None
|
|
113
|
+
|
|
114
|
+
def to_dict(self) -> dict[str, Any]:
|
|
115
|
+
result: dict[str, Any] = {"field": self.field}
|
|
116
|
+
if self.domain is not None:
|
|
117
|
+
result["domain"] = list(self.domain)
|
|
118
|
+
if self.range is not None:
|
|
119
|
+
result["range"] = list(self.range)
|
|
120
|
+
return result
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
ColorChannel = FieldSpec | ColorField
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def colors(
|
|
127
|
+
field: str,
|
|
128
|
+
mapping: dict[Any, str] | list[str] | tuple[str, ...],
|
|
129
|
+
domain: list[Any] | tuple[Any, ...] | None = None,
|
|
130
|
+
) -> ColorField:
|
|
131
|
+
"""Colour ``field``'s categories with explicit colours.
|
|
132
|
+
|
|
133
|
+
A dict pins each value to its colour; values not in it draw the null colour.
|
|
134
|
+
A list is a palette, assigned in sorted value order, or in ``domain`` order
|
|
135
|
+
when given. Either makes the scale ordinal, so
|
|
136
|
+
a 0/1 integer column works too::
|
|
137
|
+
|
|
138
|
+
fj.bar_y(x="team", y=fj.count(), fill=fj.colors("won", {0: "#d62728", 1: "#2ca02c"}))
|
|
139
|
+
fj.dot(x="a", y="b", fill=fj.colors("species", ["#1b9e77", "#d95f02", "#7570b3"]))
|
|
140
|
+
"""
|
|
141
|
+
if isinstance(mapping, dict):
|
|
142
|
+
if domain is not None:
|
|
143
|
+
raise ValueError("colors(): pass domain only with a list of colours, not a dict")
|
|
144
|
+
return ColorField(field, tuple(mapping.keys()), tuple(mapping.values()))
|
|
145
|
+
return ColorField(field, tuple(domain) if domain is not None else None, tuple(mapping))
|
|
146
|
+
|
|
147
|
+
|
|
106
148
|
def count() -> AggregateField:
|
|
107
149
|
"""count() aggregate."""
|
|
108
150
|
return AggregateField(aggregate="count")
|