fix: go to 0 and disappear to not overlap

This commit is contained in:
əlemi 2023-11-21 03:41:07 +01:00
parent 49fb01178c
commit ccaa41703d
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -32,7 +32,7 @@ pub fn display(
let authors : HashSet<String> = commits.values().map(|(_t, c)| crate::author_display(c, false)).collect();
let mut authors_data : HashMap<String,Vec<(f64, f64)>> = HashMap::new();
for author in authors {
authors_data.insert(author, vec![(0f64, 0f64); bins + 1]);
authors_data.insert(author, vec![(0f64, -1.0f64); bins + 1]);
}
let mut y_max = 0.;
@ -43,6 +43,9 @@ pub fn display(
y_max = data[bin].1;
}
if let Some(x) = authors_data.get_mut(&crate::author_display(c, false)) {
if x[bin].1 < 0. { x[bin].1 = 0. };
if bin > 0 && x[bin-1].1 < 0. { x[bin-1].1 = 0. };
if bin < x.len() - 1 && x[bin+1].1 < 0. { x[bin+1].1 = 0. };
x[bin].1 += 1.;
}
}
@ -107,7 +110,7 @@ pub fn display(
.y_axis(Axis::default()
.title(Span::styled("Y Axis", Style::default().fg(Color::Cyan)))
.style(Style::default().fg(Color::White))
.bounds([-0.1, y_max + 0.1])
.bounds([-0.0, y_max + 1.])
.labels(y_labels.iter().map(Span::from).collect())
);