Skip to content

netlist_carpentry.vis.styling.format

Classes:

FormatDefinition

Bases: BaseModel

Methods:

  • copy_

    Alias for self.model_copy(update).

  • merge

    Merges the current object together with another FormatDefinition object into a new object.

Attributes:

background_color class-attribute instance-attribute

background_color: Optional[str] = None

Node background color as a plain string, e.g. 'red' or hex code, e.g. '#ABCDEF'.

background_opacity class-attribute instance-attribute

background_opacity: Optional[str] = None

Node background opacity from 0 (transparent) to 1 (opaque), e.g. '0.5'.

border class-attribute instance-attribute

border: Optional[str] = None

Shorthand for border-width border-style (required) border-color, e.g. 'solid' or '5px dotted blue'.

border_color class-attribute instance-attribute

border_color: Optional[str] = None

Node border color as a plain string, e.g. 'black' or hex code, e.g. '#ABCDEF'.

border_radius class-attribute instance-attribute

border_radius: Optional[str] = None

Node border corner radius, e.g. '5px'.

border_style class-attribute instance-attribute

border_style: Union[str, BorderStyleLiteral, None] = None

Node border style, e.g. 'solid' or 'dashed'.

border_width class-attribute instance-attribute

border_width: Optional[str] = None

Node border width, e.g. '2px'.

box_shadow class-attribute instance-attribute

box_shadow: Optional[str] = None

Node box shadow effect, e.g. '2px 2px 5px #ABCDEF'.

color class-attribute instance-attribute

color: Optional[str] = None

Node text color as a plain string, e.g. 'red' or hex code, e.g. '#ABCDEF'.

curve_style class-attribute instance-attribute

curve_style: Union[str, CurveStyleLiteral, None] = None

Style of edges curvature, e.g. 'bezier', 'unbundled-bezier', or 'source-target'.

font_family class-attribute instance-attribute

font_family: Optional[str] = None

Node or edge label font family, e.g. 'sans-serif' or 'monospace'.

font_size class-attribute instance-attribute

font_size: Optional[str] = None

Node or edge label text size, e.g. '14px'.

font_style class-attribute instance-attribute

font_style: Union[str, FontStyleLiteral, None] = None

Node or edge label font style, e.g. 'italic', 'oblique', or 'normal'.

font_weight class-attribute instance-attribute

font_weight: Union[str, FontWeightLiteral, None] = None

Node or edge label font weight, e.g. 'normal', 'bold', 'bolder', 'lighter', or a number from 100 to 900.

height class-attribute instance-attribute

height: Optional[str] = None

Node height, e.g. '80px'.

label class-attribute instance-attribute

label: Optional[str] = None

Node or edge label as plain text.

left class-attribute instance-attribute

left: Optional[str] = None

Node horizontal position from the left edge, e.g. '100px'.

line_color class-attribute instance-attribute

line_color: Optional[str] = None

Edge color as a plain string, e.g. 'red' or hex code, e.g. '#ABCDEF'.

line_dash_pattern class-attribute instance-attribute

line_dash_pattern: Optional[str] = None

Edge line dash pattern, e.g. '4,2' for dashed lines or '2,2' for dotted lines.

line_height class-attribute instance-attribute

line_height: Optional[str] = None

Line height multiplier for text, e.g. '1.2'.

line_style class-attribute instance-attribute

line_style: Union[str, LineStyleLiteral, None] = None

Edge line style, e.g. 'solid', 'dashed', or 'dotted'.

line_width class-attribute instance-attribute

line_width: Optional[str] = None

Edge line width, e.g. '2px'.

max_width class-attribute instance-attribute

max_width: Optional[str] = None

Maximum node width, e.g. '200px'.

min_width class-attribute instance-attribute

min_width: Optional[str] = None

Minimum node width, e.g. '50px'.

padding class-attribute instance-attribute

padding: Optional[str] = None

Node internal padding, e.g. '10px'.

padding_bottom class-attribute instance-attribute

padding_bottom: Optional[str] = None

Node internal bottom padding, e.g. '10px'.

padding_left class-attribute instance-attribute

padding_left: Optional[str] = None

Node internal left padding, e.g. '10px'.

padding_right class-attribute instance-attribute

padding_right: Optional[str] = None

Node internal right padding, e.g. '10px'.

padding_top class-attribute instance-attribute

padding_top: Optional[str] = None

Node internal top padding, e.g. '10px'.

position class-attribute instance-attribute

position: Union[str, PositionLiteral, None] = None

Node position as coordinates, e.g. '{x: 100, y: 200}'.

shape class-attribute instance-attribute

shape: Union[str, ShapeLiteral, None] = None

Node shape, e.g. 'rectangle', 'ellipse', 'circle', 'diamond', 'triangle', etc.

target_arrow_color class-attribute instance-attribute

target_arrow_color: Optional[str] = None

Edge arrow color as a plain string, e.g. 'red' or hex code, e.g. '#ABCDEF'.

target_arrow_shape class-attribute instance-attribute

target_arrow_shape: Union[str, ArrowShapeLiteral, None] = None

Edge arrow shape, e.g. 'triangle', 'vee', 'circle', 'diamond', 'none', etc.

