Skip to content
  1. API
  2. Ogma

Ogma.styles

Ogma functions related to styling the graph and adjusting its visual appearance.

ogma.styles.addEdgeRule([selector], rule)

Add a rule that impacts only edges.

Arguments

Returns

ogma.styles.addNodeRule([selector], rule)

Add a rule that impacts only nodes.

Arguments

Returns

ogma.styles.addRule([options])

Add a style rule, applying the specified attributes to all nodes & edges that match the specified selector. The style of a node is re-computed when its degree or data changes, and automatically assigned when a node is added. Rules are applied one after another. The latest added rule is applied last. Rules are applied before attributes assigned through setAttributes, which are applied before classes.

Arguments

  • options(optional) object
    • edgeAttributes(optional) EdgeAttributesValue|(edge:Edge)=>EdgeAttributesValue Attributes that will be assigned to the edges.
    • edgeDependencies(optional) EdgeDependencies (Advanced - see tutorial) Attributes on which the functions (if any) in the edgeAttributes field depend
    • edgeOutput(optional) EdgeOutput (Advanced - see tutorial) Edge attributes assigned by the rule. If unspecified, they are inferred from the edgeAttributes field. This field is used together with the dependency fields of other rules/classes to know which rules/classes should be updated when this rule is updated.
    • edgeSelector(optional) EdgeSelector Indicates if the rule should be applied to a given edge. If unspecified, the rule is applied to all edges.
    • nodeAttributes(optional) NodeAttributesValue|(node:Node)=>NodeAttributesValue Attributes that will be assigned to the nodes.
    • nodeDependencies(optional) NodeDependencies (Advanced - see tutorial) Attributes on which the functions (if any) in the nodeAttributes field depend
    • nodeOutput(optional) NodeOutput (Advanced - see tutorial) Node attributes assigned by the rule. If unspecified, they are inferred from the nodeAttributes field. This field is used together with the dependency fields of other rules/classes to know which rules/classes should be updated when this rule is updated.
    • nodeSelector(optional) NodeSelector Indicates if the rule should be applied to a given node. If unspecified, the rule is applied to all nodes.

Returns

ogma.styles.createClass(options)

Create a new class for nodes & edges. Classes are similar to style rules, except they are assigned on an individual basis instead of according to a selector (assigned only to the nodes/edges that have been assigned the class with node.addClass('className')).

Arguments

  • options object
    • edgeAttributes(optional) EdgeAttributesValue Attributes applied to edges when they have this class.
    • edgeDependencies(optional) EdgeDependencies (Advanced - see tutorial) Attributes on which the functions (if any) in the edgeAttributes field depend
    • edgeOutput(optional) EdgeOutput (Advanced - see tutorial) Edge attributes assigned by the class. If unspecified, they are inferred from the edgeAttributes field. This field is used together with the dependency fields of other rules/classes to know which rules/classes should be updated when this class is assigned/removed to/from a edge.
    • name string Name of the class to be created.
    • nodeAttributes(optional) NodeAttributesValue Attributes applied to nodes when they have this class.
    • nodeDependencies(optional) NodeDependencies (Advanced - see tutorial) Attributes on which the functions (if any) in the nodeAttributes field depend
    • nodeOutput(optional) NodeOutput (Advanced - see tutorial) Node attributes assigned by the class. If unspecified, they are inferred from the nodeAttributes field. This field is used together with the dependency fields of other rules/classes to know which rules/classes should be updated when this class is assigned/removed to/from a node.

Returns

ogma.styles.getClass(className)

Returns the class with the specified name. Returns null if no class has the specified name.

Arguments

  • className string

Returns

ogma.styles.getClassList()

Returns the list of existing classes by increasing priority, excluding builtin classes.

Returns

ogma.styles.getEdgeRules()

Returns all rules that only impact edges.

Returns

ogma.styles.getNodeRules()

Returns all rules that only impact nodes.

