From 1b65fa022a1a370b035adb5eebd256760274b1ba Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Wed, 15 Jan 2020 00:38:43 -0500 Subject: [PATCH] Added some logic to allow visibility of network data even when smaller height windows are used --- src/canvas.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/canvas.rs b/src/canvas.rs index 823c17b1..1352b1cd 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -319,10 +319,25 @@ pub fn draw_data( ) .split(vertical_chunks[0]); + debug!("Height: {}", bottom_chunks[0].height); let network_chunk = Layout::default() .direction(Direction::Vertical) .margin(0) - .constraints([Constraint::Percentage(75), Constraint::Percentage(25)].as_ref()) + .constraints( + if (bottom_chunks[0].height as f64 * 0.25) as u16 >= 4 { + [Constraint::Percentage(75), Constraint::Percentage(25)] + } else { + let required = if bottom_chunks[0].height < 10 { + bottom_chunks[0].height / 2 + } else { + 5 + }; + debug!("Req: {}", required); + let remaining = bottom_chunks[0].height - required; + [Constraint::Length(remaining), Constraint::Length(required)] + } + .as_ref(), + ) .split(bottom_chunks[0]); // Default chunk index based on left or right legend setting