mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
fix: avoid crashing history graph on empty plot with throttling data
This commit is contained in:
parent
204dcb47fc
commit
4a35ffbde1
@ -105,7 +105,7 @@ impl PlotData {
|
||||
self.push_secondary_line_series_with_time(name, point, chrono::Local::now().naive_local());
|
||||
}
|
||||
|
||||
pub fn push_line_series_with_time(&mut self, name: &str, point: f64, time: NaiveDateTime) {
|
||||
fn push_line_series_with_time(&mut self, name: &str, point: f64, time: NaiveDateTime) {
|
||||
self.line_series
|
||||
.entry(name.to_owned())
|
||||
.or_default()
|
||||
@ -183,4 +183,8 @@ impl PlotData {
|
||||
self.throttling
|
||||
.retain(|(time_point, _)| ((maximum_point - *time_point) / 1000) < last_seconds);
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.line_series.is_empty() && self.secondary_line_series.is_empty()
|
||||
}
|
||||
}
|
||||
|
@ -293,6 +293,7 @@ impl RenderRequest {
|
||||
.context("Failed to draw mesh")?;
|
||||
|
||||
// Draw the throttling histogram as a series of bars.
|
||||
if !data.is_empty() {
|
||||
chart
|
||||
.draw_series(
|
||||
data.throttling_iter()
|
||||
@ -321,6 +322,7 @@ impl RenderRequest {
|
||||
}),
|
||||
)
|
||||
.context("Failed to draw throttling histogram")?;
|
||||
}
|
||||
|
||||
// Draw the main line series using cubic spline interpolation.
|
||||
for (idx, (caption, data)) in (0..).zip(data.line_series_iter()) {
|
||||
|
Loading…
Reference in New Issue
Block a user