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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//! Pure-Rust + SVG interactive charts for Leptos CSR.
//!
//! v0.1 ships one chart type — [`AreaChart`] — with the visual style
//! of ApexCharts (gradient fills, soft axes, modern legend) but
//! implemented entirely in Rust + SVG. No JS, no canvas, no Tailwind.
//! Designed to be project-agnostic: no consumer types leak into the
//! public API.
//!
//! ## Quick start
//!
//! ```ignore
//! use leptos::prelude::*;
//! use forge_charts::{AreaChart, Series, CHART_CSS};
//!
//! #[derive(Clone)]
//! struct Datum { date: String, opened: u32, closed: u32 }
//!
//! #[component]
//! fn MyChart(data: Signal<Vec<Datum>>) -> impl IntoView {
//! view! {
//! <Stylesheet text=CHART_CSS />
//! <AreaChart
//! data=data
//! x_label=|d: &Datum| d.date.clone()
//! y_values=|d: &Datum| vec![f64::from(d.opened), f64::from(d.closed)]
//! series=vec![
//! Series::area("Opened", "opened"),
//! Series::area("Closed", "closed"),
//! ]
//! height=320
//! />
//! }
//! }
//! ```
//!
//! ## Styling
//!
//! The crate ships a default stylesheet exposed as the [`CHART_CSS`]
//! constant. Consumers inject it once via Leptos `<Stylesheet />` at
//! the app root. CSS variables (`--charts-fg`, `--charts-grid-color`,
//! `--charts-series-opened`, `--charts-series-closed`, …) let
//! consumers theme without forking the stylesheet.
//!
//! ## Roadmap
//!
//! - **Phase B** (shipped): hover crosshair + consumer-provided
//! tooltip slot.
//! - **Phase C** (shipped): drag-to-zoom + reset.
//! - **Future**: Bar / Line variants, smooth Bezier curves, stacked
//! areas. Extract shared math when the second chart needs it.
// All modules are internal implementation detail; the public surface
// is the re-exports below. `pub(crate)` so the crate's SemVer surface
// is the named items, not the module layout. The `unreachable_pub`
// allow keeps the inner `pub fn` / `pub struct` markers as
// module-local API documentation rather than forcing every item to
// be `pub(crate)`.
pub
pub
pub
pub
pub
pub
pub
pub use ;
pub use HoverState;
pub use ;
pub use ;
/// Default stylesheet bundled with the crate. Inject once at the app
/// root via `<Stylesheet text=CHART_CSS />` (Leptos meta).
pub const CHART_CSS: &str = include_str!;