Fix bug with network legend
This commit is contained in:
parent
207444fbbf
commit
90e1e9f4cb
|
@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- `"processes"`
|
- `"processes"`
|
||||||
- `"temperature"`
|
- `"temperature"`
|
||||||
|
|
||||||
|
- Removed an (undocumented) feature in allowing modifying total RX/TX colours. This is mainly due to the legend change.
|
||||||
|
|
||||||
- [#117](https://github.com/ClementTsang/bottom/issues/117): Update tui to 0.9:
|
- [#117](https://github.com/ClementTsang/bottom/issues/117): Update tui to 0.9:
|
||||||
|
|
||||||
- Use custom legend-hiding to stop hiding legends for memory and network widgets.
|
- Use custom legend-hiding to stop hiding legends for memory and network widgets.
|
||||||
|
|
|
@ -347,6 +347,7 @@ impl Painter {
|
||||||
app_state,
|
app_state,
|
||||||
rect[0],
|
rect[0],
|
||||||
app_state.current_widget.widget_id,
|
app_state.current_widget.widget_id,
|
||||||
|
false,
|
||||||
),
|
),
|
||||||
Proc => self.draw_process_and_search(
|
Proc => self.draw_process_and_search(
|
||||||
&mut f,
|
&mut f,
|
||||||
|
|
|
@ -43,8 +43,8 @@ impl Default for CanvasColours {
|
||||||
swap_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
swap_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
||||||
rx_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
rx_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
||||||
tx_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
tx_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
||||||
total_rx_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
total_rx_style: Style::default().fg(STANDARD_THIRD_COLOUR),
|
||||||
total_tx_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
total_tx_style: Style::default().fg(STANDARD_FOURTH_COLOUR),
|
||||||
avg_colour_style: Style::default().fg(AVG_COLOUR),
|
avg_colour_style: Style::default().fg(AVG_COLOUR),
|
||||||
cpu_colour_styles: Vec::new(),
|
cpu_colour_styles: Vec::new(),
|
||||||
border_style: Style::default().fg(text_colour),
|
border_style: Style::default().fg(text_colour),
|
||||||
|
|
|
@ -31,6 +31,7 @@ pub trait NetworkGraphWidget {
|
||||||
|
|
||||||
fn draw_network_graph<B: Backend>(
|
fn draw_network_graph<B: Backend>(
|
||||||
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
||||||
|
hide_legend: bool,
|
||||||
);
|
);
|
||||||
|
|
||||||
fn draw_network_labels<B: Backend>(
|
fn draw_network_labels<B: Backend>(
|
||||||
|
@ -55,15 +56,16 @@ impl NetworkGraphWidget for Painter {
|
||||||
)
|
)
|
||||||
.split(draw_loc);
|
.split(draw_loc);
|
||||||
|
|
||||||
self.draw_network_graph(f, app_state, network_chunk[0], widget_id);
|
self.draw_network_graph(f, app_state, network_chunk[0], widget_id, true);
|
||||||
self.draw_network_labels(f, app_state, network_chunk[1], widget_id);
|
self.draw_network_labels(f, app_state, network_chunk[1], widget_id);
|
||||||
} else {
|
} else {
|
||||||
self.draw_network_graph(f, app_state, draw_loc, widget_id);
|
self.draw_network_graph(f, app_state, draw_loc, widget_id, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_network_graph<B: Backend>(
|
fn draw_network_graph<B: Backend>(
|
||||||
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
&self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64,
|
||||||
|
hide_legend: bool,
|
||||||
) {
|
) {
|
||||||
if let Some(network_widget_state) = app_state.net_state.widget_states.get_mut(&widget_id) {
|
if let Some(network_widget_state) = app_state.net_state.widget_states.get_mut(&widget_id) {
|
||||||
let network_data_rx: &[(f64, f64)] = &app_state.canvas_data.network_data_rx;
|
let network_data_rx: &[(f64, f64)] = &app_state.canvas_data.network_data_rx;
|
||||||
|
@ -123,12 +125,68 @@ impl NetworkGraphWidget for Painter {
|
||||||
" Network ".to_string()
|
" Network ".to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
let legend_constraints = if app_state.app_config_fields.use_old_network_legend {
|
let legend_constraints = if hide_legend {
|
||||||
(Constraint::Ratio(0, 1), Constraint::Ratio(0, 1))
|
(Constraint::Ratio(0, 1), Constraint::Ratio(0, 1))
|
||||||
} else {
|
} else {
|
||||||
(Constraint::Ratio(3, 4), Constraint::Ratio(3, 4))
|
(Constraint::Ratio(3, 4), Constraint::Ratio(3, 4))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let dataset = if app_state.app_config_fields.use_old_network_legend && !hide_legend {
|
||||||
|
vec![
|
||||||
|
Dataset::default()
|
||||||
|
.name(format!("RX: {:7}", app_state.canvas_data.rx_display))
|
||||||
|
.marker(if app_state.app_config_fields.use_dot {
|
||||||
|
Marker::Dot
|
||||||
|
} else {
|
||||||
|
Marker::Braille
|
||||||
|
})
|
||||||
|
.style(self.colours.rx_style)
|
||||||
|
.data(&network_data_rx),
|
||||||
|
Dataset::default()
|
||||||
|
.name(format!("TX: {:7}", app_state.canvas_data.tx_display))
|
||||||
|
.marker(if app_state.app_config_fields.use_dot {
|
||||||
|
Marker::Dot
|
||||||
|
} else {
|
||||||
|
Marker::Braille
|
||||||
|
})
|
||||||
|
.style(self.colours.tx_style)
|
||||||
|
.data(&network_data_tx),
|
||||||
|
Dataset::default()
|
||||||
|
.name(format!(
|
||||||
|
"Total RX: {:7}",
|
||||||
|
app_state.canvas_data.total_rx_display
|
||||||
|
))
|
||||||
|
.style(self.colours.total_rx_style),
|
||||||
|
Dataset::default()
|
||||||
|
.name(format!(
|
||||||
|
"Total TX: {:7}",
|
||||||
|
app_state.canvas_data.total_tx_display
|
||||||
|
))
|
||||||
|
.style(self.colours.total_tx_style),
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
vec![
|
||||||
|
Dataset::default()
|
||||||
|
.name(&app_state.canvas_data.rx_display)
|
||||||
|
.marker(if app_state.app_config_fields.use_dot {
|
||||||
|
Marker::Dot
|
||||||
|
} else {
|
||||||
|
Marker::Braille
|
||||||
|
})
|
||||||
|
.style(self.colours.rx_style)
|
||||||
|
.data(&network_data_rx),
|
||||||
|
Dataset::default()
|
||||||
|
.name(&app_state.canvas_data.tx_display)
|
||||||
|
.marker(if app_state.app_config_fields.use_dot {
|
||||||
|
Marker::Dot
|
||||||
|
} else {
|
||||||
|
Marker::Braille
|
||||||
|
})
|
||||||
|
.style(self.colours.tx_style)
|
||||||
|
.data(&network_data_tx),
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
f.render_widget(
|
f.render_widget(
|
||||||
Chart::default()
|
Chart::default()
|
||||||
.block(
|
.block(
|
||||||
|
@ -148,26 +206,7 @@ impl NetworkGraphWidget for Painter {
|
||||||
)
|
)
|
||||||
.x_axis(x_axis)
|
.x_axis(x_axis)
|
||||||
.y_axis(y_axis)
|
.y_axis(y_axis)
|
||||||
.datasets(&[
|
.datasets(&dataset)
|
||||||
Dataset::default()
|
|
||||||
.name(&app_state.canvas_data.rx_display)
|
|
||||||
.marker(if app_state.app_config_fields.use_dot {
|
|
||||||
Marker::Dot
|
|
||||||
} else {
|
|
||||||
Marker::Braille
|
|
||||||
})
|
|
||||||
.style(self.colours.rx_style)
|
|
||||||
.data(&network_data_rx),
|
|
||||||
Dataset::default()
|
|
||||||
.name(&app_state.canvas_data.tx_display)
|
|
||||||
.marker(if app_state.app_config_fields.use_dot {
|
|
||||||
Marker::Dot
|
|
||||||
} else {
|
|
||||||
Marker::Braille
|
|
||||||
})
|
|
||||||
.style(self.colours.tx_style)
|
|
||||||
.data(&network_data_tx),
|
|
||||||
])
|
|
||||||
.hidden_legend_constraints(legend_constraints),
|
.hidden_legend_constraints(legend_constraints),
|
||||||
draw_loc,
|
draw_loc,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue