Compare commits
1 changed files with 2 additions and 2 deletions
|
|
@ -27,7 +27,7 @@ impl Graph {
|
||||||
|
|
||||||
pub fn update(&mut self, value: f32) {
|
pub fn update(&mut self, value: f32) {
|
||||||
self.timeline.push_back(value);
|
self.timeline.push_back(value);
|
||||||
if self.timeline.len() > 500 {
|
if self.timeline.len() > 1000 {
|
||||||
self.timeline.pop_front();
|
self.timeline.pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +53,7 @@ impl canvas::Program<app::Message, Theme, Renderer> for Graph {
|
||||||
&canvas::Path::new(|builder| {
|
&canvas::Path::new(|builder| {
|
||||||
for (index, value) in self.timeline.iter().enumerate() {
|
for (index, value) in self.timeline.iter().enumerate() {
|
||||||
let x = index as f32 / self.timeline.len() as f32 * bounds.width;
|
let x = index as f32 / self.timeline.len() as f32 * bounds.width;
|
||||||
let y = bounds.height - value / 100. * bounds.height - 1.;
|
let y = bounds.height - value / 100. * bounds.height;
|
||||||
builder.line_to(Point::new(x, y))
|
builder.line_to(Point::new(x, y))
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue