Skip to content

Commit 3d608e1

Browse files
committed
optimize examples
1 parent b18153d commit 3d608e1

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

examples/cpu-monitor.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ use iced::{
2121
use plotters::prelude::ChartBuilder;
2222
use plotters_backend::DrawingBackend;
2323
use plotters_iced::{Chart, ChartWidget, Renderer};
24-
use std::collections::VecDeque;
25-
use std::time::{Duration, Instant};
24+
use std::{
25+
collections::VecDeque,
26+
time::{Duration, Instant},
27+
};
2628
use sysinfo::{CpuExt, CpuRefreshKind, RefreshKind, System, SystemExt};
2729

2830
const PLOT_SECONDS: usize = 60; //1 min
@@ -250,14 +252,7 @@ impl CpuUsageChart {
250252
.height(Length::Fill)
251253
.spacing(5)
252254
.push(Text::new(format!("Processor {}", idx)))
253-
.push(
254-
ChartWidget::new(self).height(Length::Fill), // .resolve_font(
255-
// |_, style| match style {
256-
// plotters_backend::FontStyle::Bold => FONT_BOLD,
257-
// _ => FONT_REGULAR,
258-
// },
259-
// ),
260-
),
255+
.push(ChartWidget::new(self).height(Length::Fill)),
261256
)
262257
.width(Length::Fill)
263258
.height(Length::Fill)

examples/split-chart/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extern crate plotters;
2626
use iced::{
2727
executor,
2828
widget::{Column, Container, Text},
29-
Alignment, Application, Command, Element, Length, Settings, Subscription, Theme,
29+
window, Alignment, Application, Command, Element, Length, Settings, Subscription, Theme,
3030
};
3131
use plotters::{coord::Shift, prelude::*};
3232
use plotters_backend::DrawingBackend;
@@ -97,8 +97,7 @@ impl Application for State {
9797
}
9898

9999
fn subscription(&self) -> Subscription<Self::Message> {
100-
use std::time::Duration;
101-
iced::time::every(Duration::from_millis(500)).map(|_| Message::Tick)
100+
window::frames().map(|_| Message::Tick)
102101
}
103102
}
104103

0 commit comments

Comments
 (0)