Bases#

These classes are not generally needed, but are included for completeness.

Base widget identification for ipyforcegraph.

class ipyforcegraph._base.ForceBase(**kwargs)[source]#

Bases: Widget

The base class for all IPyForceGraph widgets.

Public constructor

Base classes for all behaviors and forces.

class ipyforcegraph.behaviors._base.BaseD3Force(**kwargs)[source]#

Bases: Behavior

A base for all d3-force-3d force wrappers.

Public constructor

active Bool(True)#

whether the force is currently active

class ipyforcegraph.behaviors._base.Behavior(**kwargs)[source]#

Bases: ForceBase

The base class for all IPyForceGraph graph behaviors.

Public constructor

rank Int(100)#

order in which behaviors are applied: lower numbers are applied first.

class ipyforcegraph.behaviors._base.Column(value, **kwargs)[source]#

Bases: DynamicValue

A column from a DataFrameSource.

Public constructor

class ipyforcegraph.behaviors._base.DEFAULT_RANK[source]#

Bases: object

Ranks applied to different behaviors: lower values are applied first.

Ties are resolved by the arbitrary (but monotonically increasing) model id.”

behavior Int(100)#

a default rank for behaviors: ties are resolved by class name, then “age”

selection Int(100)#

selection behaviors should generally come earlier

shapes Int(100)#

shapes should resolve after selection, but before styling of default circles, etc.

class ipyforcegraph.behaviors._base.DynamicValue(value, **kwargs)[source]#

Bases: ForceBase

An abstract class to describe what a Dynamic Widget Trait is and does.

Public constructor

JSON_DATA_TYPES Int(100)#
coerce Unicode('')#

name of a JSON Schema type into which to coerce the final value

value Unicode('')#

the source used to compute the value for the trait

class ipyforcegraph.behaviors._base.HasDimensions(**kwargs)[source]#

Bases: HasFillAndStroke, HasOffsets

A shape that has width, height and depth.

Public constructor

depth Union(None)#

the depth of a shape in px

height Union(None)#

the height of a shape in px

opacity Union(None)#

the opacity of a shape

width Union(None)#

the width of a shape in px

class ipyforcegraph.behaviors._base.HasFillAndStroke(**kwargs)[source]#

Bases: HasScale

A shape that has fill and stroke.

Public constructor

fill Union(None)#

the fill color of a shape

line_dash Union(None)#

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

stroke Union(None)#

the stroke color of a shape

stroke_width Union(None)#

the stroke width of a shape

class ipyforcegraph.behaviors._base.HasOffsets(**kwargs)[source]#

Bases: ShapeBase

A shape that can be offset in the horizontal, vertical, or elevation dimensions.

Public constructor

offset_x Union(None)#

the relative horizontal offset from the middle of the shape in px

offset_y Union(None)#

the relative vertical offset from the middle of the shape in px

offset_z Union(None)#

the relative elevation offset from the middle of the shape in px

class ipyforcegraph.behaviors._base.HasScale(**kwargs)[source]#

Bases: ShapeBase

A shape that has scale_on_zoom.

Public constructor

scale_on_zoom Union(None)#

whether font size/stroke respects the global scale. Has no impact on link shapes.

class ipyforcegraph.behaviors._base.Nunjucks(value, **kwargs)[source]#

Bases: DynamicValue

A nunjucks template for calculating dynamic values on the client.

The syntax is intentionally very similar to jinja2, and a number of extra template functions are provided, including the methods and properties in JS Math.

All the data in the source is available as graphData, which has nodes and links.

Depending on the context, inside of a template, one can use node or link, which will have all their available columns available using the dot notation, e.g., node.id. In addition, link will have source and target as realized nodes.

For example, to dynamically set the attribute property of a behavior in the front-end based on the id property of the source node of a given link, you would:

behavior.attribute = Nunjucks("{{ link.source.id }}")

With these, and basic template tools, one can generate all kinds of interesting effects.

color by group#
{{ ["red", "yellow", "blue", "orange", "purple", "magenta"][node.group] }}
color by out-degree#
{% set n = 0 %}
{% for link in graphData.links %}
{% if link.source.id == node.id %}{% set n = n + 1 %}{% endif %}
{% endfor %}
{% set c = 256 * (7-n) / 7 %}
rgb({{ c }},0,0)

Public constructor

class ipyforcegraph.behaviors._base.ShapeBase(**kwargs)[source]#

Bases: ForceBase

A base class from which all shapes inherit.

Public constructor