This commit is contained in:
Simon Gardling 2022-02-14 09:58:43 -05:00
parent 918bae6bec
commit 544989e4b2
2 changed files with 6 additions and 6 deletions

View File

@ -49,7 +49,7 @@ pub fn draw(
root.present()?;
let output = chart.into_coord_trans();
return Ok((output, area));
Ok((output, area))
}
// Creates and does the math for creating all the rectangles under the graph
@ -83,5 +83,5 @@ fn integral_rectangles(
.filter(|ele| ele != &(0.0, 0.0, 0.0))
.collect();
let area: f32 = data2.iter().map(|(_, _, y)| y * step).sum(); // sum of all rectangles' areas
return (data2, area);
(data2, area)
}

View File

@ -44,13 +44,13 @@ impl Chart {
.map_err(|err| err.to_string())?;
let map_coord = draw_output.0;
return Ok(Chart {
convert: Box::new(move |coord| map_coord(coord).map(|(x, y)| (x.into(), y.into()))),
Ok(Chart {
convert: Box::new(move |coord| map_coord(coord).map(|(x, y)| (x, y))),
area: draw_output.1,
});
})
}
pub fn get_area(&self) -> f32 { return self.area; }
pub fn get_area(&self) -> f32 { self.area }
pub fn coord(&self, x: i32, y: i32) -> Option<Point> {
(self.convert)((x, y)).map(|(x, y)| Point::new(x, y))