mirror of
https://github.com/fdehau/tui-rs.git
synced 2024-11-05 12:00:17 +00:00
avoid divide by zero
This commit is contained in:
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…
Reference in New Issue
Block a user