avoid divide by zero

pull/165/head
Russ 5 years ago committed by Florian Dehau
parent 25a0825ae4
commit f0e0b515ad

@ -133,7 +133,7 @@ impl<'a> Widget for BarChart<'a> {
.data
.iter()
.take(max_index)
.map(|&(l, v)| (l, v * u64::from(chart_area.height) * 8 / max))
.map(|&(l, v)| (l, v * u64::from(chart_area.height) * 8 / std::cmp::max(max, 1)))
.collect::<Vec<(&str, u64)>>();
for j in (0..chart_area.height - 1).rev() {
for (i, d) in data.iter_mut().enumerate() {

Loading…
Cancel
Save