mirror of
https://github.com/ClementTsang/bottom.git
synced 2026-08-25 04:46:40 +00:00
refactor: move around some files related to the time graphs (#1942)
* refactor: move around some files related to the time graphs * fmt * fmt again * update changelog * add docs for time_graph * rename time_graph to time_chart to be consistent * nvm, that just makes it more annoying * fmt * Update documentation comment for time_graph.rs * add extra rustdoc lint as well while I'm here
This commit is contained in:
+359
-186
File diff suppressed because it is too large
Load Diff
+6
-1
@@ -95,7 +95,11 @@ starship-battery = { version = "0.10.3", optional = true }
|
|||||||
sysinfo = "=0.37.2"
|
sysinfo = "=0.37.2"
|
||||||
timeless = "0.0.14-alpha"
|
timeless = "0.0.14-alpha"
|
||||||
toml_edit = { version = "0.24.0", features = ["serde"] }
|
toml_edit = { version = "0.24.0", features = ["serde"] }
|
||||||
tui = { version = "0.30.0", package = "ratatui", features = ["unstable-rendered-line-info", "layout-cache", "crossterm"] }
|
tui = { version = "0.30.0", package = "ratatui", features = [
|
||||||
|
"unstable-rendered-line-info",
|
||||||
|
"layout-cache",
|
||||||
|
"crossterm",
|
||||||
|
] }
|
||||||
unicode-ellipsis = "0.3.0"
|
unicode-ellipsis = "0.3.0"
|
||||||
unicode-segmentation = "1.12.0"
|
unicode-segmentation = "1.12.0"
|
||||||
unicode-width = "0.2.2"
|
unicode-width = "0.2.2"
|
||||||
@@ -249,6 +253,7 @@ rust_2018_idioms = "deny"
|
|||||||
|
|
||||||
[lints.rustdoc]
|
[lints.rustdoc]
|
||||||
broken_intra_doc_links = "deny"
|
broken_intra_doc_links = "deny"
|
||||||
|
private_intra_doc_links = "deny"
|
||||||
missing_crate_level_docs = "deny"
|
missing_crate_level_docs = "deny"
|
||||||
|
|
||||||
[lints.clippy]
|
[lints.clippy]
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
//! A graph displaying data in the y-axis over time in the x-axis.
|
||||||
|
//!
|
||||||
|
//! A "base" version is available, based on a vendored version of
|
||||||
|
//! ratatui's [charts](https://docs.rs/ratatui/latest/ratatui/widgets/struct.Chart.html),
|
||||||
|
//! as are variants for common use cases.
|
||||||
|
|
||||||
|
mod base;
|
||||||
|
mod variants;
|
||||||
|
mod vendored;
|
||||||
|
|
||||||
|
pub(crate) use base::*;
|
||||||
|
pub(crate) use variants::percent::PercentTimeGraph;
|
||||||
|
pub(crate) use vendored::*;
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
mod time_chart;
|
|
||||||
use std::{borrow::Cow, time::Instant};
|
use std::{borrow::Cow, time::Instant};
|
||||||
|
|
||||||
use concat_string::concat_string;
|
use concat_string::concat_string;
|
||||||
pub use time_chart::*;
|
|
||||||
use tui::{
|
use tui::{
|
||||||
Frame,
|
Frame,
|
||||||
layout::{Constraint, Rect},
|
layout::{Constraint, Rect},
|
||||||
@@ -12,6 +10,7 @@ use tui::{
|
|||||||
widgets::{BorderType, GraphType},
|
widgets::{BorderType, GraphType},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::canvas::components::time_graph::*;
|
||||||
use crate::{app::data::Values, canvas::drawing_utils::widget_block};
|
use crate::{app::data::Values, canvas::drawing_utils::widget_block};
|
||||||
|
|
||||||
/// Represents the data required by the [`TimeGraph`].
|
/// Represents the data required by the [`TimeGraph`].
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
mod base;
|
|
||||||
pub mod variants;
|
|
||||||
|
|
||||||
pub(crate) use base::*;
|
|
||||||
+2
-4
@@ -2,7 +2,7 @@
|
|||||||
//! right-aligned timeseries data.
|
//! right-aligned timeseries data.
|
||||||
//!
|
//!
|
||||||
//! Generally should be updated to be in sync with [`chart.rs`](https://github.com/ratatui-org/ratatui/blob/main/src/widgets/chart.rs);
|
//! Generally should be updated to be in sync with [`chart.rs`](https://github.com/ratatui-org/ratatui/blob/main/src/widgets/chart.rs);
|
||||||
//! the specializations are factored out to `time_chart/points.rs`.
|
//! the specializations are factored out to `time_graph/points.rs`.
|
||||||
|
|
||||||
mod canvas;
|
mod canvas;
|
||||||
mod grid;
|
mod grid;
|
||||||
@@ -410,10 +410,8 @@ impl ChartScaling {
|
|||||||
/// - Styling option for the legend box
|
/// - Styling option for the legend box
|
||||||
/// - Automatically trimming out redundant draws in the x-bounds.
|
/// - Automatically trimming out redundant draws in the x-bounds.
|
||||||
/// - Automatic interpolation to points that fall *just* outside of the screen.
|
/// - Automatic interpolation to points that fall *just* outside of the screen.
|
||||||
///
|
|
||||||
/// TODO: Support for putting the legend on the left side.
|
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct TimeChart<'a> {
|
pub(super) struct TimeChart<'a> {
|
||||||
/// A block to display around the widget eventually
|
/// A block to display around the widget eventually
|
||||||
block: Option<Block<'a>>,
|
block: Option<Block<'a>>,
|
||||||
/// The horizontal axis
|
/// The horizontal axis
|
||||||
+1
-1
@@ -112,7 +112,7 @@ mod test {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn time_chart_test_interpolation() {
|
fn time_graph_test_interpolation() {
|
||||||
let data = [(-3.0, 8.0), (-1.0, 6.0), (0.0, 5.0)];
|
let data = [(-3.0, 8.0), (-1.0, 6.0), (0.0, 5.0)];
|
||||||
|
|
||||||
assert_eq!(interpolate_point(&data[1], &data[2], 0.0), 5.0);
|
assert_eq!(interpolate_point(&data[1], &data[2], 0.0), 5.0);
|
||||||
@@ -9,7 +9,7 @@ use crate::{
|
|||||||
Painter,
|
Painter,
|
||||||
components::{
|
components::{
|
||||||
data_table::{DrawInfo, SelectionState},
|
data_table::{DrawInfo, SelectionState},
|
||||||
time_graph::{GraphData, variants::percent::PercentTimeGraph},
|
time_graph::{GraphData, PercentTimeGraph},
|
||||||
},
|
},
|
||||||
drawing_utils::should_hide_x_label,
|
drawing_utils::should_hide_x_label,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use crate::{
|
|||||||
app::{App, data::Values},
|
app::{App, data::Values},
|
||||||
canvas::{
|
canvas::{
|
||||||
Painter,
|
Painter,
|
||||||
components::time_graph::{GraphData, variants::percent::PercentTimeGraph},
|
components::time_graph::{GraphData, PercentTimeGraph},
|
||||||
drawing_utils::should_hide_x_label,
|
drawing_utils::should_hide_x_label,
|
||||||
},
|
},
|
||||||
collection::memory::MemData,
|
collection::memory::MemData,
|
||||||
|
|||||||
Reference in New Issue
Block a user