1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! rustlavel-chart: charts, drawn in the browser, described in Rust.
//!
//! **This package vendors somebody else's library, and that is unusual here.**
//! Chart.js is 69 KB gzipped and renders to a `<canvas>`; drawing the same
//! thing from scratch would mean writing an axis scaler, a tick formatter, a
//! legend layout engine and a hit-tester, and the result would still not have
//! hover, tooltips or zoom. The copy lives in `assets/`, under its own MIT
//! licence, and is served from this application's own origin — see [`plugin`].
//!
//! The Rust half never draws anything. It builds the *configuration* Chart.js
//! reads, which is a JSON object, and hands it to the page:
//!
//! ```ignore
//! let chart = Chart::line("Revenue")
//! .labels(["Jan", "Feb", "Mar"])
//! .series(Series::new("2026", [1_200.0, 1_800.0, 1_500.0]))
//! .series(Series::new("2025", [900.0, 1_100.0, 1_400.0]));
//!
//! Ok(view("dashboard", context! { revenue: chart.to_json() })?)
//! ```
//!
//! ```html
//! <canvas data-chart="{{ revenue }}"></canvas>
//! ```
//!
//! # Why an attribute, and why `{{ }}`
//!
//! The configuration travels in an ordinary escaped attribute. `{{ }}` turns
//! every `"` into `"` and every `<` into `<`, the browser reverses that
//! when it reads `dataset.chart`, and the round trip is exact — so a label
//! reading `</script>` is a label, not an escape.
//!
//! This is the whole reason there is no inline `<script>` anywhere in this
//! package. A page that writes `<script>new Chart(…)</script>` needs
//! `script-src 'unsafe-inline'`, and a policy with `unsafe-inline` does not
//! stop injected script — which is the one thing a Content-Security-Policy is
//! for. The auth kit ships `default-src 'self'` with no `unsafe-inline`, and
//! everything here is built to satisfy that policy rather than to ask for an
//! exception to it.
pub use ;
pub use Palette;
pub use ;
pub use Series;
pub use ;