leptos_chartistry/lib.rs
1#![warn(missing_docs)]
2//! Welcome to Chartistry! This crate provides a flexible way to build charts in [Leptos](https://github.com/leptos-rs/leptos).
3//!
4//! All charts are built using the [Chart] fn. If you understand this function, you understand this library.
5//!
6//! ## Examples
7//!
8//! - See the [demo for Chartistry in action](https://feral-dot-io.github.io/leptos-chartistry/).
9//! - There is also an [large, assorted list of examples](https://feral-dot-io.github.io/leptos-chartistry/examples.html) available.
10//!
11//! Below is an example chart:
12//!
13//! ```rust
14//! use leptos::prelude::*;
15//! use leptos_chartistry::*;
16//!
17//! # use chrono::prelude::*;
18//! # struct MyData { x: DateTime<Utc>, y1: f64, y2: f64 }
19//! # fn load_data() -> Signal<Vec<MyData>> { Signal::default() }
20//!
21//! # #[component]
22//! # fn SimpleChartComponent() -> impl IntoView {
23//! let data: Signal<Vec<MyData>> = load_data(/* pull data from a resource */);
24//! view! {
25//! <Chart
26//! // Sets the width and height
27//! aspect_ratio=AspectRatio::from_outer_ratio(600.0, 300.0)
28//!
29//! // Decorate our chart
30//! top=RotatedLabel::middle("My garden")
31//! left=TickLabels::aligned_floats()
32//! right=Legend::end()
33//! bottom=TickLabels::timestamps()
34//! inner=[
35//! AxisMarker::left_edge().into_inner(),
36//! AxisMarker::bottom_edge().into_inner(),
37//! XGridLine::default().into_inner(),
38//! YGridLine::default().into_inner(),
39//! XGuideLine::over_data().into_inner(),
40//! YGuideLine::over_mouse().into_inner(),
41//! ]
42//! tooltip=Tooltip::left_cursor()
43//!
44//! // Describe the data
45//! series=Series::new(|data: &MyData| data.x)
46//! .line(Line::new(|data: &MyData| data.y1).with_name("butterflies"))
47//! .line(Line::new(|data: &MyData| data.y2).with_name("dragonflies"))
48//! data=data
49//! />
50//! }
51//! # }
52//! ```
53
54mod aspect_ratio;
55mod bounds;
56mod chart;
57mod colours;
58mod debug;
59mod edge;
60mod inner;
61mod layout;
62mod overlay;
63mod padding;
64mod projection;
65mod series;
66mod state;
67mod ticks;
68mod use_watched_node;
69
70pub use aspect_ratio::AspectRatio;
71pub use chart::Chart;
72pub use colours::{Colour, ColourScheme, DivergingGradient, SequentialGradient};
73pub use edge::Edge;
74pub use inner::{
75 axis_marker::{AxisMarker, AxisPlacement, AXIS_MARKER_COLOUR},
76 grid_line::{XGridLine, YGridLine, GRID_LINE_COLOUR},
77 guide_line::{AlignOver, XGuideLine, YGuideLine, GUIDE_LINE_COLOUR},
78 legend::InsetLegend,
79 InnerLayout, IntoInner, IntoInner as _,
80};
81pub use layout::{
82 legend::Legend,
83 rotated_label::{Anchor, RotatedLabel},
84 tick_labels::TickLabels,
85 EdgeLayout, IntoEdge, IntoEdge as _,
86};
87pub use overlay::tooltip::{Tooltip, TooltipPlacement, TooltipSortBy, TOOLTIP_CURSOR_DISTANCE};
88pub use padding::Padding;
89pub use series::{
90 Bar, BarPlacement, Interpolation, Line, Marker, MarkerShape, Series, Stack, Step, BAR_GAP,
91 BAR_GAP_INNER, DIVERGING_GRADIENT, LINEAR_GRADIENT, SERIES_COLOUR_SCHEME, STACK_COLOUR_SCHEME,
92};
93pub use ticks::{AlignedFloats, Period, Tick, TickFormat, Timestamps};