Behaviors#

Graph Recording Behaviors#

Behaviors for recording the state of the ipyforcegraph graphs.

class ipyforcegraph.behaviors.recording.GraphCamera(**kwargs)[source]#

Bases: Behavior

Captures the current center and zoom of the graph viewport.

Public constructor

capturing Bool(False)#

whether visible nodes should be captured as visible

center TypedTuple()#

the center of the viewport as [x, y, z?]

look_at TypedTuple()#

the direction of a 3D camera as [x, y, z?]

visible TypedTuple()#

the indices of all visible nodes

zoom Float(None)#

the current 2D zoom level of the viewport

class ipyforcegraph.behaviors.recording.GraphData(**kwargs)[source]#

Bases: Behavior

Captures multiple subsequent ticks of a graph simulation, each as a DataFrame.

Public constructor

capturing Bool(False)#

whether the dataframe capture is currently active

source_count Int(1)#

the number of sources to capture

sources TypedTuple()#

a tuple of DataFrameSource to be populated with data of the graph

class ipyforcegraph.behaviors.recording.GraphDirector(**kwargs)[source]#

Bases: Behavior

Set a desired center and zoom of the graph viewport.

Public constructor

center TypedTuple()#

the desired center of the viewport as [x, y, z?]

fit_duration Float(0.2)#

seconds to animate a fit

fit_padding Float(10)#

pixels of padding between visible nodes and viewport

look_at TypedTuple()#

the direction of a 3d camera as [x, y, z]

pan_duration Float(0.2)#

seconds to animate a pan

visible Union(None)#

fit nodes in viewport for which this column/template is truthy

zoom Float(None)#

the desired 2D zoom level of the viewport

zoom_duration Float(0.2)#

seconds to animate a zoom

zoom_first Bool(False)#

whether to zoom the viewport before panning

class ipyforcegraph.behaviors.recording.GraphImage(**kwargs)[source]#

Bases: Behavior

Captures multiple subsequent frames of a canvas, each as an Image.

Public constructor

capturing Bool(False)#

whether the frame capture is currently active

frame_count Int(1)#

the number of frames to capture

frames TypedTuple()#

a tuple of Image to populate with frames of the graph

Selection Behaviors#

Selection behaviors for ipyforcegraph nodes and links.

class ipyforcegraph.behaviors.selection.LinkSelection(**kwargs)[source]#

Bases: Behavior

Enable link selection with synced ids of selected links.

Public constructor

column_name Unicode(None)#

an optional name of node’s column to update when selected

multiple Bool(True)#

if False, only one link can be selected at a time

selected TypedTuple()#

the 0-based indices of any selected links

selected_color Unicode('rgba(31, 120, 179, 1.0)')#

the color of selected links

selected_curvature Float(None)#

the curvature of selected links, default: None preserves unselected curvature.

selected_line_dash TypedTuple(None)#

the line-dash of selected links, default: None preserves unselected line_dash

selected_width Float(2)#

the width of selected links

class ipyforcegraph.behaviors.selection.NodeSelection(**kwargs)[source]#

Bases: Behavior

Enable node selection with synced row indices (not id) of selected nodes.

Public constructor

column_name Unicode(None)#

an optional name of a node’s column to update when selected

multiple Bool(True)#

if False, only one node can be selected at a time

selected TypedTuple()#

the row indices of any selected nodes

selected_color Unicode('rgba(179, 163, 105, 1.0)')#

the color of selected nodes

Shape Behaviors#

Configurable shapes for ipyforcegraph nodes.

class ipyforcegraph.behaviors.shapes.Ellipse(**kwargs)[source]#

Bases: HasDimensions

Draw an ellipse shape.

If the width trait is (or evaluates to) 0 or None, no shape will be drawn.

Public constructor

class ipyforcegraph.behaviors.shapes.LinkArrows(**kwargs)[source]#

Bases: Behavior

Customize the size, position, and color of arrows on links.

Public constructor

color Union(None)#

the color of the arrow

length Union(None)#

the length of the arrow

relative_position Union(None)#

the relative position of the arrow along the link, 0.0: source end, 1.0: target end

class ipyforcegraph.behaviors.shapes.LinkShapes(*shapes, **kwargs)[source]#

Bases: Behavior

Customize the shape of the links.

Custom shapes will be drawn on top of default lines, and may not interact predictably with curvature.

Note

line_dash is not displayed in ForceGraph3D.

Public constructor

color Union(None)#

the color of the link

curvature Union(None)#

the curvature of the link, 0: straight, 1: circular

line_dash Union(None)#

the dash line pattern of the link, e.g., [2, 1] for -- -- --

shapes TypedTuple()#

the shapes to draw for each link

width Union(None)#

the width of the link

class ipyforcegraph.behaviors.shapes.NodeShapes(*shapes, **kwargs)[source]#

Bases: Behavior

Change the shape of nodes using declarative statements.

The color and size traits affect the default circle, and compose with NodeSelection.

If non-empty, custom shapes will override the simple size and color, and will require custom handling with column_name to reflect user selection.

Public constructor

color Union(None)#

the color of the default circle shape

shapes TypedTuple()#

the shapes to draw for each node

size Union(None)#

the size of the default circle shape

class ipyforcegraph.behaviors.shapes.Rectangle(**kwargs)[source]#

Bases: HasDimensions

Draw a rectangle shape.

If the width trait is (or evaluates to) 0 or None, no shape will be drawn.

Public constructor

class ipyforcegraph.behaviors.shapes.Text(text=None, **kwargs)[source]#

Bases: HasFillAndStroke, HasOffsets

Draw a text shape, with an optional background.

If the text trait is (or evaluates to) 0 or None, no shape will be drawn.

Public constructor

background Union(None)#

the background fill color of a shape

font Union(None)#

the font face of a shape

padding Union(None)#

the padding around the shape in px

size Union(None)#

the visible font size of text in px

size_pixels Union(None)#

the rendered size of text in px. 3D only.

text Union(None)#

the text of a shape

Particles Behaviors#

Behaviors for controlling particles traveling over ipyforcegraph links.

class ipyforcegraph.behaviors.particles.LinkParticles(**kwargs)[source]#

Bases: Behavior

Customize the animated particles on links.

Note

The speed should be between 0.0, stationary, and ~0.1, or they will exceed the frame rate of the animation.

Public constructor

color Union(None)#

the color of the particles

density Union(None)#

the number of particles, ideally 0.0 < value

speed Union(None)#

the speed of the particles, ideally 0.0 < value < ~0.1

width Union(None)#

the size of the particles, ideally 0.0 < value < ~5

Tooltip Behaviors#

On-hover tooltip behaviors for ipyforcegraph nodes and links.

class ipyforcegraph.behaviors.tooltip.LinkTooltip(label=None, **kwargs)[source]#

Bases: Behavior

Customize link tooltips, displayed on hover.

These may be strings or full HTML.

Public constructor

label Union(None)#

the label to display when hovering over the link, can be Column or Nunjucks template

class ipyforcegraph.behaviors.tooltip.NodeTooltip(label=None, **kwargs)[source]#

Bases: Behavior

Customize node tooltips, displayed on hover.

These may be strings or full HTML.

Public constructor

label Union(None)#

the label to display when hovering over the node, can be Column or Nunjucks template