Appearance
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
- selector(optional)
EdgeSelector - rule
EdgeAttributesValue
Returns
ogma.styles.addNodeRule([selector], rule)
Add a rule that impacts only nodes.
Arguments
- selector(optional)
NodeSelector - rule
NodeAttributesValue
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)=>EdgeAttributesValueAttributes that will be assigned to the edges. - edgeDependencies(optional)
EdgeDependencies(Advanced - see tutorial) Attributes on which the functions (if any) in theedgeAttributesfield depend - edgeOutput(optional)
EdgeOutput(Advanced - see tutorial) Edge attributes assigned by the rule. If unspecified, they are inferred from theedgeAttributesfield. 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)
EdgeSelectorIndicates if the rule should be applied to a given edge. If unspecified, the rule is applied to all edges. - nodeAttributes(optional)
NodeAttributesValue|(node:Node)=>NodeAttributesValueAttributes that will be assigned to the nodes. - nodeDependencies(optional)
NodeDependencies(Advanced - see tutorial) Attributes on which the functions (if any) in thenodeAttributesfield depend - nodeOutput(optional)
NodeOutput(Advanced - see tutorial) Node attributes assigned by the rule. If unspecified, they are inferred from thenodeAttributesfield. 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)
NodeSelectorIndicates if the rule should be applied to a given node. If unspecified, the rule is applied to all nodes.
- edgeAttributes(optional)
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)
EdgeAttributesValueAttributes applied to edges when they have this class. - edgeDependencies(optional)
EdgeDependencies(Advanced - see tutorial) Attributes on which the functions (if any) in theedgeAttributesfield depend - edgeOutput(optional)
EdgeOutput(Advanced - see tutorial) Edge attributes assigned by the class. If unspecified, they are inferred from theedgeAttributesfield. 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
stringName of the class to be created. - nodeAttributes(optional)
NodeAttributesValueAttributes applied to nodes when they have this class. - nodeDependencies(optional)
NodeDependencies(Advanced - see tutorial) Attributes on which the functions (if any) in thenodeAttributesfield depend - nodeOutput(optional)
NodeOutput(Advanced - see tutorial) Node attributes assigned by the class. If unspecified, they are inferred from thenodeAttributesfield. 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.
- edgeAttributes(optional)
Returns
ogma.styles.fontSizeToBadgeScale(fontSize, radius[, fontScale])
Computes the right fixed badge scale for a given font size and node radius. Use it when you are combining the 'scaled' node size policy with 'fixed' badge size.
Arguments
- fontSize
numberThe desired font size at zoom 1 - radius
numberThe radius of the node - fontScale(optional)
number[=0.5]The scale of the font, used to compute the badge size
Returns
-
number
ogma.styles.getClass(className)
Returns the class with the specified name. Returns null if no class has the specified name.
Arguments
- className
string
Returns
-
StyleClass|null
ogma.styles.getClassList()
Returns the list of existing classes by increasing priority, excluding builtin classes.
Returns
-
Array<StyleClass>
ogma.styles.getEdgeRules()
Returns all rules that only impact edges.
Returns
-
Array<StyleRule>
ogma.styles.getNodeRules()
Returns all rules that only impact nodes.
Returns
-
Array<StyleRule>
ogma.styles.getRuleList()
Returns the list of all rules, in the order they are applied.
Returns
-
Array<StyleRule>
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|nullAttributes to apply to hovered edges - fullOverwrite(optional)
boolean[=false]Iffalse, the specified attributes will be merged with the current attributes. Iftrue, the attributes applied on hover will be exactly the ones supplied.
ogma.styles.setHoveredEdgeExtremitiesAttributes(attributes[, fullOverwrite])
Set the style of the extremities of the hovered edges. If null is specified, no style will be applied them.
Arguments
- attributes
NodeAttributesValue|nullAttributes to apply to the extremities of hovered edges - fullOverwrite(optional)
boolean[=false]Iffalse, the specified attributes will be merged with the current attributes. Iftrue, 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|nullAttributes to apply to hovered nodes - fullOverwrite(optional)
boolean[=false]Iffalse, the specified attributes will be merged with the current attributes. Iftrue, 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|nullAttributes to apply to selected edges - fullOverwrite(optional)
boolean[=false]Iffalse, the specified attributes will be merged with the current attributes. Iftrue, the attributes applied on selection will be exactly the ones supplied.
ogma.styles.setSelectedEdgeExtremitiesAttributes(attributes[, fullOverwrite])
Set the style of the extremities of the selected edges. If null is specified, no style will be applied them.
Arguments
- attributes
NodeAttributesValue|nullAttributes to apply to the extremities of selected edges - fullOverwrite(optional)
boolean[=false]Iffalse, the specified attributes will be merged with the current attributes. Iftrue, 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|nullAttributes to apply to selected nodes - fullOverwrite(optional)
boolean[=false]Iffalse, the specified attributes will be merged with the current attributes. Iftrue, the attributes applied on selection will be exactly the ones supplied.
ogma.styles.setTheme(theme)
Sets the theme for Ogma
Arguments
- theme
Theme- edgeAttributes(optional)
EdgeAttributesDefault edge attributes - hoveredEdgeAttributes(optional)
HoverEdgeOptionsHovered edge attributes (you can specify duration and easing for the animation) - hoveredNodeAttributes(optional)
HoverNodeOptionsHovered node attributes (you can specify duration and easing for the animation) - nodeAttributes(optional)
NodeAttributesDefault node attributes - selectedEdgeAttributes(optional)
EdgeAttributesSelected edge attributes - selectedNodeAttributes(optional)
NodeAttributesSelected node attributes
- edgeAttributes(optional)