1use plotters::{prelude::*, style::full_palette::ORANGE};
2
3const OUT_FILE_NAME: &'static str = "plotters-doc-data/pie-chart.png";
4fn main() -> Result<(), Box<dyn std::error::Error>> {
5 let root_area = BitMapBackend::new(&OUT_FILE_NAME, (950, 700)).into_drawing_area();
6 root_area.fill(&WHITE).unwrap();
7 let title_style = TextStyle::from(("sans-serif", 30).into_font()).color(&(BLACK));
8 root_area.titled("BEST CIRCLES", title_style).unwrap();
9
10 let dims = root_area.dim_in_pixel();
11 let center = (dims.0 as i32 / 2, dims.1 as i32 / 2);
12 let radius = 300.0;
13 let sizes = vec![66.0, 33.0];
14 let _rgba = RGBAColor(0, 50, 255, 1.0);
15 let colors = vec![RGBColor(0, 50, 255), CYAN];
16 let labels = vec!["Pizza", "Pacman"];
17
18 let mut pie = Pie::new(&center, &radius, &sizes, &colors, &labels);
19 pie.start_angle(66.0);
20 pie.label_style((("sans-serif", 50).into_font()).color(&(ORANGE)));
21 pie.percentages((("sans-serif", radius * 0.08).into_font()).color(&BLACK));
22 root_area.draw(&pie)?;
23
24 Ok(())
25}
26