Components / display
SpecializedChart builder
Specialized raw-value presentations with a persistent labeled value key, keyboard selection, semantic marks, and retained-data refresh failures.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::display::specialized::SpecializedChart;
Reviewed in specialized specialized-distribution specialized-exploration.
Construct
new(ident: impl Into<Ident>, label: impl Into<SharedString>, state: PlotState<SpecializedData>) -> Self
Options
Chain onto the value.
selected(id: Option<SharedString>) -> Self
motion(enabled: bool) -> Self
animate(enabled: bool) -> Self
animation(spec: crate::motion::MotionSpec) -> Self
labels(enabled: bool) -> Self
on_navigate(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
on_hover(handler: impl Fn(Option<SharedString>, &mut Window, &mut App) + 'static) -> Self
current(id: impl Into<SharedString>) -> Self
on_current(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
Example · specialized
fn specialized(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
let leaf = |id, label, value| HierarchyNode::leaf(WeightedValue::new(id, label, value));
let root = HierarchyNode::branch(
"total",
"All work",
vec![
leaf("build", "Build", 60.0),
HierarchyNode::branch(
"verify",
"Verification",
vec![leaf("tests", "Tests", 30.0), leaf("lint", "Lint", 10.0)],
),
],
);
let fixtures = [
(
"treemap",
"Treemap · area = work",
SpecializedData::treemap(&root),
),
(
"sunburst",
"Sunburst · angle = work",
SpecializedData::sunburst(&root),
),
(
"funnel",
"Funnel · width = count",
SpecializedData::funnel(vec![
WeightedValue::new("seen", "Seen", 120.0),
WeightedValue::new("started", "Started", 75.0),
WeightedValue::new("done", "Completed", 24.0),
]),
),
];
stack(&theme)
.w(px(940.0))
.child(caption(
&theme,
"Synthetic hierarchy fixtures · select marks with arrow keys or value keys",
))
.child(
div()
.row()
.gap_token(&theme, Space::Lg)
.children(fixtures.into_iter().map(|(id, label, data)| {
div().w(px(280.0)).child(
SpecializedChart::new(
Ident::new("scene.specialized").child(id),
label,
PlotState::Ready(data.expect("valid hierarchy")),
)
.on_current(|_, _, _| {}),
)
})),
)
.child(
div().w(px(220.0)).child(SpecializedChart::new(
"scene.specialized.zero",
"Zero is measured, not missing",
PlotState::Stale {
data: SpecializedData::funnel(vec![WeightedValue::new(
"zero",
"Measured zero",
0.0,
)])
.expect("zero"),
reason: "Refresh refused; verified zero retained".into(),
},
)),
)
.into_any_element()
}