text_background_color class-attribute instance-attribute

text_background_color: Optional[str] = None

Text background fill color, e.g. 'white' or hex code, '#ABCDEF'.

text_background_opacity class-attribute instance-attribute

text_background_opacity: Optional[str] = None

Text background opacity from 0 (transparent) to 1 (opaque), e.g. '0.5'.

text_background_padding class-attribute instance-attribute

text_background_padding: Optional[str] = None

Padding around text background, e.g. '5px'.

text_halign class-attribute instance-attribute

text_halign: Union[str, TextHAlignLiteral, None] = None

Horizontal alignment of node or edge text, e.g. 'center', 'left', or 'right'.

text_max_width class-attribute instance-attribute

text_max_width: Optional[str] = None

Maximum text width before wrapping, e.g. '150px'.

text_min_width class-attribute instance-attribute

text_min_width: Optional[str] = None

Minimum text width before wrapping, e.g. '150px'.

text_outline_color class-attribute instance-attribute

text_outline_color: Optional[str] = None

Text outline/stroke color, e.g. 'white' or hex code, '#ABCDEF'.

text_outline_opacity class-attribute instance-attribute

text_outline_opacity: Optional[str] = None

Text outline opacity from 0 (transparent) to 1 (opaque), e.g. '0.5'.

text_outline_width class-attribute instance-attribute

text_outline_width: Optional[str] = None

Text outline/stroke width, e.g. '1px'.

text_valign class-attribute instance-attribute

text_valign: Union[str, TextVAlignLiteral, None] = None

Vertical alignment of node or edge text, e.g. 'center', 'top', or 'bottom'.

text_wrap class-attribute instance-attribute

text_wrap: Union[str, TextWrapLiteral, None] = None

Text wrapping mode, e.g. 'wrap', 'ellipsis', or 'none'.

top class-attribute instance-attribute

top: Optional[str] = None

Node vertical position from the top edge, e.g. '50px'.

transition_property class-attribute instance-attribute

transition_property: Optional[str] = None

CSS property to animate, e.g. 'background-color'.

transition_duration class-attribute instance-attribute

transition_duration: Optional[str] = None

Animation duration, e.g. '0.3s'.

width class-attribute instance-attribute

width: Optional[str] = None

Node width, e.g. '80px'.

z_index class-attribute instance-attribute

z_index: Optional[str] = None

Stacking order of the node, e.g. '10'.

copy_

copy_(update: Optional[Dict[str, Optional[str]]] = None) -> Self

Alias for self.model_copy(update).

Copies the current object and updates values in the new object as specified in the given dictionary.

Parameters:

  • update

    (Optional[Dict[str, Optional[str]]], default: None ) –

    An update dictionary with values to set in the new object. Entries with None as value are also valid, since this will reset the parameter to its default value. If None, the object is copied and left as-is. Defaults to None.

Returns:

  • Self ( Self ) –

    A copy of this object, with value changes if specified in the update dictionary.

merge

merge(other: Self) -> Self

Merges the current object together with another FormatDefinition object into a new object.

None values in both objects are ignored (i.e. remain as None). The values from the other object take precedence over the current object. Both original objects remain unchanged, and a new object with the merged properties is returned.

Parameters:

  • other

    (Self) –

    Another FormatDefinition object to merge with.

Returns:

  • Self ( Self ) –

    A new FormatDefinition object that combines the properties of both objects.

Example
>>> f1 = FormatDefinition(color='red', width='20')
>>> f2 = FormatDefinition(height='30', color=None)
>>> f3 = f1.merge(f2)
>>> f3.color
'red'
>>> f3.width
'20'
>>> f3.height
'30'

Formats

Bases: BaseModel

Methods:

  • add_format

    Adds a format with the given name and the provided format definition.

  • remove_format

    Removes a format with the given name from the definitions.

  • format_nodes

    Formats the specified nodes with the given format.

add_format

add_format(name: FormatName, format: FormatDefinition) -> FormatDefinition

Adds a format with the given name and the provided format definition.

If the format name starts with a period (.), ipycytoscape will treat it like a CSS class.

Parameters:

  • name

    (FormatName) –

    The name of the format. If the format name starts with a period (.), ipycytoscape will treat it like a CSS class.

  • format

    (FormatDefinition) –

    The format definition associated with the given name.

Raises:

Returns:

remove_format

remove_format(format: FormatName) -> None

Removes a format with the given name from the definitions.

Parameters:

  • format

    (FormatName) –

    The name of the format to remove.

Raises:

format_nodes

format_nodes(
    nodes: Union[NodeName, Iterable[NodeName]],
    format: FormatName,
    append: bool = True,
) -> None

Formats the specified nodes with the given format.

If append is True, the format is added to the existing formats for each node. If False, it overwrites any existing formats, so that the specified nodes only have the given format afterwards.

Parameters:

  • nodes

    (Union[NodeName, Iterable[NodeName]]) –

    The nodes to format.

  • format

    (FormatName) –

    The name of the format to apply.

  • append

    (bool, default: True ) –

    Whether to append the format to existing formats for each node. If False, overwrites existing formats. Defaults to True.