mirror of
https://github.com/danog/ytop.git
synced 2024-11-30 04:29:10 +01:00
Implement linechart horizontal scale
This commit is contained in:
parent
3a44986be1
commit
7971d05fc6
@ -15,6 +15,8 @@ pub struct BatteryWidget<'a> {
|
||||
update_interval: Ratio<u64>,
|
||||
colorscheme: &'a Colorscheme,
|
||||
|
||||
horizontal_scale: u64,
|
||||
|
||||
update_count: u64,
|
||||
battery_data: HashMap<String, Vec<(f64, f64)>>,
|
||||
manager: Manager,
|
||||
@ -27,6 +29,8 @@ impl BatteryWidget<'_> {
|
||||
update_interval: Ratio::from_integer(60),
|
||||
colorscheme,
|
||||
|
||||
horizontal_scale: 50,
|
||||
|
||||
update_count: 0,
|
||||
battery_data: HashMap::new(),
|
||||
manager: Manager::new().unwrap(),
|
||||
@ -83,7 +87,7 @@ impl Widget for BatteryWidget<'_> {
|
||||
Chart::<String, String>::default()
|
||||
.block(block::new(self.colorscheme, &self.title))
|
||||
.x_axis(Axis::default().bounds([
|
||||
self.update_count as f64 - 100.0,
|
||||
self.update_count as f64 - self.horizontal_scale as f64,
|
||||
self.update_count as f64 + 1.0,
|
||||
]))
|
||||
.y_axis(Axis::default().bounds([0.0, 100.0]))
|
||||
|
@ -13,8 +13,9 @@ pub struct CpuWidget<'a> {
|
||||
update_interval: Ratio<u64>,
|
||||
colorscheme: &'a Colorscheme,
|
||||
|
||||
horizontal_scale: u64,
|
||||
|
||||
update_count: u64,
|
||||
horizontal_scale: i64,
|
||||
|
||||
cpu_count: usize,
|
||||
|
||||
@ -127,7 +128,7 @@ impl Widget for CpuWidget<'_> {
|
||||
Chart::<String, String>::default()
|
||||
.block(block::new(self.colorscheme, &self.title))
|
||||
.x_axis(Axis::default().bounds([
|
||||
self.update_count as f64 - 100.0,
|
||||
self.update_count as f64 - self.horizontal_scale as f64,
|
||||
self.update_count as f64 + 1.0,
|
||||
]))
|
||||
.y_axis(Axis::default().bounds([0.0, 100.0]))
|
||||
|
@ -21,6 +21,8 @@ pub struct MemWidget<'a> {
|
||||
update_interval: Ratio<u64>,
|
||||
colorscheme: &'a Colorscheme,
|
||||
|
||||
horizontal_scale: u64,
|
||||
|
||||
update_count: u64,
|
||||
|
||||
main: MemData,
|
||||
@ -42,6 +44,8 @@ impl MemWidget<'_> {
|
||||
update_interval,
|
||||
colorscheme,
|
||||
|
||||
horizontal_scale: 100,
|
||||
|
||||
update_count,
|
||||
|
||||
main,
|
||||
@ -80,7 +84,7 @@ impl Widget for MemWidget<'_> {
|
||||
Chart::<String, String>::default()
|
||||
.block(block::new(self.colorscheme, &self.title))
|
||||
.x_axis(Axis::default().bounds([
|
||||
self.update_count as f64 - 100.0,
|
||||
self.update_count as f64 - self.horizontal_scale as f64,
|
||||
self.update_count as f64 + 1.0,
|
||||
]))
|
||||
.y_axis(Axis::default().bounds([0.0, 100.0]))
|
||||
|
Loading…
Reference in New Issue
Block a user