visualize_yew/
lib.rs

1//! # Visualize Yew
2//!
3//! `Visualize Yew` is a simple crate to help you visualize your data in the browser using Yew. It is a wrapper around the yew crate that provides a simple API to create charts.
4//!
5//! ## Features
6//!
7//! - `BarChart` — Renders a standard bar chart.
8//! - `PieChart` — Renders a pie chart.
9//! - `LineCurveChart` — Renders a line chart with optional curve smoothing.
10//! - `DoughnutChart` — Renders a doughnut chart similar to a pie chart but with a hole in the center.
11//!
12//! Enable the desired chart(s) in your `Cargo.toml`:
13//!
14//! ```toml
15//! visualize-yew = { version = "0.2x.x", features = ["BarChart", "PieChart"] }
16//! ```
17//!
18//! ## Example
19//!
20//! ```rust
21//! use visualize_yew::pie_chart::{DataPoint as PieChartData, PieChart};
22//!
23//! #[function_component]
24//! fn Home() -> Html {
25//!     let mut pie_chart_config = PieChartConfig::default();
26//!     pie_chart_config.show_legend = true;
27//!
28//!     let pie_data = vec![
29//!         PieChartData::new("A", 10, ""),
30//!         PieChartData::new("B", 20, ""),
31//!         PieChartData::new("C", 30, ""),
32//!         PieChartData::new("D", 40, ""),
33//!     ];
34//!
35//!     html! {
36//!         // Chart will take the full width of the parent container
37//!         <div>
38//!             <PieChart data={pie_chart_data} config={pie_chart_config} />
39//!         </div>
40//!     }
41//! }
42//! ```
43
44pub mod charts;
45
46#[cfg(feature = "BarChart")]
47/// Renders a bar chart.
48///
49/// This feature is enabled by default.
50pub use charts::bar_chart::bar_chart;
51
52#[cfg(feature = "PieChart")]
53/// Renders a pie chart.
54///
55/// Enable this via the `PieChart` feature in Cargo.toml.
56pub use charts::pie_chart::pie_chart;
57
58#[cfg(feature = "LineCurveChart")]
59/// Renders a line chart with optional curves.
60///
61/// Enable this via the `LineCurveChart` feature in Cargo.toml.
62pub use charts::line_chart::line_chart;
63
64#[cfg(feature = "DoughnutChart")]
65/// Renders a doughnut chart.
66///
67/// Enable this via the `DoughnutChart` feature in Cargo.toml.
68pub use charts::doughnut_chart::doughnut_chart;