Expand description
§tui-piechart
A customizable pie chart widget for Ratatui TUI applications.
§Features
- 🥧 Simple pie chart with customizable slices
- 🎨 Customizable colors for each slice
- 🔤 Labels and percentages
- 📊 Legend support
- 📦 Optional block wrapper
- ✨ Custom symbols for pie chart and legend
- ⚡ Zero-cost abstractions
§Examples
Basic usage:
use ratatui::style::Color;
use tui_piechart::{PieChart, PieSlice};
let slices = vec![
PieSlice::new("Rust", 45.0, Color::Red),
PieSlice::new("Go", 30.0, Color::Blue),
PieSlice::new("Python", 25.0, Color::Green),
];
let piechart = PieChart::new(slices);With custom styling:
use ratatui::style::{Color, Style};
use tui_piechart::{PieChart, PieSlice};
let slices = vec![
PieSlice::new("Rust", 45.0, Color::Red),
PieSlice::new("Go", 30.0, Color::Blue),
];
let piechart = PieChart::new(slices)
.style(Style::default())
.show_legend(true)
.show_percentages(true);With custom symbols:
use ratatui::style::Color;
use tui_piechart::{PieChart, PieSlice, symbols};
let slices = vec![
PieSlice::new("Rust", 45.0, Color::Red),
PieSlice::new("Go", 30.0, Color::Blue),
];
// Use predefined symbols
let piechart = PieChart::new(slices.clone())
.pie_char(symbols::PIE_CHAR_BLOCK)
.legend_marker(symbols::LEGEND_MARKER_CIRCLE);
// Or use any custom characters
let piechart = PieChart::new(slices)
.pie_char('█')
.legend_marker("→");Modules§
- symbols
- Symbols for pie chart widget
Structs§
- PieChart
- A widget that displays a pie chart.
- PieSlice
- A slice of the pie chart representing a portion of data.
Enums§
- Resolution
- Rendering resolution mode for pie charts.