fjkit-charts
Server-rendered Plotly charts for fjkit. A plugin, one line to add, no front-end build.
uv add fjkit-charts
from fjkit import FjkitConfig
from fjkit_charts import ChartsPlugin
config = FjkitConfig(template_dir=APP_DIR / "templates", plugins=(ChartsPlugin(),))
{% from "charts/macros.html" import chart, chart_scripts %}
{% for item in charts %}{{ chart(item) }}{% endfor %}
{% block scripts %}{{ chart_scripts() }}{% endblock %}
Plotly's cartesian bundle ships inside this wheel and is served from the
plugin's own static mount. Nothing is fetched at runtime, and a page loads the
1.4 MB only if it calls chart_scripts().
Chart accepts exactly the twelve trace types that bundle registers — bar,
box, contour, heatmap, histogram, histogram2d, histogram2dcontour,
image, pie, scatter, scatterternary and violin. Any other type fails
validation in the route rather than drawing an empty box in the browser.
assert_no_colour_in(charts) is the test to put in your own suite. It refuses
an image trace, whose z is a colour per pixel chosen on the server and
cannot follow the theme; pass allow_image=True when the pixels are the point.
If the app builds figures with plotly.py, that library targets one plotly.js
release. When its major or minor differs from the bundled one, the plugin emits
a PluginWarning at startup. plotly.py is not a dependency of this package.
Chart chrome — axis text, grid lines, tick colour, the hover card — is resolved from the live theme tokens on every draw, so a theme toggle is a redraw.
A chart is drawn when it first comes into view, not when the page loads.
Drawing one costs around 20 ms, so a page of fifteen draws the four that are on
screen; the rest are sized from Chart.height and wait. An overflow-x: auto
row counts — a chart scrolled off the side of one is off screen. Pass
chart(item, eager=true) for a chart that has to be in the first paint.
Each chart dispatches two bubbling DOM events on its [data-chart] div.
fjkit:chart-drawn follows every draw, theme redraws included, with an empty
detail. fjkit:chart-click fires once per click on a point, with
detail = {curve, point, x, y, name, meta, customdata}. Keyword arguments to
chart() land on that div, so a click can drive an htmx request:
{{ chart(item, hx_get="/tasks/table", hx_trigger="fjkit:chart-click",
hx_target="#tasks", hx_vals="js:{...event.detail}") }}
With htmx 2, that sends each field as a query parameter: an array as repeated
parameters, an object as JSON, and a field the trace does not set as the string
undefined. Name the fields the route reads — js:{status: event.detail.x} —
to send only those.
A trigger filter must evaluate to exactly true, so
fjkit:chart-click[detail.customdata] never fires when customdata is an
array or an object; compare instead, as in
hx_trigger="fjkit:chart-click[detail.customdata!=null]".
License
MIT. See LICENSE.
Metadata
Release files for fjkit-charts 0.3.1
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 | Actions |
|---|---|---|---|---|
| fjkit_charts-0.3.1.tar.gz | 502.2 kB | Without provenance | Details for fjkit_charts-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fjkit_charts-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for fjkit_charts-0.3.1-py3-none-any.whl |
Total release size: 998.7 kB
Release files / fjkit_charts-0.3.1.tar.gz
| Download URL | fjkit_charts-0.3.1.tar.gz |
|---|---|
| Size | 502.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cdde17edccc7fb0dfb1af73e286d26ee90a88a68ee0873125e46aae7ada4a399
|
|
BLAKE2b-256 checksum How to use checksums |
59e9d25fd691d5531d6d60b278df61e6136943a0e5ea24ed710b38e4be30f7ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / fjkit_charts-0.3.1-py3-none-any.whl
| Download URL | fjkit_charts-0.3.1-py3-none-any.whl |
|---|---|
| Size | 496.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60e784854cec6a8a7554054782280b7f85161a1070e76862fe1b3deb810b6cb1
|
|
BLAKE2b-256 checksum How to use checksums |
fbed50f3d7068c017ef750fcd29f5c289cef8cc01029cf3304f3303a510d945c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for fjkit-charts 0.3.1
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.