Skip to content
  1. API
  2. Ogma

Ogma.rules

Rules API: functions to create rules for styling nodes and edges.

ogma.rules.map(options)

Create a function that, given a node or edge, returns a value based on a mapping "any data -> any value".

Arguments

  • options object
    • fallback(optional) any|Array<any> Value(s) to assign when the data value is not specified in the mapping.
    • field PropertyPath Data property path on which to retrieve the value to be mapped
    • values(optional) {[key: string]: any} Mapping that associate data value to output value.

Returns

ogma.rules.slices(options)

Create a function that, given a node or edge, returns a value based on a mapping "numerical data -> any value"

Arguments

  • options object
    • fallback(optional) any Value to assign when the property is not a number.
    • field PropertyPath Data property path to "slice"
    • reverse(optional) boolean[=false] By default low values for data properties are given low output values. Setting this to true reverse this behavior.
    • stops(optional) {min: number, max: number}|Array<number> Indicates the boundaries of the slices. If an object is specified, it must indicates the minimum and maximum values the data property can have. If it's an array, two consecutive elements indicate the boundaries for a slice. By default, the slices will be determined using the current minimum and maximum value of the data property.
    • values {nbSlices: number, min: number, max: number}|Array<any> Indicates the possible output values for the slices. If an object is specified, there will be nbSlices possible output values, with values from min to max (at regular intervals). If an array is specified, it indicates the different possible values.

Returns

ogma.rules.template(template)

Returns a function that, given a node or edge, returns a string by replacing a pattern in the string by the according data property.

Arguments

  • template string String in which "}" will be replaced by the data property "foo".

Returns