1
0
mirror of https://github.com/danog/ytop.git synced 2024-11-30 04:29:10 +01:00

Add cpu graph labels

This commit is contained in:
Caleb Bassi 2020-01-10 14:46:54 -08:00
parent fe50e09966
commit de0b2358e6

View File

@ -114,5 +114,33 @@ impl Widget for CpuWidget {
.y_axis(Axis::default().bounds([0.0, 100.0]))
.datasets(&datasets)
.draw(area, buf);
if self.show_average {
buf.set_string(
area.x + 3,
area.y + 2,
format!(
"AVRG {:3.0}%",
self.average_data[self.update_count as usize - 1].1
),
Style::default().fg(Color::Yellow),
);
}
if self.show_percpu {
let offset = if self.show_average { 1 } else { 0 };
for i in 0..self.cpu_count {
buf.set_string(
area.x + 3,
area.y + 2 + offset + i as u16,
format!(
"CPU{} {:3.0}%",
i,
self.percpu_data[i][self.update_count as usize - 1].1
),
Style::default().fg(Color::Yellow),
);
}
}
}
}