table/
table.rs

1use polars::prelude::*;
2
3use plotlars::{Cell, Header, Plot, Rgb, Table, Text};
4
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}