pub struct PieChart { /* private fields */ }Expand description
A structure representing a pie chart.
The PieChart struct allows for the creation and customization of pie charts, supporting
features such as labels, hole size for donut-style charts, slice pulling, rotation, and customizable plot titles.
It is ideal for visualizing proportions and distributions in categorical data.
§Arguments
data- A reference to theDataFramecontaining the data to be plotted.labels- A string slice specifying the column name to be used for slice labels.hole- An optionalf64value specifying the size of the hole in the center of the pie chart. A value of0.0creates a full pie chart, while a value closer to1.0creates a thinner ring.pull- An optionalf64value specifying the fraction by which each slice should be pulled out from the center.rotation- An optionalf64value specifying the starting angle (in degrees) of the first slice.plot_title- An optionalTextstruct specifying the title of the plot.
§Example
§Basic Pie Chart with Customization
use polars::prelude::*;
use plotlars::{PieChart, Plot, Text};
let dataset = LazyCsvReader::new(PlPath::new("data/penguins.csv"))
.finish()
.unwrap()
.select([
col("species"),
])
.collect()
.unwrap();
PieChart::builder()
.data(&dataset)
.labels("species")
.hole(0.4)
.pull(0.01)
.rotation(20.0)
.plot_title(
Text::from("Pie Chart")
.font("Arial")
.size(18)
)
.build()
.plot();
Implementations§
Source§impl PieChart
impl PieChart
Sourcepub fn builder<'f1, 'f2>() -> PieChartBuilder<'f1, 'f2>
pub fn builder<'f1, 'f2>() -> PieChartBuilder<'f1, 'f2>
Examples found in repository?
examples/piechart.rs (line 13)
5fn main() {
6 let dataset = LazyCsvReader::new(PlPath::new("data/penguins.csv"))
7 .finish()
8 .unwrap()
9 .select([col("species")])
10 .collect()
11 .unwrap();
12
13 PieChart::builder()
14 .data(&dataset)
15 .labels("species")
16 .hole(0.4)
17 .pull(0.01)
18 .rotation(20.0)
19 .plot_title(Text::from("Pie Chart").font("Arial").size(18))
20 .build()
21 .plot();
22}Trait Implementations§
Source§impl PlotHelper for PieChart
impl PlotHelper for PieChart
fn get_layout(&self) -> &LayoutPlotly
fn get_traces(&self) -> &Vec<Box<dyn Trace + 'static>>
Auto Trait Implementations§
impl Freeze for PieChart
impl !RefUnwindSafe for PieChart
impl !Send for PieChart
impl !Sync for PieChart
impl Unpin for PieChart
impl !UnwindSafe for PieChart
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more