sparkline
Builds Sparkline


The code that drew it
A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.
fn sparkline(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
let points = [
SparklinePoint::new(0.0, 0.20),
SparklinePoint::new(0.14, 0.34),
SparklinePoint::new(0.28, 0.29),
SparklinePoint::new(0.42, 0.56),
SparklinePoint::new(0.57, 0.48),
SparklinePoint::new(0.71, 0.74),
SparklinePoint::new(0.85, 0.66),
SparklinePoint::new(1.0, 0.82),
];
stack(&theme)
.w(px(520.0))
.child(caption(
&theme,
"normalized geometry with caller-formatted current, minimum and maximum",
))
.child(Sparkline::new(
"scene.sparkline.rate",
"Fixture throughput",
SparklineState::Ready(SparklineReading::new(
points, "82 req/s", "20 req/s", "82 req/s",
)),
))
.child(Sparkline::new(
"scene.sparkline.stale",
"Fixture queue depth",
SparklineState::Stale {
reading: SparklineReading::new(points, "34 jobs", "8 jobs", "41 jobs"),
reason: "The latest sample is unavailable; the verified reading remains.".into(),
},
))
.into_any_element()
}