Bases#
These classes are not generally needed, but are included for completeness.
Base widget identification for ipyforcegraph.
- class ipyforcegraph._base.ForceBase(**kwargs)[source]#
Bases:
WidgetThe base class for all
IPyForceGraphwidgets.Public constructor
Base classes for all behaviors and forces.
- class ipyforcegraph.behaviors._base.BaseD3Force(**kwargs)[source]#
Bases:
BehaviorA base for all
d3-force-3dforce wrappers.Public constructor
- active Bool(True)#
whether the force is currently active
- class ipyforcegraph.behaviors._base.Behavior(**kwargs)[source]#
Bases:
ForceBaseThe 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:
DynamicValueA column from a
DataFrameSource.Public constructor
- class ipyforcegraph.behaviors._base.DEFAULT_RANK[source]#
Bases:
objectRanks 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:
ForceBaseAn 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
typeinto 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,HasOffsetsA shape that has
width,heightanddepth.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:
HasScaleA shape that has
fillandstroke.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:
ShapeBaseA 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:
ShapeBaseA 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:
DynamicValueA 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
sourceis available asgraphData, which hasnodesandlinks.Depending on the context, inside of a template, one can use
nodeorlink, which will have all their available columns available using the dot notation, e.g.,node.id. In addition,linkwill havesourceandtargetas realizednodes.For example, to dynamically set the
attributeproperty of abehaviorin the front-end based on theidproperty of the sourcenodeof a givenlink, 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