Stack the element with the labels on the bottom and left.
(
widget: impl Into<Element<'a, M>>,
x_label: &'a str,
y_label: &'a str,
axis_label_size: f32,
axis_label_color: Color,
)
| 5 | |
| 6 | /// Stack the element with the labels on the bottom and left. |
| 7 | pub(crate) fn stack_with_labels<'a, M: 'a>( |
| 8 | widget: impl Into<Element<'a, M>>, |
| 9 | x_label: &'a str, |
| 10 | y_label: &'a str, |
| 11 | axis_label_size: f32, |
| 12 | axis_label_color: Color, |
| 13 | ) -> Element<'a, M> { |
| 14 | if x_label.is_empty() && y_label.is_empty() { |
| 15 | widget.into() |
| 16 | } else if x_label.is_empty() { |
| 17 | row![ |
| 18 | y_axis_label(y_label, axis_label_size, axis_label_color), |
| 19 | widget.into() |
| 20 | ] |
| 21 | .into() |
| 22 | } else if y_label.is_empty() { |
| 23 | column![ |
| 24 | widget.into(), |
| 25 | x_axis_label(x_label, axis_label_size, axis_label_color) |
| 26 | ] |
| 27 | .into() |
| 28 | } else { |
| 29 | row![ |
| 30 | y_axis_label(y_label, axis_label_size, axis_label_color), |
| 31 | column![ |
| 32 | widget.into(), |
| 33 | x_axis_label(x_label, axis_label_size, axis_label_color) |
| 34 | ] |
| 35 | ] |
| 36 | .into() |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | fn x_axis_label<'a, M: 'a>(label: &'a str, size: f32, color: Color) -> Element<'a, M> { |
| 41 | container(text(label).size(size).color(color)) |
no test coverage detected