Styling API¶
On this page¶
NodeStyle¶
st_graph_workbench.component.styles.NodeStyle ¶
NodeStyle(label: str, color: Optional[str] = None, caption: Optional[str] = None, icon: Optional[str] = None, size: Optional[float] = None, shape: Optional[str] = None, border_color: Optional[str] = None, border_width: Optional[float] = None, opacity: Optional[float] = None, label_position: Optional[Literal['top', 'center', 'bottom']] = None, text_size: Optional[float] = None, raw_style: Optional[Dict[str, Any]] = None)
Configure a label-based Cytoscape node style.
The style matches nodes whose data.label equals label. Named
arguments cover common visual properties; raw_style provides access to
additional Cytoscape style properties.
Define a custom style of a node in the graph based on label.
Parameters:
-
label(str) –The label of the node. This label is used to identify the group or category of the node.
-
color(Optional[str], default:None) –Specifies the background color of the node. If not provided, the default node color "#0a0a0a" will be used.
-
caption(Optional[str], default:None) –Name of the node's attribute to use as caption/label. If not provided, no caption will be shown.
-
icon(Optional[str], default:None) –Node icon name from the bundled Material Symbols-style SVG assets (e.g. 'person') or a URL (e.g. url('...')). A list of supported icons is available in
st_graph_workbench.component.icons. -
size(Optional[float], default:None) –Node width and height in Cytoscape units.
-
shape(Optional[str], default:None) –Cytoscape node shape, such as 'ellipse', 'round-rectangle', or 'diamond'.
-
border_color(Optional[str], default:None) –Node border color.
-
border_width(Optional[float], default:None) –Node border width in Cytoscape units.
-
opacity(Optional[float], default:None) –Node opacity from 0 to 1.
-
label_position(Optional[Literal['top', 'center', 'bottom']], default:None) –Vertical label placement relative to the node.
-
text_size(Optional[float], default:None) –Node label font size in Cytoscape units.
-
raw_style(Optional[Dict[str, Any]], default:None) –Advanced Cytoscape style properties merged after the simple Python fields. Use this when Cytoscape supports a style that this wrapper does not name directly.
Example
node_style = NodeStyle(label="Person", color="#345eeb", caption="name")
Source code in st_graph_workbench/component/styles.py
dump ¶
Return the style as a JSON-ready Cytoscape selector rule.
Source code in st_graph_workbench/component/styles.py
EdgeStyle¶
st_graph_workbench.component.styles.EdgeStyle ¶
EdgeStyle(label: str, color: Optional[str] = None, caption: Optional[str] = None, labeled: Optional[bool] = None, directed: bool = False, curve_style: Optional[str] = None, width: Optional[float] = None, line_style: Optional[str] = None, opacity: Optional[float] = None, source_arrow: Optional[str] = None, target_arrow: Optional[str] = None, raw_style: Optional[Dict[str, Any]] = None)
Configure a label-based Cytoscape edge style.
The style matches edges whose data.label equals label and can
describe captions, direction, line appearance, arrows, and raw Cytoscape
properties.
Define a custom style of an edge in the graph based on label.
Parameters:
-
label(str) –The label of the edge. This label is used to identify the group or category of the edge.
-
color(Optional[str], default:None) –Specifies the color of the edge line.
-
caption(Optional[str], default:None) –Name of the edge's attribute to use as caption/label. If not provided, no caption will be shown.
-
labeled(bool, default:False (deprecated)) –Compatibility parameter retained for older examples. Use
captioninstead to specify edge caption/label. Iflabeledis set to True andcaptionis not provided, default caption 'label' will be used. -
directed(bool, default:False) –Indicates whether the edge is directed. If True, the edge will be rendered with an arrow pointing from the source to target. Default is False. Note: Arrows will not be displayed if
curve_styleis set to "haystack". -
curve_style(Optional[str], default:None) –Specifies the edge curving method to use. By default, it is set to "bezier", which is suitable for multigraphs. For large, simple graphs, consider using "haystack" for better performance. For more options and detailed information, visit: https://js.cytoscape.org/#style/edge-line
-
width(Optional[float], default:None) –Edge line width in Cytoscape units.
-
line_style(Optional[str], default:None) –Edge line style, such as 'solid', 'dashed', or 'dotted'.
-
opacity(Optional[float], default:None) –Edge opacity from 0 to 1.
-
source_arrow(Optional[str], default:None) –Cytoscape source arrow shape.
-
target_arrow(Optional[str], default:None) –Cytoscape target arrow shape. This overrides the default triangle used by
directed=True. -
raw_style(Optional[Dict[str, Any]], default:None) –Advanced Cytoscape style properties merged after the simple Python fields.
Example
edge_style = EdgeStyle(label="FOLLOWS", color="#345eeb")
Source code in st_graph_workbench/component/styles.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
dump ¶
Return the style as a JSON-ready Cytoscape selector rule.
Source code in st_graph_workbench/component/styles.py
StyleRule¶
st_graph_workbench.component.styles.StyleRule ¶
Configure an advanced Cytoscape selector and style dictionary.
Define an advanced Cytoscape stylesheet rule.
Use this escape hatch when NodeStyle or EdgeStyle do not expose a
specific Cytoscape style property directly.