[widgets] Fix a bug in chart layout

This commit is contained in:
Florian Dehau 2017-10-14 21:31:51 +02:00
parent cb8af88adf
commit 5dd03d91ad

View File

@ -274,8 +274,16 @@ where
y -= 1;
}
if let Some(labels) = self.y_axis.labels {
let max_width = labels.iter().fold(0, |acc, l| max(l.as_ref().width(), acc)) as u16;
if let Some(y_labels) = self.y_axis.labels {
let mut max_width = y_labels.iter().fold(
0,
|acc, l| max(l.as_ref().width(), acc),
) as u16;
if let Some(x_labels) = self.x_axis.labels {
if x_labels.len() > 0 {
max_width = max(max_width, x_labels[0].as_ref().width() as u16);
}
}
if x + max_width < area.right() {
layout.label_y = Some(x);
x += max_width;