pub struct Cell { /* private fields */ }Expand description
A structure representing cell formatting for tables.
The Cell struct allows customization of table cells including height,
alignment, font, and fill color.
§Example
use plotlars::{Table, Cell, Plot, Text, Rgb};
use polars::prelude::*;
let dataset = df![
"product" => &["Laptop", "Mouse", "Keyboard", "Monitor"],
"price" => &[999.99, 29.99, 79.99, 299.99],
"stock" => &[15, 250, 87, 42]
]
.unwrap();
let cell = Cell::new()
.height(30.0)
.align("left")
.font("Arial")
.fill(Rgb(240, 240, 240));
Table::builder()
.data(&dataset)
.columns(vec!["product", "price", "stock"])
.cell(&cell)
.plot_title(Text::from("Product Inventory"))
.build()
.plot();
Implementations§
Source§impl Cell
impl Cell
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Cell instance with default values.
Examples found in repository?
examples/table.rs (line 25)
5fn main() {
6 let dataset = df![
7 "name" => &["Alice Johnson", "Bob Smith", "Charlie Davis", "Diana Martinez", "Eva Wilson"],
8 "department" => &["Engineering", "Marketing", "Engineering", "Sales", "Marketing"],
9 "salary" => &[95000, 78000, 102000, 85000, 82000],
10 "years" => &[5, 3, 7, 4, 2]
11 ]
12 .unwrap();
13
14 let header = Header::new()
15 .values(vec![
16 "Employee Name",
17 "Department",
18 "Annual Salary ($)",
19 "Years of Service",
20 ])
21 .align("center")
22 .font("Arial Bold")
23 .fill(Rgb(70, 130, 180));
24
25 let cell = Cell::new()
26 .align("center")
27 .height(25.0)
28 .font("Arial")
29 .fill(Rgb(240, 248, 255));
30
31 Table::builder()
32 .data(&dataset)
33 .columns(vec!["name", "department", "salary", "years"])
34 .header(&header)
35 .cell(&cell)
36 .plot_title(
37 Text::from("Employee Data")
38 .font("Arial")
39 .size(20)
40 .color(Rgb(25, 25, 112)),
41 )
42 .build()
43 .plot();
44}Sourcepub fn height(self, height: f64) -> Self
pub fn height(self, height: f64) -> Self
Examples found in repository?
examples/table.rs (line 27)
5fn main() {
6 let dataset = df![
7 "name" => &["Alice Johnson", "Bob Smith", "Charlie Davis", "Diana Martinez", "Eva Wilson"],
8 "department" => &["Engineering", "Marketing", "Engineering", "Sales", "Marketing"],
9 "salary" => &[95000, 78000, 102000, 85000, 82000],
10 "years" => &[5, 3, 7, 4, 2]
11 ]
12 .unwrap();
13
14 let header = Header::new()
15 .values(vec![
16 "Employee Name",
17 "Department",
18 "Annual Salary ($)",
19 "Years of Service",
20 ])
21 .align("center")
22 .font("Arial Bold")
23 .fill(Rgb(70, 130, 180));
24
25 let cell = Cell::new()
26 .align("center")
27 .height(25.0)
28 .font("Arial")
29 .fill(Rgb(240, 248, 255));
30
31 Table::builder()
32 .data(&dataset)
33 .columns(vec!["name", "department", "salary", "years"])
34 .header(&header)
35 .cell(&cell)
36 .plot_title(
37 Text::from("Employee Data")
38 .font("Arial")
39 .size(20)
40 .color(Rgb(25, 25, 112)),
41 )
42 .build()
43 .plot();
44}Sourcepub fn align(self, align: impl Into<String>) -> Self
pub fn align(self, align: impl Into<String>) -> Self
Sets the alignment of the cell text.
§Argument
align- A string specifying the alignment (left, center, right).
Examples found in repository?
examples/table.rs (line 26)
5fn main() {
6 let dataset = df![
7 "name" => &["Alice Johnson", "Bob Smith", "Charlie Davis", "Diana Martinez", "Eva Wilson"],
8 "department" => &["Engineering", "Marketing", "Engineering", "Sales", "Marketing"],
9 "salary" => &[95000, 78000, 102000, 85000, 82000],
10 "years" => &[5, 3, 7, 4, 2]
11 ]
12 .unwrap();
13
14 let header = Header::new()
15 .values(vec![
16 "Employee Name",
17 "Department",
18 "Annual Salary ($)",
19 "Years of Service",
20 ])
21 .align("center")
22 .font("Arial Bold")
23 .fill(Rgb(70, 130, 180));
24
25 let cell = Cell::new()
26 .align("center")
27 .height(25.0)
28 .font("Arial")
29 .fill(Rgb(240, 248, 255));
30
31 Table::builder()
32 .data(&dataset)
33 .columns(vec!["name", "department", "salary", "years"])
34 .header(&header)
35 .cell(&cell)
36 .plot_title(
37 Text::from("Employee Data")
38 .font("Arial")
39 .size(20)
40 .color(Rgb(25, 25, 112)),
41 )
42 .build()
43 .plot();
44}Sourcepub fn font(self, font: &str) -> Self
pub fn font(self, font: &str) -> Self
Sets the font family of the cell text.
§Argument
font- A string slice specifying the font family name.
Examples found in repository?
examples/table.rs (line 28)
5fn main() {
6 let dataset = df![
7 "name" => &["Alice Johnson", "Bob Smith", "Charlie Davis", "Diana Martinez", "Eva Wilson"],
8 "department" => &["Engineering", "Marketing", "Engineering", "Sales", "Marketing"],
9 "salary" => &[95000, 78000, 102000, 85000, 82000],
10 "years" => &[5, 3, 7, 4, 2]
11 ]
12 .unwrap();
13
14 let header = Header::new()
15 .values(vec![
16 "Employee Name",
17 "Department",
18 "Annual Salary ($)",
19 "Years of Service",
20 ])
21 .align("center")
22 .font("Arial Bold")
23 .fill(Rgb(70, 130, 180));
24
25 let cell = Cell::new()
26 .align("center")
27 .height(25.0)
28 .font("Arial")
29 .fill(Rgb(240, 248, 255));
30
31 Table::builder()
32 .data(&dataset)
33 .columns(vec!["name", "department", "salary", "years"])
34 .header(&header)
35 .cell(&cell)
36 .plot_title(
37 Text::from("Employee Data")
38 .font("Arial")
39 .size(20)
40 .color(Rgb(25, 25, 112)),
41 )
42 .build()
43 .plot();
44}Sourcepub fn fill(self, fill: Rgb) -> Self
pub fn fill(self, fill: Rgb) -> Self
Examples found in repository?
examples/table.rs (line 29)
5fn main() {
6 let dataset = df![
7 "name" => &["Alice Johnson", "Bob Smith", "Charlie Davis", "Diana Martinez", "Eva Wilson"],
8 "department" => &["Engineering", "Marketing", "Engineering", "Sales", "Marketing"],
9 "salary" => &[95000, 78000, 102000, 85000, 82000],
10 "years" => &[5, 3, 7, 4, 2]
11 ]
12 .unwrap();
13
14 let header = Header::new()
15 .values(vec![
16 "Employee Name",
17 "Department",
18 "Annual Salary ($)",
19 "Years of Service",
20 ])
21 .align("center")
22 .font("Arial Bold")
23 .fill(Rgb(70, 130, 180));
24
25 let cell = Cell::new()
26 .align("center")
27 .height(25.0)
28 .font("Arial")
29 .fill(Rgb(240, 248, 255));
30
31 Table::builder()
32 .data(&dataset)
33 .columns(vec!["name", "department", "salary", "years"])
34 .header(&header)
35 .cell(&cell)
36 .plot_title(
37 Text::from("Employee Data")
38 .font("Arial")
39 .size(20)
40 .color(Rgb(25, 25, 112)),
41 )
42 .build()
43 .plot();
44}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Cell
impl RefUnwindSafe for Cell
impl Send for Cell
impl Sync for Cell
impl Unpin for Cell
impl UnwindSafe for Cell
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 moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().