pub struct Header {
pub values: Option<Vec<String>>,
pub height: Option<f64>,
pub align: Option<String>,
pub font: Option<String>,
pub fill: Option<Rgb>,
}Expand description
A structure representing header formatting for tables.
The Header struct allows customization of table headers including custom values,
height, alignment, font, and fill color.
§Example
use plotlars::{Table, Header, Plot, Text, Rgb};
use polars::prelude::*;
let dataset = df![
"name" => &["Alice", "Bob", "Charlie"],
"age" => &[25, 30, 35],
"city" => &["New York", "London", "Tokyo"]
]
.unwrap();
let header = Header::new()
.values(vec!["Full Name", "Years", "Location"])
.height(40.0)
.align("center")
.font("Arial")
.fill(Rgb(200, 200, 200));
Table::builder()
.data(&dataset)
.columns(vec!["name", "age", "city"])
.header(&header)
.plot_title(Text::from("Employee Information"))
.build()
.plot();
Fields§
§values: Option<Vec<String>>§height: Option<f64>§align: Option<String>§font: Option<String>§fill: Option<Rgb>Implementations§
Source§impl Header
impl Header
Sourcepub fn new() -> Header
pub fn new() -> Header
Creates a new Header instance with default values.
Examples found in repository?
examples/plotly_table.rs (line 6)
3fn main() {
4 let dataset = CsvReader::new("data/employee_data.csv").finish().unwrap();
5
6 let header = Header::new()
7 .values(vec![
8 "Employee Name",
9 "Department",
10 "Annual Salary ($)",
11 "Years of Service",
12 ])
13 .align("center")
14 .font("Arial Black")
15 .fill(Rgb(70, 130, 180));
16
17 let cell = Cell::new()
18 .align("center")
19 .height(25.0)
20 .fill(Rgb(240, 248, 255));
21
22 Table::builder()
23 .data(&dataset)
24 .columns(vec!["name", "department", "salary", "years"])
25 .header(&header)
26 .cell(&cell)
27 .plot_title(
28 Text::from("Employee Data")
29 .font("Arial")
30 .size(20)
31 .color(Rgb(25, 25, 112)),
32 )
33 .build()
34 .plot();
35}Sourcepub fn values(self, values: Vec<&str>) -> Header
pub fn values(self, values: Vec<&str>) -> Header
Sets custom header values.
§Argument
values- A vector of string slices representing custom header names.
Examples found in repository?
examples/plotly_table.rs (lines 7-12)
3fn main() {
4 let dataset = CsvReader::new("data/employee_data.csv").finish().unwrap();
5
6 let header = Header::new()
7 .values(vec![
8 "Employee Name",
9 "Department",
10 "Annual Salary ($)",
11 "Years of Service",
12 ])
13 .align("center")
14 .font("Arial Black")
15 .fill(Rgb(70, 130, 180));
16
17 let cell = Cell::new()
18 .align("center")
19 .height(25.0)
20 .fill(Rgb(240, 248, 255));
21
22 Table::builder()
23 .data(&dataset)
24 .columns(vec!["name", "department", "salary", "years"])
25 .header(&header)
26 .cell(&cell)
27 .plot_title(
28 Text::from("Employee Data")
29 .font("Arial")
30 .size(20)
31 .color(Rgb(25, 25, 112)),
32 )
33 .build()
34 .plot();
35}Sourcepub fn align(self, align: impl Into<String>) -> Header
pub fn align(self, align: impl Into<String>) -> Header
Sets the alignment of the header text.
§Argument
align- A string specifying the alignment (left, center, right).
Examples found in repository?
examples/plotly_table.rs (line 13)
3fn main() {
4 let dataset = CsvReader::new("data/employee_data.csv").finish().unwrap();
5
6 let header = Header::new()
7 .values(vec![
8 "Employee Name",
9 "Department",
10 "Annual Salary ($)",
11 "Years of Service",
12 ])
13 .align("center")
14 .font("Arial Black")
15 .fill(Rgb(70, 130, 180));
16
17 let cell = Cell::new()
18 .align("center")
19 .height(25.0)
20 .fill(Rgb(240, 248, 255));
21
22 Table::builder()
23 .data(&dataset)
24 .columns(vec!["name", "department", "salary", "years"])
25 .header(&header)
26 .cell(&cell)
27 .plot_title(
28 Text::from("Employee Data")
29 .font("Arial")
30 .size(20)
31 .color(Rgb(25, 25, 112)),
32 )
33 .build()
34 .plot();
35}Sourcepub fn font(self, font: &str) -> Header
pub fn font(self, font: &str) -> Header
Sets the font family of the header text.
§Argument
font- A string slice specifying the font family name.
Examples found in repository?
examples/plotly_table.rs (line 14)
3fn main() {
4 let dataset = CsvReader::new("data/employee_data.csv").finish().unwrap();
5
6 let header = Header::new()
7 .values(vec![
8 "Employee Name",
9 "Department",
10 "Annual Salary ($)",
11 "Years of Service",
12 ])
13 .align("center")
14 .font("Arial Black")
15 .fill(Rgb(70, 130, 180));
16
17 let cell = Cell::new()
18 .align("center")
19 .height(25.0)
20 .fill(Rgb(240, 248, 255));
21
22 Table::builder()
23 .data(&dataset)
24 .columns(vec!["name", "department", "salary", "years"])
25 .header(&header)
26 .cell(&cell)
27 .plot_title(
28 Text::from("Employee Data")
29 .font("Arial")
30 .size(20)
31 .color(Rgb(25, 25, 112)),
32 )
33 .build()
34 .plot();
35}Sourcepub fn fill(self, fill: Rgb) -> Header
pub fn fill(self, fill: Rgb) -> Header
Examples found in repository?
examples/plotly_table.rs (line 15)
3fn main() {
4 let dataset = CsvReader::new("data/employee_data.csv").finish().unwrap();
5
6 let header = Header::new()
7 .values(vec![
8 "Employee Name",
9 "Department",
10 "Annual Salary ($)",
11 "Years of Service",
12 ])
13 .align("center")
14 .font("Arial Black")
15 .fill(Rgb(70, 130, 180));
16
17 let cell = Cell::new()
18 .align("center")
19 .height(25.0)
20 .fill(Rgb(240, 248, 255));
21
22 Table::builder()
23 .data(&dataset)
24 .columns(vec!["name", "department", "salary", "years"])
25 .header(&header)
26 .cell(&cell)
27 .plot_title(
28 Text::from("Employee Data")
29 .font("Arial")
30 .size(20)
31 .color(Rgb(25, 25, 112)),
32 )
33 .build()
34 .plot();
35}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnsafeUnpin for Header
impl UnwindSafe for Header
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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,
impl<T> PlanCallbackArgs for T
impl<T> PlanCallbackOut for T
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,
impl<T> Read<Exclusive, BecauseExclusive> 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().