Components / display
ContinuousHeatmap builder
A raw-valued matrix with visible cell values and a numeric color legend. Selection is caller controlled. Invalid coordinates, identities, and readings produce an explicit error; a stale refresh retains verified cells and reason.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::display::heatmap::ContinuousHeatmap;
Reviewed in continuous-heatmap-transition heatmap-reordering continuous-heatmap.
Construct
new(ident: impl Into<Ident>, label: impl Into<SharedString>, scale: HeatColorScale, state: super::plot::PlotState<Vec<ContinuousHeatCell>>) -> Self
Options
Chain onto the value.
motion(enabled: bool) -> Self
animate(enabled: bool) -> Self
animation(spec: crate::motion::MotionSpec) -> Self
rows(rows: impl IntoIterator<Item = impl Into<HeatAxis>>) -> Self
columns(columns: impl IntoIterator<Item = impl Into<HeatAxis>>) -> Self
current(id: impl Into<SharedString>) -> Self
on_current(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
Example · continuous-heatmap-transition
fn continuous_heatmap_transition(window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
let revision = crate::motion::keyed::slot::<usize>(
&"scene.heat.transition-state".into(),
window.window_handle().window_id(),
cx,
);
let value = match *revision.borrow() % 3 {
0 => Some(-8.0),
1 => Some(32.0),
_ => None,
};
let next = revision.clone();
stack(&theme)
.w(px(440.0))
.child(caption(
&theme,
"Synthetic observations · exact latest text with animated color; missing is never zero",
))
.child(
Button::new("scene.heat.advance")
.label("Advance reading")
.on_click(move |window, _| {
*next.borrow_mut() += 1;
window.refresh();
}),
)
.child(
ContinuousHeatmap::new(
"scene.heat.live",
"Controlled measurement",
HeatColorScale::diverging(
[-8.0, 2.0, 32.0],
theme.colors.accent,
theme.colors.canvas,
theme.colors.danger,
)
.expect("domain"),
PlotState::Ready(vec![
ContinuousHeatCell::new("changing", "row", "a", "Changing reading", value),
ContinuousHeatCell::new("zero", "row", "b", "Verified zero", Some(0.0)),
]),
)
.rows(["row"])
.columns(["a", "b"])
.motion(true),
)
.into_any_element()
}