pub struct NetworkGraph { /* private fields */ }Expand description
An interactive, force-directed network graph.
let graph = cx.new(|cx| {
NetworkGraph::new(cx)
.with_data(GraphData::new(nodes, edges))
.with_label_mode(LabelMode::Auto)
});
cx.subscribe(&graph, |this, _, event: &NetworkGraphEvent, cx| { /* ... */ }).detach();Place it in a sized container: it fills its parent.
Implementations§
Source§impl NetworkGraph
impl NetworkGraph
pub fn new(cx: &mut Context<'_, Self>) -> Self
pub fn with_data(self, data: GraphData) -> Self
pub fn with_force_config(self, config: ForceConfig) -> Self
pub fn with_label_mode(self, mode: LabelMode) -> Self
pub fn with_color_by(self, color_by: ColorBy) -> Self
Sourcepub fn edge_labels(self, edge_labels: bool) -> Self
pub fn edge_labels(self, edge_labels: bool) -> Self
Draw relationship labels on edges (default on).
Sourcepub fn group_hulls(self, group_hulls: bool) -> Self
pub fn group_hulls(self, group_hulls: bool) -> Self
Outline each expanded group with a rounded hull (default on).
Sourcepub fn sticky_drag(self, sticky: bool) -> Self
pub fn sticky_drag(self, sticky: bool) -> Self
Keep dragged nodes pinned where they are dropped (default off).
pub fn with_palette(self, palette: Palette) -> Self
pub fn with_node_sizing(self, sizing: NodeSizing) -> Self
Sourcepub fn with_colors(self, colors: GraphColors) -> Self
pub fn with_colors(self, colors: GraphColors) -> Self
Fixed colors instead of following the gpui-base theme.
Sourcepub fn with_tooltip(
self,
builder: impl Fn(&Selection, &GraphColors, &mut Window, &mut App) -> Option<AnyElement> + 'static,
) -> Self
pub fn with_tooltip( self, builder: impl Fn(&Selection, &GraphColors, &mut Window, &mut App) -> Option<AnyElement> + 'static, ) -> Self
Replace the built-in tooltip. Return None from the builder to hide it.
pub fn label_mode(&self) -> LabelMode
pub fn set_label_mode(&mut self, mode: LabelMode, cx: &mut Context<'_, Self>)
pub fn color_by(&self) -> ColorBy
pub fn set_color_by(&mut self, color_by: ColorBy, cx: &mut Context<'_, Self>)
pub fn has_arrows(&self) -> bool
pub fn set_arrows(&mut self, arrows: bool, cx: &mut Context<'_, Self>)
pub fn has_edge_labels(&self) -> bool
Sourcepub fn set_focus_dimming(&mut self, dimming: bool, cx: &mut Context<'_, Self>)
pub fn set_focus_dimming(&mut self, dimming: bool, cx: &mut Context<'_, Self>)
Whether hovering or selecting an item fades everything outside its neighborhood. Off, the item and its edges are still emphasized, and every other node stays as readable — and as easy to aim at — as before.
pub fn focus_dimming(&self) -> bool
pub fn set_edge_labels(&mut self, edge_labels: bool, cx: &mut Context<'_, Self>)
pub fn has_group_hulls(&self) -> bool
pub fn set_group_hulls(&mut self, group_hulls: bool, cx: &mut Context<'_, Self>)
pub fn is_sticky_drag(&self) -> bool
pub fn set_sticky_drag(&mut self, sticky: bool)
pub fn has_tooltips(&self) -> bool
pub fn set_tooltips(&mut self, tooltips: bool, cx: &mut Context<'_, Self>)
pub fn set_force_config( &mut self, config: ForceConfig, cx: &mut Context<'_, Self>, )
pub fn set_colors( &mut self, colors: Option<GraphColors>, cx: &mut Context<'_, Self>, )
Sourcepub fn set_data(&mut self, data: GraphData, cx: &mut Context<'_, Self>)
pub fn set_data(&mut self, data: GraphData, cx: &mut Context<'_, Self>)
Replace the whole graph (a new query result) and reset the viewport.
Sourcepub fn merge(
&mut self,
data: GraphData,
anchor: Option<&str>,
cx: &mut Context<'_, Self>,
)
pub fn merge( &mut self, data: GraphData, anchor: Option<&str>, cx: &mut Context<'_, Self>, )
Add nodes and edges to the current graph, e.g. expanding a node. Existing
ids are kept; new nodes start around anchor so the layout stays stable.
New members of a collapsed group join it without expanding it.
Sourcepub fn remove_nodes(&mut self, ids: &[&str], cx: &mut Context<'_, Self>)
pub fn remove_nodes(&mut self, ids: &[&str], cx: &mut Context<'_, Self>)
Remove nodes and every edge touching them.
pub fn clear(&mut self, cx: &mut Context<'_, Self>)
Sourcepub fn data(&self) -> GraphData
pub fn data(&self) -> GraphData
The current graph contents (including nodes inside collapsed groups).
pub fn node_count(&self) -> usize
pub fn edge_count(&self) -> usize
pub fn node(&self, id: &str) -> Option<&Node>
pub fn degree(&self, id: &str) -> usize
pub fn neighbors_of(&self, id: &str) -> Vec<Node>
pub fn categories(&self) -> Vec<CategoryInfo>
pub fn groups(&self) -> Vec<GroupInfo>
pub fn group(&self, id: &str) -> Option<GroupInfo>
Sourcepub fn group_members(&self, id: &str) -> Vec<Node>
pub fn group_members(&self, id: &str) -> Vec<Node>
Member nodes of a group.
Sourcepub fn resolved_colors(&self, cx: &App) -> GraphColors
pub fn resolved_colors(&self, cx: &App) -> GraphColors
The colors in effect: the override, or the current theme.
pub fn selection(&self) -> Selection
pub fn zoom(&self) -> f32
Sourcepub fn is_simulating(&self) -> bool
pub fn is_simulating(&self) -> bool
Whether the layout is still moving.
Sourcepub fn select_node(
&mut self,
id: Option<&str>,
center: bool,
cx: &mut Context<'_, Self>,
)
pub fn select_node( &mut self, id: Option<&str>, center: bool, cx: &mut Context<'_, Self>, )
Select a node by id (None clears), optionally centering it.
Sourcepub fn set_pinned(&mut self, id: &str, pinned: bool, cx: &mut Context<'_, Self>)
pub fn set_pinned(&mut self, id: &str, pinned: bool, cx: &mut Context<'_, Self>)
Pin or release a node at its current position.
pub fn is_pinned(&self, id: &str) -> bool
pub fn unpin_all(&mut self, cx: &mut Context<'_, Self>)
Sourcepub fn collapse_group(&mut self, id: &str, cx: &mut Context<'_, Self>)
pub fn collapse_group(&mut self, id: &str, cx: &mut Context<'_, Self>)
Collapse a group into a single super node.
pub fn expand_group(&mut self, id: &str, cx: &mut Context<'_, Self>)
pub fn toggle_group(&mut self, id: &str, cx: &mut Context<'_, Self>)
Sourcepub fn collapse_all_groups(&mut self, cx: &mut Context<'_, Self>)
pub fn collapse_all_groups(&mut self, cx: &mut Context<'_, Self>)
Community overview: every group becomes one node.
pub fn expand_all_groups(&mut self, cx: &mut Context<'_, Self>)
pub fn set_group_label( &mut self, id: &str, label: impl Into<SharedString>, cx: &mut Context<'_, Self>, )
Sourcepub fn fit_view(&mut self, cx: &mut Context<'_, Self>)
pub fn fit_view(&mut self, cx: &mut Context<'_, Self>)
Fit everything into view and keep fitting while the layout settles.
pub fn zoom_by(&mut self, factor: f32, cx: &mut Context<'_, Self>)
Trait Implementations§
impl EventEmitter<NetworkGraphEvent> for NetworkGraph
Source§impl Focusable for NetworkGraph
impl Focusable for NetworkGraph
Source§fn focus_handle(&self, _: &App) -> FocusHandle
fn focus_handle(&self, _: &App) -> FocusHandle
Source§impl Render for NetworkGraph
impl Render for NetworkGraph
Auto Trait Implementations§
impl !Freeze for NetworkGraph
impl !RefUnwindSafe for NetworkGraph
impl !Send for NetworkGraph
impl !Sync for NetworkGraph
impl !UnwindSafe for NetworkGraph
impl Unpin for NetworkGraph
impl UnsafeUnpin for NetworkGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more