Skip to content

Commit 55d5402

Browse files
authored
refactor: small time series graph refactor (#2060)
Just a quick refactor.
1 parent 2c7c6c2 commit 55d5402

7 files changed

Lines changed: 11 additions & 13 deletions

File tree

docs/content/usage/widgets/temperature-graph.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ Note that key bindings are generally case-sensitive.
2626
| Binding | Action |
2727
| ------------ | -------------------------------------------------------------- |
2828
| ++"Scroll"++ | Scrolling up or down zooms in or out of the graph respectively |
29+
30+
<!--TODO: Add screenshots of widgets -->

src/app/data/time_series.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ pub struct TimeSeriesData {
6262
pub gpu_mem: HashMap<String, Values>,
6363

6464
/// Temperature data.
65+
///
66+
/// TODO: Maybe make this use TypedTemperature?
6567
pub temperature: HashMap<String, ChunkedData<f32>>,
6668
}
6769

File renamed without changes.

src/components/time_series.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,15 @@ pub struct TimeseriesState {
3434
}
3535

3636
impl TimeseriesState {
37-
/// Create a new [`TimeseriesState`] using the given config.
38-
pub fn new(config: TimeseriesConfig) -> Self {
37+
/// Create a new [`TimeseriesState`] using the given config and `autohide_timer` setting.
38+
pub fn new(config: TimeseriesConfig, autohide_timer: Option<Instant>) -> Self {
3939
Self {
4040
current_display_time: config.default_time_value,
4141
config,
42-
autohide_timer: None,
42+
autohide_timer,
4343
}
4444
}
4545

46-
/// Set the autohide timer.
47-
pub fn with_autohide_timer(mut self, autohide_timer: Option<Instant>) -> Self {
48-
self.autohide_timer = autohide_timer;
49-
self
50-
}
51-
5246
/// Get a mutable reference to the autohide timer.
5347
pub fn autohide_timer_mut(&mut self) -> &mut Option<Instant> {
5448
&mut self.autohide_timer

src/components/time_series/auto_y.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub struct AutoYAxisTimeGraph {
9999
impl AutoYAxisTimeGraph {
100100
pub(crate) fn new(config: TimeseriesConfig, autohide_timer: Option<Instant>) -> Self {
101101
AutoYAxisTimeGraph {
102-
state: TimeseriesState::new(config).with_autohide_timer(autohide_timer),
102+
state: TimeseriesState::new(config, autohide_timer),
103103
height_cache: GraphHeightCache::default(),
104104
}
105105
}

src/components/time_series/percent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ use super::{
77
};
88

99
/// A time series graph that expects data to be in a percentage format,
10-
/// from 0.0 to 100.0.
10+
/// from 0% to 100%.
1111
pub struct PercentTimeGraph {
1212
state: TimeseriesState,
1313
}
1414

1515
impl PercentTimeGraph {
1616
pub(crate) fn new(config: TimeseriesConfig, autohide_timer: Option<Instant>) -> Self {
1717
PercentTimeGraph {
18-
state: TimeseriesState::new(config).with_autohide_timer(autohide_timer),
18+
state: TimeseriesState::new(config, autohide_timer),
1919
}
2020
}
2121

src/options/config/flags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub(crate) struct GeneralConfig {
5353
pub(crate) disable_click: Option<bool>,
5454
pub(crate) disable_keys: Option<bool>,
5555
pub(crate) no_write: Option<bool>,
56-
pub(crate) network_legend: Option<String>,
56+
pub(crate) network_legend: Option<String>, // TODO: Migrate this to per-widget config
5757
pub(crate) memory_legend: Option<String>,
5858
pub(crate) process_memory_as_value: Option<bool>,
5959
pub(crate) tree: Option<bool>,

0 commit comments

Comments
 (0)