Skip to main content

NetworkGraph

Struct NetworkGraph 

Source
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

Source

pub fn new(cx: &mut Context<'_, Self>) -> Self

Source

pub fn with_data(self, data: GraphData) -> Self

Source

pub fn with_force_config(self, config: ForceConfig) -> Self

Source

pub fn with_label_mode(self, mode: LabelMode) -> Self

Source

pub fn with_color_by(self, color_by: ColorBy) -> Self

Source

pub fn arrows(self, arrows: bool) -> Self

Draw direction arrows on edges (default on).

Source

pub fn edge_labels(self, edge_labels: bool) -> Self

Draw relationship labels on edges (default on).

Source

pub fn group_hulls(self, group_hulls: bool) -> Self

Outline each expanded group with a rounded hull (default on).

Source

pub fn sticky_drag(self, sticky: bool) -> Self

Keep dragged nodes pinned where they are dropped (default off).

Source

pub fn with_palette(self, palette: Palette) -> Self

Source

pub fn with_node_sizing(self, sizing: NodeSizing) -> Self

Source

pub fn with_colors(self, colors: GraphColors) -> Self

Fixed colors instead of following the gpui-base theme.

Source

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.

Source

pub fn tooltips(self, tooltips: bool) -> Self

Show tooltips for the hovered item (default on).

Source

pub fn label_mode(&self) -> LabelMode

Source

pub fn set_label_mode(&mut self, mode: LabelMode, cx: &mut Context<'_, Self>)

Source

pub fn color_by(&self) -> ColorBy

Source

pub fn set_color_by(&mut self, color_by: ColorBy, cx: &mut Context<'_, Self>)

Source

pub fn has_arrows(&self) -> bool

Source

pub fn set_arrows(&mut self, arrows: bool, cx: &mut Context<'_, Self>)

Source

pub fn has_edge_labels(&self) -> bool

Source

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.

Source

pub fn focus_dimming(&self) -> bool

Source

pub fn set_edge_labels(&mut self, edge_labels: bool, cx: &mut Context<'_, Self>)

Source

pub fn has_group_hulls(&self) -> bool

Source

pub fn set_group_hulls(&mut self, group_hulls: bool, cx: &mut Context<'_, Self>)

Source

pub fn is_sticky_drag(&self) -> bool

Source

pub fn set_sticky_drag(&mut self, sticky: bool)

Source

pub fn has_tooltips(&self) -> bool

Source

pub fn set_tooltips(&mut self, tooltips: bool, cx: &mut Context<'_, Self>)

Source

pub fn set_force_config( &mut self, config: ForceConfig, cx: &mut Context<'_, Self>, )

Source

pub fn set_colors( &mut self, colors: Option<GraphColors>, cx: &mut Context<'_, Self>, )

Source

pub fn set_data(&mut self, data: GraphData, cx: &mut Context<'_, Self>)

Replace the whole graph (a new query result) and reset the viewport.

Source

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.

Source

pub fn remove_nodes(&mut self, ids: &[&str], cx: &mut Context<'_, Self>)

Remove nodes and every edge touching them.

Source

pub fn clear(&mut self, cx: &mut Context<'_, Self>)

Source

pub fn data(&self) -> GraphData

The current graph contents (including nodes inside collapsed groups).

Source

pub fn node_count(&self) -> usize

Source

pub fn edge_count(&self) -> usize

Source

pub fn node(&self, id: &str) -> Option<&Node>

Source

pub fn degree(&self, id: &str) -> usize

Source

pub fn neighbors_of(&self, id: &str) -> Vec<Node>

Source

pub fn edges_of(&self, id: &str) -> Vec<Edge>

Edges touching a node, in either direction.

Source

pub fn categories(&self) -> Vec<CategoryInfo>

Source

pub fn groups(&self) -> Vec<GroupInfo>

Source

pub fn group(&self, id: &str) -> Option<GroupInfo>

Source

pub fn group_members(&self, id: &str) -> Vec<Node>

Member nodes of a group.

Source

pub fn resolved_colors(&self, cx: &App) -> GraphColors

The colors in effect: the override, or the current theme.

Source

pub fn color_of(&self, node: &Node, cx: &App) -> Hsla

The color a node is painted with.

Source

pub fn selection(&self) -> Selection

Source

pub fn zoom(&self) -> f32

Source

pub fn is_simulating(&self) -> bool

Whether the layout is still moving.

Source

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.

Source

pub fn set_pinned(&mut self, id: &str, pinned: bool, cx: &mut Context<'_, Self>)

Pin or release a node at its current position.

Source

pub fn is_pinned(&self, id: &str) -> bool

Source

pub fn unpin_all(&mut self, cx: &mut Context<'_, Self>)

Source

pub fn collapse_group(&mut self, id: &str, cx: &mut Context<'_, Self>)

Collapse a group into a single super node.

Source

pub fn expand_group(&mut self, id: &str, cx: &mut Context<'_, Self>)

Source

pub fn toggle_group(&mut self, id: &str, cx: &mut Context<'_, Self>)

Source

pub fn collapse_all_groups(&mut self, cx: &mut Context<'_, Self>)

Community overview: every group becomes one node.

Source

pub fn expand_all_groups(&mut self, cx: &mut Context<'_, Self>)

Source

pub fn set_group_label( &mut self, id: &str, label: impl Into<SharedString>, cx: &mut Context<'_, Self>, )

Source

pub fn fit_view(&mut self, cx: &mut Context<'_, Self>)

Fit everything into view and keep fitting while the layout settles.

Source

pub fn zoom_by(&mut self, factor: f32, cx: &mut Context<'_, Self>)

Source

pub fn relayout(&mut self, cx: &mut Context<'_, Self>)

Restart the layout from scratch (d3 simulation.alpha(1).restart()).

Trait Implementations§

Source§

impl EventEmitter<NetworkGraphEvent> for NetworkGraph

Source§

impl Focusable for NetworkGraph

Source§

fn focus_handle(&self, _: &App) -> FocusHandle

Returns the focus handle associated with this view.
Source§

impl Render for NetworkGraph

Source§

fn render( &mut self, window: &mut Window, cx: &mut Context<'_, Self>, ) -> impl IntoElement

Render this view into an element tree.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more