Switch to log scale for networks to allow a scale from 0 bytes to 1 GiB.

This commit is contained in:
ClementTsang 2019-12-14 00:13:29 -05:00
parent e11b9f299a
commit 8d648433f0
3 changed files with 6 additions and 6 deletions

View File

@ -346,8 +346,8 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu
let x_axis: Axis<String> = Axis::default().style(Style::default().fg(GRAPH_COLOUR)).bounds([0.0, 600_000.0]);
let y_axis = Axis::default()
.style(Style::default().fg(GRAPH_COLOUR))
.bounds([-0.5, 1_000_000.5])
.labels(&["0GB", "1GB"]);
.bounds([-0.5, 30_f64])
.labels(&["0B", "1KiB", "1MiB", "1GiB"]);
Chart::default()
.block(
Block::default()

View File

@ -251,13 +251,15 @@ pub fn convert_network_data_points(network_data: &[data_collection::network::Net
let current_time = std::time::Instant::now();
let rx_data = (
((TIME_STARTS_FROM as f64 - current_time.duration_since(data.instant).as_millis() as f64) * 10_f64).floor(),
data.rx as f64 / 1024.0,
if data.rx > 0 { (data.rx as f64).log(2.0) } else { 0.0 },
);
let tx_data = (
((TIME_STARTS_FROM as f64 - current_time.duration_since(data.instant).as_millis() as f64) * 10_f64).floor(),
data.tx as f64 / 1024.0,
if data.tx > 0 { (data.tx as f64).log(2.0) } else { 0.0 },
);
//debug!("Plotting: {:?} bytes rx, {:?} bytes tx", rx_data, tx_data);
// Now, inject our joining points...
if !rx.is_empty() {
let previous_element_data = *(rx.last().unwrap());

View File

@ -50,7 +50,6 @@ fn main() -> error::Result<()> {
(version: crate_version!())
(author: crate_authors!())
(about: crate_description!())
//(@arg THEME: -t --theme +takes_value "Sets a colour theme.")
(@arg AVG_CPU: -a --avgcpu "Enables showing the average CPU usage.")
(@arg DOT_MARKER: -m --dot_marker "Use a dot marker instead of the default braille marker. May be needed in things like Powershell.")
(@arg DEBUG: -d --debug "Enables debug mode.")
@ -61,7 +60,6 @@ fn main() -> error::Result<()> {
)
(@arg RATE_MILLIS: -r --rate +takes_value "Sets a refresh rate in milliseconds; the minimum is 250ms, defaults to 1000ms. Smaller values may take more resources.")
)
//.after_help("Themes:") // TODO: This and others disabled for now
.get_matches();
let update_rate_in_milliseconds: u128 = if matches.is_present("RATE_MILLIS") {