Skip to content

Commit b403db3

Browse files
committed
Added ability to set labels and margins
1 parent 5c0f3a5 commit b403db3

File tree

7 files changed

+699
-104
lines changed

7 files changed

+699
-104
lines changed

examples/layout.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
99
root.fill(&full_palette::WHITE)?;
1010

1111
let mut chart = ChartLayout::new(&root);
12-
chart.set_title_text("Chart Title")?.draw()?;
12+
chart
13+
.set_chart_title_text("Chart Title")?
14+
.set_top_label_text("A label at the top")?
15+
.set_chart_title_style(("serif", 60.).into_font().with_color(&RED))?
16+
.set_left_label_text("Left label")?
17+
.set_right_label_text("Right label")?
18+
.set_bottom_label_text("Bottom label")?
19+
.set_bottom_label_margin(10.)?
20+
.set_top_label_margin(10.)?
21+
.draw()?;
22+
23+
let extent = chart.get_chart_area_extent()?;
24+
root.draw(&Rectangle::new(extent.into_array_of_tuples(), &BLUE))?;
25+
let extent = chart.get_chart_title_extent()?;
26+
root.draw(&Rectangle::new(extent.into_array_of_tuples(), &BLUE))?;
27+
//dbg!();
1328

1429
Ok(())
1530
}

0 commit comments

Comments
 (0)