Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/scripts/build-book-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ BOOK_EXAMPLES=(
"statistical_charts"
"subplots"
"themes"
"downsampling"
)

# Build each example
Expand Down
26 changes: 23 additions & 3 deletions examples/basic_charts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ use plotly::{
TicksDirection, TraceOrder,
},
sankey::{Line as SankeyLine, Link, Node},
traces::table::{Cells, Header},
traces::table::{
Align as TableAlign, Cells, Fill as TableFill, Font as TableFont, Header, Line as TableLine,
},
Bar, Pie, Plot, Sankey, Scatter, ScatterPolar, Table,
};
use plotly_utils::write_example_to_html;
Expand Down Expand Up @@ -878,8 +880,26 @@ fn custom_node_sankey_diagram(show: bool, file_name: &str) {
// ANCHOR: table_chart
fn table_chart(show: bool, file_name: &str) {
let trace = Table::new(
Header::new(vec![String::from("col1"), String::from("col2")]),
Cells::new(vec![vec![1, 2], vec![2, 3]]),
Header::new(vec![String::from("col1"), String::from("col2")])
.font(TableFont::new().color_array(vec![NamedColor::Black, NamedColor::Blue]))
.align_array(vec![TableAlign::Left, TableAlign::Right]),
Cells::new(vec![vec![1, 2], vec![2, 3]])
.align_matrix(vec![
vec![TableAlign::Left, TableAlign::Right],
vec![TableAlign::Right, TableAlign::Left],
])
.fill(TableFill::new().color_matrix(vec![
vec![NamedColor::LightBlue, NamedColor::LightCoral],
vec![NamedColor::LightGreen, NamedColor::LightYellow],
]))
.line(
TableLine::new()
.color_matrix(vec![
vec![NamedColor::Black, NamedColor::Blue],
vec![NamedColor::Green, NamedColor::Yellow],
])
.width_matrix(vec![vec![2.5, 3.3], vec![4.5, 5.3]]),
),
);
let mut plot = Plot::new();
plot.add_trace(trace);
Expand Down
Loading
Loading