pub struct Table { /* private fields */ }Expand description
A structure representing a table plot.
The Table struct allows for the creation and customization of tables with support
for custom headers, cell formatting, column widths, and various styling options.
§Arguments
data- A reference to theDataFramecontaining the data to be displayed.columns- A vector of column names to be displayed in the table.header- An optionalHeadercomponent for custom header values and formatting.cell- An optionalCellcomponent for cell formatting.column_width- An optional column width ratio. Columns fill the available width in proportion.plot_title- An optionalTextstruct specifying the title of the plot.
§Example
use polars::prelude::*;
use plotlars::{Table, Header, Cell, Plot, Text, Rgb};
let dataset = LazyCsvReader::new(PlPath::new("data/employee_data.csv"))
.finish()
.unwrap()
.collect()
.unwrap();
let header = Header::new()
.values(vec![
"Employee Name",
"Department",
"Annual Salary ($)",
"Years of Service",
])
.align("center")
.font("Arial Bold")
.fill(Rgb(70, 130, 180));
let cell = Cell::new()
.align("center")
.height(25.0)
.font("Arial")
.fill(Rgb(240, 248, 255));
Table::builder()
.data(&dataset)
.columns(vec![
"name",
"department",
"salary",
"years",
])
.header(&header)
.cell(&cell)
.plot_title(
Text::from("Table")
.font("Arial")
.size(20)
.color(Rgb(25, 25, 112))
)
.build()
.plot();
Implementations§
Source§impl Table
impl Table
Sourcepub fn builder<'f1, 'f2, 'f3, 'f4>() -> TableBuilder<'f1, 'f2, 'f3, 'f4>
pub fn builder<'f1, 'f2, 'f3, 'f4>() -> TableBuilder<'f1, 'f2, 'f3, 'f4>
Examples found in repository?
examples/table.rs (line 28)
4fn main() {
5 let dataset = LazyCsvReader::new(PlPath::new("data/employee_data.csv"))
6 .finish()
7 .unwrap()
8 .collect()
9 .unwrap();
10
11 let header = Header::new()
12 .values(vec![
13 "Employee Name",
14 "Department",
15 "Annual Salary ($)",
16 "Years of Service",
17 ])
18 .align("center")
19 .font("Arial Bold")
20 .fill(Rgb(70, 130, 180));
21
22 let cell = Cell::new()
23 .align("center")
24 .height(25.0)
25 .font("Arial")
26 .fill(Rgb(240, 248, 255));
27
28 Table::builder()
29 .data(&dataset)
30 .columns(vec!["name", "department", "salary", "years"])
31 .header(&header)
32 .cell(&cell)
33 .plot_title(
34 Text::from("Employee Data")
35 .font("Arial")
36 .size(20)
37 .color(Rgb(25, 25, 112)),
38 )
39 .build()
40 .plot();
41}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Table
impl !RefUnwindSafe for Table
impl !Send for Table
impl !Sync for Table
impl Unpin for Table
impl !UnwindSafe for Table
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