Returns

ogma.styles.getRuleList()

Returns the list of all rules, in the order they are applied.

Returns

ogma.styles.setEdgeTextsVisibility(value)

Show or hide all the edge texts. This method has an internal counter; if it's called with false, the counter is decreased by one, if it's called with true the counter is increased by one. The counter starts at 0, and cannot go lower than 0. The edge texts are shown if the counter is equal to 0.

Arguments

  • value boolean

ogma.styles.setEdgesVisibility(value)

Show or hide all the edges. This method has an internal counter; if it's called with false, the counter is decreased by one, if it's called with true the counter is increased by one. The counter starts at 0, and cannot go lower than 0. The edges are shown if the counter is equal to 0.

Arguments

  • value boolean

ogma.styles.setHoveredEdgeAttributes(attributes[, fullOverwrite])

Set the style of edges when they are hovered. If null is specified, no style will be applied to hovered edges.

Arguments

  • attributes HoverEdgeOptions|null Attributes to apply to hovered edges
  • fullOverwrite(optional) boolean[=false] If false, the specified attributes will be merged with the current attributes. If true, the attributes applied on hover will be exactly the ones supplied.

ogma.styles.setHoveredNodeAttributes(attributes[, fullOverwrite])

Set the style of nodes when they are hovered. If null is specified, no style will be applied to hovered nodes.

Arguments

  • attributes HoverNodeOptions|null Attributes to apply to hovered nodes
  • fullOverwrite(optional) boolean[=false] If false, the specified attributes will be merged with the current attributes. If true, the attributes applied on hover will be exactly the ones supplied.

ogma.styles.setNodeTextsVisibility(value)

Show or hide all the node texts. This method has an internal counter; if it's called with false, the counter is decreased by one, if it's called with true the counter is increased by one. The counter starts at 0, and cannot go lower than 0. The node texts are shown if the counter is equal to 0.

Arguments

  • value boolean

ogma.styles.setNodesVisibility(value)

Show or hide all the nodes. This method has an internal counter; if it's called with false, the counter is decreased by one, if it's called with true the counter is increased by one. The counter starts at 0, and cannot go lower than 0. The nodes are shown if the counter is equal to 0.

Arguments

  • value boolean

ogma.styles.setSelectedEdgeAttributes(attributes[, fullOverwrite])

Set the style of edges when they are selected. If null is specified, no style will be applied to selected edges.

Arguments

  • attributes EdgeAttributesValue|null Attributes to apply to selected edges
  • fullOverwrite(optional) boolean[=false] If false, the specified attributes will be merged with the current attributes. If true, the attributes applied on selection will be exactly the ones supplied.

ogma.styles.setSelectedNodeAttributes(attributes[, fullOverwrite])

Set the style of nodes when they are selected. If null is specified, no style will be applied to selected nodes.

Arguments

  • attributes NodeAttributesValue|null Attributes to apply to selected nodes
  • fullOverwrite(optional) boolean[=false] If false, the specified attributes will be merged with the current attributes. If true, the attributes applied on selection will be exactly the ones supplied.

ogma.styles.setTheme([nodeAttributes][, edgeAttributes][, selectedNodeAttributes][, selectedEdgeAttributes][, hoveredNodeAttributes][, hoveredEdgeAttributes])

Sets the theme for Ogma

Arguments

  • nodeAttributes(optional) NodeAttributes Default node attributes
  • edgeAttributes(optional) EdgeAttributes Default edge attributes
  • selectedNodeAttributes(optional) NodeAttributes Selected node attributes
  • selectedEdgeAttributes(optional) EdgeAttributes Selected edge attributes
  • hoveredNodeAttributes(optional) HoverNodeOptions Hovered node attributes (you can specify duration and easing for the animation)
  • hoveredEdgeAttributes(optional) HoverEdgeOptions Hovered edge attributes (you can specify duration and easing for the animation)