API Reference

Here you’ll find reference documentation for every JavaScript object, function, event and option in the KeyLines API. You’ll see tags and buttons attached to items:

Alpha
Beta

This gives you the status of the latest features we’ve added to KeyLines. The tags link to Alpha/Beta Features.

async

This is an asynchronous function, meaning it doesn't return a result directly to the caller. The tag links to more details about Asynchronous JavaScript.

chart

Tags like this remind you which namespace a method, object or event belongs to.

deprecated

We intend to end support for this item in future, and recommend that you stop using it now. The tag links to the list of current Deprecations.

getter/setter

This tag tells you when a function is both a getter and setter.

graph engine only

This method is only available in the Graph Engine and is separate from the methods used to render charts. The tag links to more details about the Graph Engine.

required

This property is mandatory. For example, id properties must be included on nodes and links.

Item Format

KeyLines uses JavaScript objects for defining visual appearances.

The chart object lets you load JSON data into the chart. In this example, only the type, id, id1, id2 and subject properties are required:

let data = {
  type: 'LinkChart',           // this must be exactly this string
  items: [
    { 
      id: 'node1',             // the identity of the node
      type: 'node',            // the type of the item: must be 'node'
      c: 'blue'                // the fill colour (optional)
    },
    { 
      id: 'node2',             // the identity of the node
      type: 'node',            // the type of the item: must be 'node'
      c: 'blue'                // the fill colour (optional)
    },
    {
      id: 'link1-2',           // the identity of the link
      id1: 'node1',            // the identity of the node at one end
      id2: 'node2',            // the identity of the node at the other end
      type: 'link',            // the type of the item: must be 'link'
      c: 'rgb(216, 30, 91)'    // the link colour (optional)
    },
    {
      id: 'annotation1',       // the identity of the annotation
      subject: 'node1',     // the identity of the annotated item
      type: 'annotation',      // the type of the item: must be 'annotation'
      t: { t: 'Annotation Label' },  // the annotation text (optional)
    }
  ]
};
required
An array of nodes, links and annotations.
required
'LinkChart'
A KeyLines Chart type - must be 'LinkChart'.

Nodes are the basic objects that you use to build a graph.

By default, nodes don't have a defined body unless their background is specified. To create a defined body, set a background fill colour (c), a font icon (fi), or a background image (u).

let data = {
  type: 'LinkChart',
  items: [
    {
      id: 'node1',
      type: 'node',
      c: '#43976C',
    },
  ],
};

Either font icons or images can also be used alongside a background fill colour as a top layer over the coloured node.

You can set the properties of nodes using setProperties.

string(Colour)
default: No border
The border colour.
boolean
default: false
Whether the node is displayed in the background.
number | string | number[] | object
default: '0 0 0 0'
The radius of the corners. Accepts a single number setting equal radius to all corners, a string of numbers separated by spaces (ordered top left, top right, bottom right, bottom left), an array of numbers separated by commas, or an object setting values for individual properties such as topLeft or bottomRight.
"solid" | "dashed"
default: 'solid'
The style of the border line.
An object describing the bubble shown on the node. Deprecated as we recommend using annotations instead.
number
default: 4
The width of the node's border.
string(Colour)
The node background fill colour. Can also be set to 'rgba(0,0,0,0)' to create a fully transparent node with a defined body.
boolean
default: false
Whether the image should be a cutout circle from the original image. Does not apply to font icons.
object
The d parameter stands for data. Use this to store custom data on the node.
An object describing the donut border shown on the node. Only applies to circle nodes - nodes with sh (shape) property set to 'circle'. If both donut and b are set then donut takes precedence.
number
default: 1
The enlargement factor for the node. Does not apply to nodes with w and h specified.
boolean
default: false
Whether the label should be displayed in bold font.
string(Colour)
default: white with alpha channel
The background colour of the font.
string(Colour)
default: black
The colour of the label font.
string
The font family to use for the label. The default is inherited from the fontFamily setting of chart.options().
FontIcon | null
The font icon used on the node.
number
default: 14
The font size (px) of the node label. By default the font size will scale with the node's e property.
An array of objects describing the glyphs shown on the node.
number | "auto"
When specified with w: the height of the node in world coordinates. Set to 'auto' to fit the node height to any number or length of labels inside.
The halo shown on the node. There are ten halo properties, ha0, ha1, ha2, etc., up to ha9.
boolean
default: false
Whether the node is hidden. See also show and hide.
required
string
The identity of the node. Must be unique across all items in the chart. Must not start with an underscore or end with a '\' character.
number
default: 54
The minimum height of a node.
number
default: 54
The minimum width of a node.
The style of the open combo.
string(Colour)
default: 'grey'
The border colour.
number | string | number[] | object
default: '0 0 0 0'
The corner radius. Accepts a number to set radius to all corners, a string of space-separated numbers ( top left, top right, bottom right, bottom left), an array of comma-separated numbers, or an object setting values for properties such as topLeft or bottomRight.
"solid" | "dashed"
default: 'solid'
The style of the border line.
number
default: 1
The border width.
string
default: 'light grey'
The background colour of the open combo.
An array of objects describing the glyphs shown on the open combo.
number
The height of the open rectangular combo. Set to fit all content when the combo is created.
boolean
default: false
Whether resize handles are shown on open combos.
string | NodeLabel | NodeLabel[]
  • string - A simple text string label.
  • Beta NodeLabel - A single label object that can contain label styling properties.
  • Beta NodeLabel[] - An array of objects to add multiple labels where each label can be styled individually.

For more details about label styling see the Advanced combo styling documentation.

number
The width of the open combo. This is automatically set to fit all content when the combo is created. Set this option after the combo has been created.
string | null
The id of the parent node, if it is a member of a combo. Can be set explicitly during combo creation, but after that you should use chart.combo().transfer() to change it.
Location
An object describing the position of the node on the Leaflet map.
required
number
The latitude in degrees that this node is positioned at on a Leaflet map. Should be in the range -90 to 90, but larger values will be rounded to ±90 respectively.
required
number
The longitude in degrees that this node is positioned at on a Leaflet map. Should be in the range -180 to 180 but larger values will wrap at the antimeridian.
boolean
default: false
Whether resize handles are shown on a legacy shape node. Shape nodes are drawn behind other chart items and are only available when legacyShapeNodeBehaviour is enabled.
"circle" | "box"
default: 'circle'
The node's shape. Set to 'box', without setting h and w, to create a scalable square node. Defaults to 'box' for nodes with h and w specified.
string | NodeLabel | NodeLabel[]
default: No label
  • string - A simple text string label.
  • Beta NodeLabel - A single label object that can contain label styling properties.
  • Beta NodeLabel[] - An array of objects to add multiple labels where each label can be styled individually.

For more details about label styling see the Advanced label styling documentation.

boolean
default: true for nodes / false for nodes with images
If true, labels are shown in the centre of the node. If false, labels are shown at the bottom of the node. Deprecated as we recommend using the position option instead.
required
'node'
The type of the item.
string
The URL of the image used on the node. To prevent non-square images from being distorted, set the node dimensions in w and h node properties in proportion to the aspect ratio of the image.
number | "auto"
When specified with h: the width of the node in world coordinates. Set to 'auto' to fit the node width to any number or length of labels inside.
number
default: 0
The node position along the X-axis, in world coordinates.
number
default: 0
The node position along the Y-axis, in world coordinates.

In KeyLines, connections between nodes are called links. Links represent connections in your data and are used to show network structure. You can set the properties of links using setProperties.

boolean
default: false
Whether to show an arrow at the id1 end.
boolean
default: false
Whether to show an arrow at the id2 end.
number
default: 0
The distance to back-off from end id1 as a ratio of the total length of the link line. Value in the range 0 to 1.
number
default: 0
The distance to back-off from end id2 as a ratio of the total length of the link line. Value in the range 0 to 1.
boolean
default: false
Whether the link is displayed in the background.
object

The border around the link label. If set for multiline labels, merges all labels into a single label container.

string(Colour)
default: No border
The border colour.
number | string | number[] | object
default: '0 0 0 0'
The radius of the label corners. Accepts a single number setting equal radius to all corners, a string of numbers separated by spaces (ordered top left, top right, bottom right, bottom left), an array of numbers separated by commas, or an object setting values for individual properties such as topLeft or bottomRight.
number
default: 4
The border width. Requires colour to also be set.
An object describing the bubble shown on the link. Deprecated as we recommend using annotations instead.
string(Colour)
default: 'grey'
The colour of the link line.
string(Colour)
If specified, the link will have a colour gradient, with colour c at the id1 end and colour c2 at the id2 end. The transition setting of linkStyle controls the gradient's appearance.
object
The d parameter stands for data. Use this to store custom data on the link.
boolean
default: false
Whether the label should be displayed in bold font.
string(Colour)
default: white with alpha channel
The background colour of the font.
string(Colour)
default: 'black'
The colour for the label font.
string
The font family to use for the label. The default is inherited from the fontFamily setting of chart.options().
boolean | FlowOptions
default: false
Options to customise the flow animation on the link. Set to true to enable flow with a default velocity of 2. Note that flowing links are always shown as dashed (overriding the ls property).
number
default: 2
The velocity of the flow on the link. Positive values flow from id1 to id2, and negative from id2 to id1. Must be in the range -10 to 10.
number
default: 14
The font size (px) of the link label.
An array of objects setting the glyphs in the link centre next to the label. To add a glyph at a link end, set the g property within t1 or t2.
boolean
default: false
Whether the link is hidden. See also show and hide.
required
string
The identity of the link. This must be unique across all items in the chart. It must not end with a '\' character.
LinkShapeOptions
The shape and orientation of the path taken by the link.
"horizontal" | "vertical"
If name is set to 'angled' or 'curved', the direction in which the link attaches to its nodes.
required
"direct" | "curved" | "angled"
The shape of the path taken by this link:
  • 'direct' - either straight or, when offset, following an arc.
  • 'curved' - a curved path.
  • 'angled' - a straight, branching path: useful for hierarchical data sets. Currently in beta.
"solid" | "dashed" | "dotted"
default: 'solid'
The style of the link line.
number
default: 0

Overrides automatic calculation of link offsets, so can be used to force direct links to follow an arc. Increasing off increases the distance between the midpoint of the link and the straight line joining its ends. If off is set for any link in a set of links between two nodes, then it defaults to 0 for any other links in that set.

Note: When chart.layout runs with default settings, off is overriden because straighten is true. To prevent this, and preserve specified offsets, set straighten to false.

Similarly, when chart.combo().arrange() runs with default settings, off is overriden because straighten is true. To prevent this, and preserve specified offsets, set it to false.

For self links, this option specifies how far the link is offset from its default position close to the node; see Self Link Offsets.

number | string | number[] | object
default: '2 2 0 2'
The distance between the link label text and the label edge. Borders are excluded. If used on multiline labels with border set, applies to the whole label container.
string | null
The id of the parent combo or link (if it is a member of a combo). Note that parentIds for links are calculated automatically and cannot be set.
0 | 1
default: 0
The priority of the link; see Prioritising links.
string
The label positioned at the centre of the link. For multiline labels, use '\n' or '\r' to force a line break.
string | LinkEndLabel
The link label positioned at the id1 end. For multiline labels, use '\n' or '\r' to force a line break. String values inherit styling from the label at the link's centre.
The border around the link label. Note that if t1 / t2 inherit the styling in the border object, any unspecified values will be set to defaults.
boolean
Whether the label should be displayed in bold font. The default is inherited from the link's fb setting.
string(Colour)
The background colour of the font. The default is inherited from the label at the centre of the link.
string(Colour)
The colour for the label font. The default is inherited from the label at the centre of the link.
string
The font family to use for the label. The default is inherited from the label at the centre of the link.
number
The font size (px) of the link label. The default is inherited from the label at the centre of the link.
An array of objects describing the glyphs shown in the centre of link next to the label.
number | string | number[] | object
default: '2 2 0 2'
The distance between the link label text and the label edge. Borders are excluded. If used on multiline labels with border set, applies to the whole label container.
string
The link label. For multiline labels, use '\n' or '\r' to force a line break.
string | LinkEndLabel
The link label positioned at the id2 end. For multiline labels, use '\n' or '\r' to force a line break. String values inherit styling from the label at the link's centre.
number
default: 1
The width of the link line. Also affects the size of arrowheads if present.
required
string
The identity of the node at one end of the link.
required
string
The identity of the node at the other end of the link. This may be the same as id1 to create a "self link" if the selfLinks chart option is enabled.
required
'link'
The type of the item.

Beta

Annotations are notes connected to items in the chart. The following chart items can be annotated:

  • Nodes
  • Links
  • Open and closed combos

See also the Annotations documentation for more information.

Annotations are added to the chart as a special type of an item that contains the id or ids of the annotated item(s) in the subject property:

let data = {
  type: 'LinkChart',
  items: [
    {
      id: 'annotation1',
      type: 'annotation',
      subject: 'node1',
      t: { t: 'Annotation Label' },
      position: { angle: 'ne' },
      connectorStyle: { container: 'rectangle' }
    },
    {
      id: 'node1',    // node1 is the annotation subject
      type: 'node',
      c: 'rgb(45,105,160)',
    },
  ]
};

Annotations are drawn in a separate layer on top of the chart and their position is relative to their subjects. When a layout is run or when their subjects move, annotations keep their position relative to their subjects.

Annotations that are linked to chart items are only displayed if at least one of the annotated items is present.

Notes:

  • Annotations cannot be selected or backgrounded.
  • Annotations are not shown on a Leaflet map.
  • Annotations for time bar are not supported.
string
default: 'rgb(230, 230, 230)'
The border colour.
number | string | number[] | object
default: '3, 3, 3, 3'
The corner radius of the annotation. Accepts a single number setting equal radius to all corners, a string of numbers separated by spaces (ordered top left, top right, bottom right, bottom left), an array of numbers separated by commas, or an object setting values for individual properties such as topLeft or bottomRight.
"solid" | "dashed"
default: 'solid'
The style of the border line.
number
default: 1
The width of the border.
string
default: 'white'
The fill colour.
ConnectorStyle
The style of the connector between the annotation and the annotated subject(s). The connector has three parts:
  • A line towards the subject, or multiple lines if there are multiple subjects.
  • The decoration at the subject end of the line(s). Can be set in the subjectEnd option for any annotations.
  • A container around the subject(s). Can be set in the container option for node and combo annotations.
string
default: 'black'
The colour of the connector.
"none" | "circle" | "rectangle"
default: 'none'
Whether there should be a container around the subject(s):
  • 'none' - No container is drawn. When annotating links, this is the only option available.
  • 'circle' - Draws a circle around the subject node(s) or combo(s).
  • 'rectangle' - Draws a rectangle around the subject node(s) or combo(s).
"solid" | "dashed"
default: 'solid'
The style of the connector line(s) and subject container(s).
"none" | "dot" | "arrow"
default: 'dot'
The decoration shown at the subject end of the connector line.
number
default: 1
The width of the connector line(s) and the container lines. Also affects the size of subjectEnd. Set to 0 to hide the connector and create an annotation that isn't visibly connected to subjects but remains in a relative position to them.
object
The d parameter stands for data. Use this to store custom data on the annotation.
An array of objects describing the glyphs shown on the annotation.
number | "auto"
default: 'auto'
The annotation's height in view coordinates. When set to 'auto', the annotation automatically sizes to fit any content inside. When setting exact dimensions for annotations, both h and w need to be set.
boolean
default: false
Whether the annotation is hidden.
required
string
The identity of the annotation. Must be unique across all items in the chart. Must not start with an underscore or end with a '\' character.
number
default: 10
The minimum height of an annotation.
number
default: 56
The minimum width of an annotation.
object
The position of the annotation relative to the subjects it annotates.
string | number
default: 0
The angle at which the annotation is positioned relative to its subject(s). Use a compass point value ( 'n', 'ne' etc.) or integer degrees clockwise from the top (in the range 0-359).
number
default: 20
Distance between the annotation and its subject(s) in view coordinates.
required
string | string[]
The id(s) of the item(s) to which the annotation refers.
default: No label
The annotation label.
required
"annotation"
The type of the item.
number | "auto"
default: 'auto'
The annotation's width in view coordinates. When set to 'auto', the annotation automatically sizes to fit any content inside. When setting exact dimensions for annotations, both h and w need to be set.

Beta

Labels show information on nodes. They can contain text, font icons or images.

A basic label is a text string set directly in the t property such as t: 'label 1', but the t property also accepts an object that lets you further customise the label styling:

t:
  {
    t: 'Label',
    b: 'rgb(45,105,160)'
  }

or an array of objects that lets you add multiple labels and customise styling for each label:

let data = {
  type: 'LinkChart',
  items: [{
    id: 'node1',
    type: 'node',
    c: 'rgb(45,105,160)',
    t: [
        {
          fi: { t: 'fas fa-exclamation-circle' },
          fc: 'rgb(216, 30, 91)',
          fbc: 'transparent',
          position: 'ne',
        },
        {
          t: 'node label',
          borderRadius: 5,
          position: 's',
          fbc: 'rgb(122,193,226)',
        },
        {
          u: '/images/icons/pearlgirl.jpg',
          position: { horizontal: 'centre'},
        },
      ],
    }]};

For more details, see Advanced label styling.

Labels on open and closed combos

Closed combos accept the same node label API as nodes and have the same defaults.

Open combos accept the same node label API, but their default label position is outside and below the combo to avoid overlapping the combo content. For more details, see Advanced combo styling.

string(Colour)
default: No border
The colour of the label container's border.
number | string | number[] | object
default: '0 0 0 0'
The radius of the label's corners. Set this as a single value to be applied to all corners, or set individual corners as a string of space-separated numbers ( top left, top right, bottom right, bottom left), an array of comma-separated numbers, or an object setting values for properties such as topLeft or bottomRight.
number
default: 4
The width of the label's border.
boolean
default: parent node fb / false
Whether the label content should be in bold font.
string(Colour)
default: parent node fbc / white with alpha channel
The colour of the label's background. The default is inherited from the parent nodes's fbc, if it's set. Ignored if u is set.
string(Colour)
default: parent node fc / black
The font colour of the label content. The default is inherited from the parent nodes's fc, if it's set.
string
The font family to use for the label content. The default is inherited from the parent node ff if set, or from the fontFamily setting of chart.options().
The font icon to use as the label content. To set its position and offset, use position and margin, and scale it using fs. If both fi and t are specified, only fi is shown. fi is ignored if u is also specified.
number | "auto"
default: parent node fs / 14
The font size. Set to 'auto' to size the font automatically depending on the node/combo size. Note that if both w and h node dimensions are set to 'auto', setting the font size to 'auto' will revert to the node's font size instead of trying to fit to the available space.
number | string | number[] | object
default: '0 0 0 0'
The distance between the label and another label, or the label and its parent node/combo. Calculated outside of label or node/combo borders.
See also Margin, padding and borders for details and accepted value formats.
number
default: 54 for images
The height of the label container:
  • For text and font icon labels: the maximum height. Use this to limit the text height when fs is set to 'auto'.
  • For image labels: the image height if maxWidth also set.
number
default: 54 for images
The width of the label container:
  • For text and font icon labels: the maximum width. Use it to reduce the text width before a line break when textWrap is set to 'normal', or set the maximum text width when fs is set to 'auto'.
  • For image labels: the image width if maxHeight also set.
number | "stretch"
The minimum height of the label container. Will always fit the content. Set to 'stretch' to draw the label across the whole node/combo height. Ignored if u is set.
number | "stretch"
The minimum width of the label container. Will always fit the content. Set to 'stretch' to draw the label across the whole node/combo width. Set minWidth when textWrap is set to 'normal' to increase the minimum text width before a line break. Ignored if u is set.
number | string | number[] | object
default: '2 2 0 2'
The distance between the label content and the label container. Borders are excluded.
See also Margin, padding and borders for details and accepted value formats.
string | object
Sets the label position in relation to the node.
The compass point values ( 'n', 'ne' etc.) place labels outside the node/combo.
An object with horizontal and/or vertical properties places labels inside the node/combo.
Default position for nodes and closed combos is in the middle and centre of the node.
Default position for open combos is outside and below the combo.
If there are multiple labels with completely or partially overlapping positions, the label which was processed later will be drawn over the label which was processed earlier.
See also Label positioning and Advanced combo styling for details.
"left" | "right" | "centre" | number
The horizontal position. The number in world coordinates sets the horizontal position of the label's top left corner in relation to the top left corner of the node/combo.
"top" | "bottom" | "middle" | "inherit" | "initial" | number
The vertical position. The number in world coordinates sets the vertical position of the label's top left corner in relation to the top left corner of the node/combo. The 'initial' value puts the label in the default position.
The 'inherit' value puts the label on the same line as the previous label:
t: [
  // label 1 has no vertical position, set label 2 to 'inherit' to place it inline
  { t: 'label 1' },
  { t: 'label 2', position: { vertical: 'inherit' } },
]
Similarly, setting two labels to the same vertical position will also put them on the same line:
t: [
  // set label 2 to the same vertical position as label 1 to place it inline
  { t: 'label 1', position: { vertical: 'bottom' } },
  { t: 'label 2', position: { vertical: 'bottom' } },
]
string
The text to use as the label content. t is ignored if fi or u is also specified.
object
The alignment of text or font icons inside the label.
"left" | "right" | "centre"
default: 'centre'
The horizontal alignment.
"top" | "bottom" | "middle"
default: 'middle'
The vertical alignment.
"initial" | "normal"
default: 'initial'
Text wrapping inside the label. By default, no text wrapping is used. If set to 'normal', the label content is wrapped on whitespaces created by the space bar. To control line breaks, use minWidth / maxWidth, or the '\n' or '\r' characters. To set a fixed width for a wrapped label, set both minWidth and maxWidth to the same value.
string
The url of the image to be used as the label content. Set its size by specifying both maxHeight and maxWidth. See Image labels for more details.

Beta

Labels show information on annotations. The information can be in a format of text, font icons or images.

The t property for annotations accepts an object to add a single styled label, or an array of objects to add multiple styled labels.

let data = {
  type: 'LinkChart',
  items: [
    {
      id: 'annotation1',
      type: 'annotation',
      subject: 'node1',
      t: [
        {
          fi: { t: 'fas fa-exclamation-circle' },   // coloured font icon label
          fc: 'rgb(216, 30, 91)',
        },
        {
          t: 'Annotation Label',    // text label positioned vertically inline to the font icon
          position: { vertical: 'inherit' },
        },
      ],
    },
    {
      id: 'node1',    // node1 is the annotation subject
      type: 'node',
      c: 'rgb(45,105,160)',
    },
  ],
};

For more information about annotation labels, which behave just like regular node labels, see also Advanced label styling docs.

string
default: No border
The colour of the label border.
number | string | number[] | object
default: '0 0 0 0'
The label corner radius. Accepts a number to set radius to all corners, a string of space-separated numbers ( top left, top right, bottom right, bottom left), an array of comma-separated numbers, or an object setting values for properties such as topLeft or bottomRight.
number
default: 4
The width of the label border.
boolean
default: false
Whether the label should be in bold font.
string
default: transparent
The label background colour.
string
default: black
The label font colour.
string
The font family to use for the label. The default is inherited from the fontFamily setting of chart.options().
The font icon to use as a label.
number | "auto"
default: 14
The label font size. Set to 'auto' to size the font automatically depending on the annotation size. Note that 'auto' font sizing shouldn't be used when parent annotation's width (w) and/or height (h) is also 'auto'.
number | string | number[] | object
default: '0 0 0 0'
The distance between the label and another label or the parent annotation. Calculated outside of label or annotation borders.
See also Margin, padding and border for details and accepted value formats.
number
The maximum height of the label. Use this option when fs is set to 'auto' to set the maximum height of the text.
number
default: 240
The maximum width of the label. Set custom maxWidth when textWrap is set to 'normal' to reduce the maximum text width before a line break, or when fs is set to 'auto' to set the maximum text width.
number | "stretch"
default: 0
The minimum height of the label. Will always fit the content. Set to 'stretch' to draw the label across the whole annotation height.
number | "stretch"
default: 0
The minimum width of the label. Will always fit the content inside. Set to 'stretch' to draw the label across the whole annotation width. Set custom minWidth when textWrap is set to 'normal' to increase the minimum text width before a line break.
number | string | number[] | object
default: '10 10 10 10'
The distance between the label content and the label edge. Borders are excluded.
See also Margin, padding and border for details and accepted value formats.
Sets the label position.
Accepts a string with a compass point value ( 'n', 'ne' etc.) to place a label outside the annotation, or an object with horizontal and/or vertical properties to place a label inside the annotation.
Default annotation label position is { horizontal: 'centre', vertical: 'middle' }.
See also Label positioning for details.
string
The label text.
object
The alignment of the content inside the label.
"left" | "right" | "centre"
default: 'left'
The horizontal alignment.
"top" | "bottom" | "middle"
default: 'top'
The vertical alignment.
"normal" | "initial"
default: 'normal'
Text wrapping inside the label. By default, no text wrapping is used. If set to 'normal', the label content is wrapped on whitespaces created by the space bar. To control line breaks, use minWidth / maxWidth, or the '\n' or '\r' characters. To set a fixed width for a wrapped label, set both minWidth and maxWidth to the same value.
string
The url of the image to be used as the label content. Set its size by specifying both maxHeight and maxWidth. Align the image within the node using position and margin, and set a border with b, borderRadius, and bw.

Deprecated
Bubbles are deprecated in favour of annotations, which are more modern and customisable.

Bubbles are sub-items that can be used to add additional text to nodes or links. You can only show one bubble per item.

Bubbles can be shown in one of four positions:

  • North East ('ne')
  • South East ('se')
  • South West ('sw')
  • North West ('nw')

Bubbles are added to items as follows:

let data = {
  type: 'LinkChart',
  items: [
    {
      id: 'node1', t: 'label', type: 'node', u: 'person.png', x: 100, y: 150,
      bu: {
        c: 'rgb(255, 0, 0)',  // the bubble fill colour
        p: 'ne',              // bubble in NE position. use 'se', 'sw', 'nw' for the other positions
        t: 'Bubble'           // the bubble text
      }
    }
  ]
};
string(Colour)
default: 'grey'
The colour of the bubble border.
string(Colour)
default: 'white'
The colour of the bubble fill.
boolean
default: false
Whether the bubble text should be displayed in bold font.
string(Colour)
default: 'black'
The colour for the bubble text font.
string
The font family to use for the bubble text. The default is inherited from the fontFamily setting of chart.options().
number
default: 14
The font size (px) of the bubble text.
An object describing the glyph shown in the bubble.
"ne" | "se" | "sw" | "nw"
default: 'ne'
The position of the bubble relative to the node or link. The 4 positions are compass points.
required
string
The text for the bubble.

Glyphs are sub-items displayed on nodes, links, annotations or combos to convey additional information such as a status or a counter.

A glyph can be a simple coloured circle, and/or show a font icon, an image or a text. If multiple types are set in the same glyph object, only one is shown in this order:

  1. text t (highest priority)
  2. image u
  3. font icon fi
  4. coloured circle c (lowest priority)

To move icons and images inside glyphs from their default positions, use the imageAlignment option.

Glyphs on Nodes and Annotations

Glyphs are drawn along a border of the annotation or node (incl. closed combo node). They are added as an array of objects to the g property.

There are two styles of positioning:

  • Compass points, e.g. 'n' for north, 'se' for south east etc.
  • Integers in the range 0-359, where numbers represent the angle from the centre of the item, measured in degrees clockwise from north.

Glyphs on a single node or annotation must use the same positioning method (i.e., all use compass points or all use angles). In an array, glyphs are only drawn if they use the same positioning method as the first glyph.

You can have as many glyphs as you like, but only one glyph is allowed in each position. If multiple glyphs are set in one position, only the first one is drawn.

let data = {
  type: 'LinkChart',
  items: [
    {
      id: 'node1',
      type: 'node',
      c: '#43976C',
      t: 'node label',
      g: [{
          p: 'ne',                        // north-east corner position, position required for nodes
          c: 'red',                       // fill colour required for text to show
          t: '!',                         // the glyph text
          border: { colour: 'orange' },   // the border around the glyph
      }],
    },
    {
      id: 'annotation1',
      type: 'annotation',
      subject: 'node1',
      t: { t: 'annotation label' },
      g: [{
          p: 'ne',
          c: 'blue',
          t: '!'
      }],
    },
]};
Glyphs on Links

Links can have any number of glyphs that can be added either in the centre or at the link ends (t1 and t2). Glyphs are added as an array of objects to the g property:

let data = {
  type: 'LinkChart',
  items: [
    { id: 'n1', type: 'node', c: '#43976C' },
    { id: 'n2', type: 'node', c: '#43976C' },
    {
      id: 'link1',
      type: 'link',
      id1: 'n1',
      id2: 'n2',
      t: 'link label',
      g: [
          { c: 'red', t: '!' },       // array of glyphs in the link centre,
          { c: 'orange', t: '!' },    // shown left to right
      ],
      t1: {
        g: [ 
          { c: 'blue', t: '!' }       // array of glyphs at the left link end, shown left to right
        ],
      },
}]};
Beta Glyphs on Open Combos

Glyphs are drawn along an open combo's border. Depending on how the combo was created, glyphs are added as an array of objects to the g property of the openStyle property or the oc property.

The positioning of glyphs on open combos is the same as the positioning of glyphs on nodes, which means that either compass points (e.g. 'n', 'e', 'se') or integers (in the range 0-359) can be used.

Glyphs on a single open combo must use the same style of positioning (i.e., all use compass points or all use angles). In an array, glyphs are only drawn if they use the same positioning method as the first glyph.

You can have as many glyphs as you like, but only one glyph is allowed in each position. If multiple glyphs are set in one position, only the first one is drawn.

Note: The r property is not supported for glyphs on open combos.

let data = {
  type: 'LinkChart',
   items: [
     {
       id: 'newcombo1',
       type: 'node',
       c: 'blue',
       oc: {
         g: [{
             p: 'nw',                // north-west corner position, position required for combos
             c: 'rgb(255, 0, 0)',    // fill colour required for text to show
             t: '!',                 // the glyph text
             border: {               // the border around the glyph
               colour: 'green',
               width: 4,
             },
         }],
       },
     },
     { id: 'newchild1', parentId: 'newcombo1', type: 'node', c: 'red' },
     { id: 'newchild2', parentId: 'newcombo1', type: 'node', c: 'red' },
   ],
};
boolean
default: false
Set to true for an animated glyph.
string(Colour)
default: 'grey'
The glyph border colour. Borders on image glyphs without a glyph background are not supported. Deprecated as we recommend using border instead.
object
The border around the glyph. Borders on image glyphs without a glyph background are not supported. If both b and border are set, border takes precendence.
string
The border colour.
number
default: 2
The border width. The maximum value is 18.
string(Colour)
The glyph fill colour. Required for text glyphs. If set for image and font icon glyphs, images and font icons are shown inside the glyph. If not set, images and font icons also replace the glyph background.
number
default: 1
The enlargement factor for the glyph.
boolean
default: true
Whether the glyph's label should be displayed in bold.
string(Colour)
default: 'white'
The font colour for the glyph's label.
string
The font family to use for the glyph's label. The default is inherited from the fontFamily setting of chart.options().
The font icon to use for the glyph.
string | number
The position of the glyph relative to the node. Only supported and required on nodes and open combos. Use compass point strings ('n', 'se', etc.) or integer degrees clockwise from the top (in the range 0-359).
number
Overrides the distance from the centre of the node at which the glyph is drawn. Only available when the glyph's position is a number. If specified, link ends will no longer avoid the glyph. Not supported by open combos.
string
The text label to use for the glyph. Standard glyphs (where w is set to false) show a maximum of four characters. Wide glyphs (where w is set to true) show a maximum of 25 characters.
string
The URL of the image to use for the glyph. The image can be any size, but 64X64 should be adequate.
boolean
default: false
If true, the glyph width will adjust automatically to fit up to 25 characters, forming a rounded rectangle. Longer labels are truncated. Not supported by glyphs on links.

Font icons are vector-based glyphs embedded in font files, where specific character codes are mapped to icons.

In KeyLines, font icons can be used as node icons, glyph icons (on nodes, links, annotations and combos) and label icons (in node and annotation labels).

You can position and scale them using the imageAlignment chart option and dynamically change their fill colour using the c property.

To use font icons, you must install them in your application, import and load them into KeyLines and set them in the iconFontFamily option. See Fonts and Font Icons for details.

The referenced icons must be on the same domain as the KeyLines library, otherwise your browser will mark them as insecure and prevent them from loading. See Cross-Origin Images (CORS) for details.

let data = {
  type: 'LinkChart',
  items: [
    {
      id: 'user471',
      type: 'node',
      c: 'green',                                                //  green node
      fi: { c: 'white', t: 'fas fa-user' },                      //  white font icon inside the node
      g: [
        {
          fi: { c: 'red', t: 'fas fa-exclamation-triangle' },    // red glyph icon   
          p: 'ne',                                               // in north-east corner position of node
        },
      ],
      t: [
        {
          t: 'Membership Expired: 01/2025',
          position: 's',
        },
        {
          fi: { c: 'red', t: 'fas fa-exclamation-triangle' },    // red glyph icon  
          position: { vertical: 'inherit' },                     // placed inline following the text label
        },
      ],
    },
  ],
};

If an image is also specified for a node in the u property, the image takes precedence and the font icon is ignored.

string(Colour)
default: 'black'
The font icon fill colour.
string
The font family to use for the font icon. The default is inherited from iconFontFamily.
required
string | number
The font icon to show. Pass in a CSS class name or an escaped Unicode code point, e.g. '\u{f007}'.

Halos are circular rings that can be added to nodes. A node can have up to ten halos, on properties named ha0 to ha9.

Halos are added to nodes as follows:

let data = {
 type: 'LinkChart',
 items: [
   {
     id: 'node1', t: 'label', type: 'node', u: 'person.png', x: 100, y: 150,
     ha0: {
       c: 'rgb(0, 0, 255)',    // the halo fill colour
       r: 100,                 // the halo radius
       w: 20                   // the halo width
     }
   }
 ]
};

Setting the halo object to null or undefined removes the halo.

required
string(Colour)
The colour of the halo.
required
number
The radius of the halo.
required
number
The width of the halo.

Nodes can have donuts around their borders. They can be split into segments to represent relative quantities, similar to the way sectors work on a pie chart. Donuts cannot be added to nodes with sh property set to 'box'.

Donuts are added to nodes as follows:

let data = {
 type: 'LinkChart',
 items: [
   {
     id: 'node1', type: 'node', c: '#aaa', x: 100, y: 150,
     donut: {
       // the values for each donut segment
       v: [10, 30, 25, 40, 15],
       // the colour for each donut segment
       c: ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00'],
       w: 12,         // the width of the donut segments
       b: 'black',    // the colour of the border between segments
       bw: 1          // the width of the border between segments
     }
   }
 ]
};
string(Colour)
default: 'white'
The colour of the border between donut segments.
number
default: 2
The width of the border between donut segments.
string(Colour)
default: standard colours
An array giving the colour of each segment. It should contain the same number of elements as the v array. If not supplied, a default set of colours is used.
required
number[]
An array giving the size of each segment. Values must be positive. Segments are positioned clockwise around the node starting at the top. Do not animate changes that add or remove segments.
number
default: 10
The width of the donut segments. This doesn't include the border.

The time bar object lets you load JSON data in the following format into the time bar:

let data = {
 items: [
   { id: 'id1',     // 'id1' is the identity that the item relates to
     dt: [...],     // a timestamp or array of timestamps - either Date objects or numbers
     v:  [...],     // an optional value or array of values for each timestamp
                    // values must be numbers, there must be one for each timestamp
   },
   { id: 'id2',
     dt: [...],
     v:  [...]
   },
   ...
 ]
};

Time bar object properties are designed so that exactly the same data object can be loaded into both the chart and the time bar. Simply add the dt and optional v properties to the items.

object
The d parameter stands for data. Use this to store custom data on the item.
required
number | Date | TimePeriod | (number | Date | TimePeriod)[]
The time entry or time entries associated with this item. Either a single time entry or an array of time entries may be supplied. Each time entry may be either a JavaScript Date object, a millisecond number, or a TimePeriod object. See the Time Zones and JavaScript page for more details.
required
string
The id that the item is associated with. It must not end with a '\' character.
number | number[]
default: 1
The value associated with each time entry, for example, the amount of a transaction. Values must be greater than zero. The same number of values should be supplied as the number of time entries. If values are not supplied, then the time bar counts the number of timestamps, instead of adding up the corresponding values.

Each time bar item has a dt property that holds a time bar entry or an array of time bar entries. Each entry may be one of the following:

  • a Date object or millisecond number, representing an instant in time
  • a TimePeriod object, representing a period of time

The TimePeriod object has dt1 and dt2 properties that set the start and end of the time period.

To represent an open-ended time period, set the dt1 property only. To represent a time period without a start time, set the dt2 property only.

number | Date
The timestamp for the start of the time period, with numbers evaluated as milliseconds.
number | Date
The timestamp for the end of the time period, with numbers evaluated as milliseconds.

Colours can be specified in several formats:

  • One of the 17 CSS standard named colours, e.g., 'red'
  • Shorthand hexadecimal colours, e.g., '#F00'
  • Hexadecimal colours, e.g., '#FF0000'
  • rgb or rgba formats. For example
    • 'rgb(255, 0, 0)' - Red
    • 'rgba(255, 0, 0, 0.5)' - Red with an alpha blend of 50%

Note that the 130 extended CSS named colours are not supported.

IdMaps are objects containing properties where property names are ids of items and property values are the values assigned to the respective items.

const degreesResult = {
  node1id: node1degree,
  node2id: node2degree,
  ...
}

KeyLines

The KeyLines namespace contains functions for loading charts and time bars into your webpage.

The components object has all the current components loaded by the KeyLines wrapper. Components are accessed via their DOM id:

KeyLines.components['canvasID'].zoom('in');

Components are not created directly, but via KeyLines.create().

object
An object whose properties contain the individual component elements.

Allows asynchronous functions to be used with callbacks. This function is for backwards compatibility only.

KeyLines
A KeyLines object whose asynchronous functions can be handled with callbacks, or with both callbacks and promises simultaneously.

Calculates the coordinates of events relative to their target.

required
Event
A DOM or jQuery event.
object
An object containing the relative position coordinates.
number
The horizontal coordinate.
number
The vertical coordinate.

Sets the value of the crossorigin HTML attribute whenever KeyLines is trying to load an image from a third-party domain.

The function takes a callback function that should return the value of the HTML attribute as a string depending on your criterion. If corsAdapter() is not set or if the callback returns undefined, the crossorigin attribute defaults to 'anonymous'.

KeyLines.corsAdapter((url) => {
  if (url.startsWith('https://keylines.io/')) {
    return 'use-credentials';
  } else {
    return 'anonymous'
  }
});

required
function
A callback function which takes a URL of the CORS image as an argument and returns the value of the crossorigin HTML attribute as a string.
void
Not used.

Creates KeyLines components in your web page.

The create() function is asynchronous, and so returns a promise. If an error occurs, the error catch function will be called, passing the error parameter to it. Otherwise, the success function will be called with the result object as the new component or array of components.

// Load a single chart
KeyLines.create({ container: 'div1' })
  .then((result) => {
    chart = result;
  })
  .catch((err) => {
    // handle the error here
});
// Load two KeyLines components with a specific id
KeyLines.create([
    { container: 'chartDiv', type:'chart' },
    { container: 'timebarDiv', type:'timebar' }
])
  .then((result) => {
    [chart, timebar] = result;
})
  .catch((err) => {
    // handle the error here
});
required
A definition object describing the component to create, or an array of definition objects.
Promise
A Promise that resolves to a reference for the chart object.
string | HTMLElement | null
The DOM element or id where you want to insert the component. If set to null, the created component will be detached from any DOM element. Note that the KeyLines component will not render if the container's css style property has display: none, width = 0 or height = 0.
string
The id of the component. If not set, one will automatically be assigned.
The chart or time bar options for the new component (optional).
"chart" | "timebar"
default: 'chart'
The type of component to create.

Checks whether the current browser can show elements full screen.

To view the current state of browser support for the Fullscreen API with desktop and mobile devices, see Can I use Fullscreen API.

Use the toggleFullScreen() call to make an element full screen.

boolean
If true, the current browser can show elements full screen.

A helper to find the right Unicode character to use for the icon based on the class name:

let data = { id: 'user', type: 'node', fi: { t: KeyLines.getFontIcon('fas fa-user') } };   // retrieves the Unicode position

The getfontIcon() function is deprecated as you can set font icons directly:

let data = { id: 'user', type: 'node', fi: { t: 'fas fa-user' } };

This applies to both the t option on the fi property to set an icon, and the imageAlignment option to scale and position it.

See the Font Icons documentation for details.

required
string
The class names required to get the font icon.
number
The reference for the font icon.

The Graph engine can be used to perform traversals or other graph computations within a separate context from the chart. For more information see The Graph Engine.

Options for the graph engine.
A new instance of the graph engine used by KeyLines.
boolean
default: false
If true, links from a node to itself can be loaded into the graph engine. If false, self links are not loaded into the graph engine.

The info function returns an object containing useful information about how KeyLines is set up in your environment, including the KeyLines version number.
object
An object containing KeyLines information.

Defines which runtime KeyLines will use when calling KeyLines.create().

"auto" | "canvas" | "webgl"

The mode to use. Can be one of the following values:

  • 'auto': (default) KeyLines determines which runtime is available. Defaults to WebGL if supported.
  • 'webgl': Use WebGL Canvas. If WebGL isn't available, use HTML5 Canvas instead.
  • 'canvas': Use HTML5 Canvas.
string
The current mode.

Tells KeyLines where it can find various resources on your server. This function must be called before the KeyLines.create() function.

When many chart items use images from the same directory, the images path can be used to save repeated use of the directory path within the chart object.

By default the full path to images must be passed in the u parameter of nodes, e.g.,

const item = { t: 'label', u: '/path/to/very/deep/directory/person.png' };

Alternatively, using the images path:

// in the initialization code put this:
KeyLines.paths({ images: '/path/to/very/deep/directory/' });
// and in the item creation
const item = { t: 'label', u: 'person.png' };

The images path is also used for glyph images, the logo and the background watermark.

The images path must have a trailing slash (/) character.

required
PathsOptions
An object specifying the path to the image resources.
object
An object containing the current path settings.
string
The path to use for images.

Allows any given HTMLElement to be put in Full Screen mode, using the browser's full screen API.

Usually a containing div is made full screen, rather than the KeyLines component itself. You should change the sizes of any parts of the page in the handler function – this receives a boolean parameter which is true if new status is full screen, or false if not.

Note that this function does not support Promises.

required
HTMLElement
The element to be put in full screen. Cannot be null.
function
A callback function which will be called once the operation is complete.
void

Checks if the current device supports WebGL and meets the minimum requirements.

boolean
True when the device supports WebGL.

Chart

Chart functions allow you to draw content on the chart surface, zoom and pan around the chart, and perform layouts. To obtain a chart object to call these functions on, use KeyLines.create.

Allows custom animations to be made and chained together.

Pass a single item object (or an array of objects) in the form {id: id, propertyName1: value1, propertyName2: value2 }. Items with a matching id will be animated.

Animations can either be applied to numeric properties:

// first animate the node to (100, 100) in 300 milliseconds and then move another node to this position
chart.animateProperties({ id: 'id1', x: 100, y: 100 }, { time: 300 }).then(() => {
  return chart.animateProperties({ id: 'id2', x: 100, y: 100 }, { time: 500 });
});

Or to colours:

// changes the link colour to blue with an alpha blend of 0.5 in an animation lasting 300 ms
chart.animateProperties({ id: 'link1', c: 'rgba(0,0,255,0.5)' }, { time: 300 });

When animating properties in the top level object, you only need to specify the properties that you want to animate. When animating properties in the nested object, you need to specify both animated and unchanged properties:

chart.setProperties({ id: 'link1', fbc: 'yellow', t: 'link', t1: 'endLabel1', t2: 'endLabel2' });

// animating the nested fbc property for t1 and t2 requires repeating the t properties as well
chart.animateProperties([{ id: 'link1', w: 15, fbc: 'orange', t1: { t: 't1', fbc: 'red' }, t2: { t: 't2', fbc:'green' } }]);

See the relevant numeric and colour properties in Item Format.

Note: Animating properties is not supported in Advanced label styling for items inside the styled node label t object.

required
The item/s whose properties are to be changed.
Options to control the animation.
Promise
"linear" | "cubic"
default: 'linear'
The easing function for animation. If set to 'linear', the speed is constant. If set to 'cubic', the animation starts slow, speeds up and then finishes slow.
boolean
default: true
If true, the animation is queued until all previous queued animations have completed. If false, the animation begins immediately.
number
default: 1000
The time the animation should take, in milliseconds.

Places a set of nodes together in close proximity.

chart.arrange('grid', ['id1', 'id2', 'id3'], { fit: true, animate: true }).then(() => {
  // do more after arrange
});

The nodes are arranged in the specified shape in the order that they appear in the items array.

required
"grid" | "circle" | "radial"
The arrangement to use.
required
string[]
An array of the ids of the nodes to arrange.
Options to control the arrangement of the nodes.
Promise
A Promise.
boolean
default: true
Whether the result should be animated.
boolean
default: false
Whether to fit the chart into the window at the end of the arrangement.
"absolute" | "average" | "tidy"
default: 'average'
Controls the position of the group of arranged nodes.
  • 'absolute': use the x and y options to centre the arrangement.
  • 'average': use the average position of the nodes to centre the arrangement.
  • 'tidy': the chart is rearranged to position the nodes so they do not overlap with other nodes.
number
default: 5
Controls how close nodes are to each other. Must be in the range 0 to 10, with higher values being closer.
number
default: 700
If animated, the time the animation should take, in milliseconds.
number
default: 0
When position is set to 'absolute', the x coordinate of the centre of the nodes.
number
default: 0
When position is set to 'absolute', the y coordinate of the centre of the nodes.

Removes all items from the chart.

void

The combo namespace has methods for combining the nodes and links of a chart to simplify it. See Combo Functions.

The combo namespace which has functions for combining items together.

Returns an array of ids of all the nodes or shapes contained inside the given shape.

Shapes are legacy nodes that are drawn behind nodes and links. They are set by specifying w and h for nodes and setting the legacyShapeNodeBehaviour option to true.

Things to note:

  • If no nodes or shapes are contained within the parent shape, the function returns an empty array.
  • If one or both of w and h parent shape dimensions are set to 'auto', the function returns an empty array.
  • Hidden items are returned.
  • Open combos or their contents are not returned.
  • If the shape contains other items, their ids will be returned only if they are fully contained within the shape.
required
The definition of the shape.
string[]
The ids of the items contained in the shape (if any).
required
number
The height of the shape.
"circle" | "box"
default: 'box'
The type of shape.
required
number
The width of the shape.
required
number
The centre of the shape along the X-axis.
required
number
The centre of the shape along the Y-axis.

Creates a special type of drag that lets a user draw a new link starting from a specified node. As a result, it should always be called from within a drag-start event handler to ensure that the user is dragging:

chart.on('drag-start', (e) => {
  const { id, type } = e;
  if (type === 'node') {
    // override the default node dragger with create-link
    chart.createLink(id, 'newLink').then(() => {
      // do more after createLink
    });
  }
});

Note that this function allows the user to draw a new link during dragging. It does not create a new link immediately. To create a new link without user interaction, use setItem.

required
string
The id of the starting node. This node will be the id1 of the new link.
required
string
The id to set on the new link.
Options to control the style of the link.
Promise
A Promise that resolves with the id of the linked item, or null if the user did not create a link.
An object describing the style of the new link. Most of the optional link properties can be passed (except for id, id1, id2, type and off).

Destroys the current instance of the chart, freeing any allocated resources.

Note: This action cannot be undone. Create a new chart instance with KeyLines.create() to access the chart namespace.

chart.destroy()
void

Allows easy iteration over all the items in the chart. The handler is called with one parameter: the current item.

// write all the labels for each node to the console
chart.each({ type:'node' }, (item) => {
console.log(item.id, item.t);
});

For details of using chart.each() with combos, see the Iterating over items section in Combos Concepts.

required
Options controlling how to iterate over the chart items.
required
function
The function to be called for each item in the chart.
void
"all" | "toplevel" | "underlying"
default: 'underlying'

The chart items to iterate over when using combos.

  • 'underlying': iterates over items that are not combo nodes or combo links.
  • 'toplevel': iterates over items, including combos, that are not inside other combos.
  • 'all': iterates over every item.
required
"all" | "node" | "link" | "annotation"
The type of items to consider.

The expand() function is the easiest way to add new items to the chart. It performs a merge() followed by a layout().

const newItems = [
  { id: 'newNode', type: 'node', t: 'New Node' },
  { id: 'newLink', type: 'link', t: 'New Link', id1: 'newNode', id2: 'oldNode' }
];
chart.expand(newItems, { animate: true, layout: { fit: true } }).then(() => { // do more after expand });

If no layout is specified, expand() will use the organic layout by default.

If you have a current filter applied to the chart and want to keep the filter state consistent when new items are added to the chart, use the filter option:

function myFilter(item) {
  return (item.d.value > 10);
}
chart.expand(newItems, {animate: true, filter: { filterFn: myFilter, type: "node" } }).then(() => { // do more after expand });

If there are multiple links between two nodes, expand() will automatically apply an offset to the links.

Things to note:

  • The layout() function is not supported while using a Leaflet map.
  • You cannot change the ends of an existing link.
  • The radial layout may have non-intuitive results depending on the change of the network topology.
  • Setting the x and y properties when using expand() has no effect as layout() overwrites these positions.
  • You can set the parentId of new items to add them into a combo, but cannot change the parentId of pre-existing items. See Combos for more detail.
required
To be added to the chart, a choice of either:
  • KeyLines chart object.
  • A single item.
  • An array of items.
Options to control the expanding action of the nodes.
Promise
A Promise object.
boolean
default: true
Whether the result should be animated.
ExpandArrange
An object specifying how the contents of any combos which have changed should be arranged.
"all" | "inCombo" | "none"
default: 'all'
Controls how items outside a combo (at the top chart level or within that combo's parent combo) pull back or push in to adapt to combos that changed during expand. Note that if the parent combo has a 'grid' arrangement, it always adapts.
  • 'all': all items adapt.
  • 'inCombo': items inside the parent combo adapt, top level layout stays unchanged.
  • 'none': no items adapt.
"auto" | object
default: 'auto'
When name is set to 'grid', controls the row/column dimension of the grid. Specify an object in the form { rows: number } or { columns: number }.
string

When layout name is set to 'sequential', the name of the custom property on the node's or combo node's d property that defines which level the node/combo belongs to. The property must contain a numeric value, where the lowest value node is placed at the top of the hierarchy. Levels for nodes with no level data are inferred from the nodes' links.

"direct" | "curved" | "angled"
default: 'direct'
The shape of the path taken by links.
  • 'direct' - links are either straight or follow arcs when offset.
  • 'curved' - link follow a curved path, and attach to nodes in the direction of orientation.
  • 'angled' - links follow straight lines with corners: useful for hierarchical data sets. Currently in beta.

The direction of 'curved' and 'angled' links is inferred from orientation.

"lens" | "concentric" | "grid" | "sequential" | "none"
default: 'lens' / 'grid'
Controls how nodes are arranged inside an open combo.
  • 'lens' - automatic arrangement with connected nodes next to each other. The default for circular combos.
  • 'concentric' - circlular arrangement with larger items at the centre.
  • 'grid' - grid arrangement running from left to right, from the top down in the order in which they are added in the combo. The default for rectangular combos.
  • 'sequential' - tree-like arrangement showing the sequence of links between distinct levels of nodes.
  • 'none' - items are kept in their original positions.
string | OrderByOptions
When the arrangement name is 'sequential', specifies the order of nodes/combos within the same arrangement level of a connected component in the chart. Any disconnected nodes or combos are ignored.
string
The key of the custom data value on the node's d property used to order nodes alphanumerically within each level. When specified, nodes are ordered alphanumerically, in descending order, unless sortBy is also set.
"ascending" | "descending"
default: 'descending'
The direction of ordering.
"left" | "right" | "up" | "down"
default: 'down'
When name is set to 'sequential', the orientation of the arrangement.
"none" | "circle" | "rectangle" | "adaptive" | "aligned"
default: 'aligned'
When name is set to 'sequential', the packing mode to use.
boolean
default: true
If true, any combos that are arranged will be resized to fit their contents. If false, they will not be resized.
"auto" | "equal" | "stretched"
default: 'auto'
When name is set to 'sequential', the spacing between nodes at each level.
StackOptions
When name is set to 'sequential', stacking options for nodes sharing the same neighbours and level. If property is set in orderBy, stacking is only applied to nodes sharing the same property value.
required
"none" | "grid"
default: 'none'
If set to 'grid', four or more same-level nodes with identical neighbours are stacked in a grid.
boolean
default: true
By default, links are drawn ignoring off. If false, link offsets are preserved.
number
default: 1
When name is set to 'sequential', the spacing between levels. Values must be positive.
"auto" | "equal"
default: 'equal'
The type of spacing between levels in sequential layout. Set to 'auto' if individual levels contain unevenly sized items (nodes or combos) to optimise use of space and get more even distribution of levels.
number
default: 5
Controls how close items are to each other in open combos. Must be in the range 0 to 10, with higher values being closer.
string | string[]
When name is set to 'sequential', and level isn't set, specifies the node(s) in the top level of the arrangement. Nodes without top specified are unchanged during the layout but but may be repositioned by packing.
ExpandFilter
An object with the filter definition to apply to the chart items before running the layout. This object can have any option passed to the chart.filter() function except animate and time, plus an additional one: filterFn.
function
A function which takes an item as its argument, returning true if the item should be visible, false otherwise.
boolean
Whether isolated nodes should be hidden, even if the filter criterion passed to chart.filter() function returns true for them. The default is true if type is 'link', false otherwise.
"underlying" | "toplevel"
default: 'underlying'
The chart items to iterate over when using combos.
  • 'underlying': iterates over items that are not combo nodes or combo links.
  • 'toplevel': iterates over items, including combos, that are not inside other combos.
"link" | "all" | "annotation" | "node"
default: 'all'
The type of item to show or hide.
boolean
default: true
When true, if items are 'underlying', updates combo nodes' glyph text to equal the number of nodes that are visible inside the combo node.
ExpandLayoutOptions
An object specifying the layout to apply to the incoming items if there has been a change to the top-level structure of the chart.
boolean
default: true
If true, each layout run will produce the same chart display for the same chart structure. If false, the layout will produce different results for a given network on each run. Only used by 'lens', 'organic' and 'standard'.
"linear" | "cubic"
default: 'cubic'
The easing function for animation. If set to 'linear', the speed is constant. If set to 'cubic', the animation starts slow, speeds up and then finishes slow.
boolean
default: false
Whether to fit the chart into the window at the end of the layout.
"all" | "none" | "adaptive" | "adjacent" | "nonadjacent"
default: 'adaptive'
Specifies which nodes to fix in position when the layout is run during chart.expand(). Only used by 'organic' and 'standard'.
  • 'adaptive': fixes nodes relative to other nodes in their component, where possible.
  • 'adjacent': only fixes nodes linked to new items.
  • 'nonadjacent': only fixes nodes not linked to new items.
  • 'all': fixes all existing nodes.
  • 'none': doesn't fix any existing nodes.
boolean
default: false
Only applies to 'hierarchy'. If true, the hierarchy will be flattened by removing extra space between levels.
string

The name of the custom property on the node's or combo node's d property that defines which level the node/combo belongs to in the 'sequential', 'hierarchy', or 'radial' layouts. The property must contain a numeric value, where the lowest value node is at the top of the 'sequential' or 'hierarchy', or in the centre of the 'radial' layout.

  • 'radial' and 'hierarchy' must have either level or top specified.
  • 'sequential' assigns levels automatically if neither are specified (inferred from the nodes' links).
  • If both the level and top options are specified, level is used.
"direct" | "curved" | "angled"
default: 'direct'
The shape of the path taken by links.
  • 'direct' - links are either straight or follow arcs when offset.
  • 'curved' - link follow a curved path, and attach to nodes in the direction of orientation.
  • 'angled' - links follow straight lines with corners: useful for hierarchical data sets. Currently in beta.

The direction of 'curved' and 'angled' links is inferred from orientation.

"organic" | "structural" | "lens" | "radial" | "sequential" | "hierarchy" | "standard"
default: 'organic'
The name of the layout to apply.
string | object
When the layout name is 'sequential', specifies the order of nodes/combos within the same layout level of a connected component in the chart. Any disconnected nodes or combos are ignored.
string
The key of the custom data value on the node's d property used to order nodes alphanumerically within each level. When specified, nodes are ordered alphanumerically, in descending order, unless sortBy is also set.
"ascending" | "descending"
default: 'descending'
The direction of ordering.
"left" | "right" | "up" | "down"
default: 'down'
When name is set to 'sequential' or 'hierarchy', the orientation of the layout.
"none" | "circle" | "rectangle" | "adaptive" | "aligned"
default: 'adaptive' / 'aligned'
The packing mode to use for the layout during expand. Not used by 'lens'.
  • 'adaptive': components only move to make space for new items or to use space created by removed items.
  • 'aligned': only for sequential, default option. Components are laid out in a single line with same level items aligned. If top is used, any components without top specified are packed using 'adaptive' packing.
  • 'circle': components are treated as circles, giving a roughly circular result.
  • 'rectangle': components are treated as rectangles, giving a grid-like result.
  • 'none': components are not packed.
"auto" | "equal" | "stretched"
default: 'auto'
The spacing between nodes at each level of the sequential layout.
  • ‘auto’: node spacing reduces link lengths and connected components are nested together to make the most of screen space.
  • ‘equal’: regular node positions with equal spacing within each connected component and a clear separation between them.
  • ‘stretched’: as for ‘equal’ but each level is stretched to take up an equal amount of screen space.
StackOptions
When name is set to 'sequential', stacking options for nodes sharing the same neighbours and level. If property is set in orderBy, stacking is only applied to nodes sharing the same property value.
required
"none" | "grid"
default: 'none'
If set to 'grid', four or more same-level nodes with identical neighbours are stacked in a grid.
boolean
default: true
By default, links are drawn ignoring off. If false, link offsets are preserved.
number
default: 1
When name is set to 'sequential', the spacing between levels. Values must be positive.
"auto" | "equal"
default: 'equal'
The type of spacing between levels in sequential layout. Set to 'auto' if individual levels contain unevenly sized items (nodes or combos) to optimise use of space and get more even distribution of levels.
number
default: 5
Controls how close nodes are to each other. Must be in the range 0 to 10, with higher values being closer.
string | string[]
A node id or an array of node ids which should be at the top of the hierarchy and sequential layouts, or in the centre of the radial layout. Components without top specified are unchanged during the layout but can be repositioned by packing. If both the level and top properties are specified, top is ignored.
  • 'radial' and 'hierarchy' must have either level or top specified.
  • 'sequential' assigns levels automatically if neither are specified (inferred from the nodes' links).
number
default: 1000
The time the animation should take, in milliseconds.

This function produces images of the chart in raster (PNG, JPEG) or vector (SVG, PDF) format. Raster images can be exported in high-resolution quality by setting the fitTo options to high values.

The exported image is encoded in a blob URL which is passed to the fulfilled promise.

chart.export({
  type: 'pdf',
  extents: 'chart',
  fitTo: 'page',
  heading: 'PDF Report',
  doc: {
    size: 'legal',
    layout: 'landscape',
    margin: 0.5 * 72, // 0.5 inch margin
  },
  fonts: {
     'Font Awesome 5 Free Regular': { src: '../fonts/fontAwesome5/fa-regular-400.woff' },
     Raleway: { src: './fonts/Raleway/Raleway-Regular.ttf' },
  },
}).then((exportResult) => {
  // do something with the image
});

SVG and PDF export may require embedding font files for fonts, font icons and special characters to display correctly. Unavailable fonts are replaced with ‘sans-serif’ and unavailable font icons are embedded as PNG images. See Font embedding in SVG and Text in PDF for details.

To export into PDF, you need to add external dependencies into your application. See the documentation for PDF Export for details.

The logo, navigation controls and overview window are not exported.

Notes

  • We do not recommend running multiple exports in parallel.
  • If you reference an image outside the domain of the KeyLines library, your browser will display it, but won’t let KeyLines examine it or render it to a URL. See Cross-Origin Images.
  • For PNG and JPEG, the maximum resolution that can be successfully exported is determined by the combination of device/OS/browser and memory available. We do not recommend attempting to export images larger than 100 megapixels.
  • Exporting charts on a Leaflet map may exclude items from some custom Leaflet layers, including markers and shadows.

Return Object

Use the returned promise object to detect when the operation has completed. The return object is in the form of { url, warnings }, where:

  • url - Contains a blob URL of the exported file. This will be undefined if a custom PDFDocument has been specified in the doc option to allow adding to the document before it is finished.
  • warnings - An array containing any warning objects generated during the export.
chart.export({  type: 'svg' }).then(({ url, warnings }) => {
  warnings.forEach(warning => { console.log(warning.msg); }); // we can do more with these, e.g. only log a certain type of warning
  const snapshotLink = document.createElement('a'); // create the link to download the image
  snapshotLink.download = 'chart-export.svg';
  snapshotLink.href = url;
  snapshotLink.click();
  URL.revokeObjectURL(url); // important - remember to revoke the url afterwards to free it from browser memory
});
required
An options object to configure the export.
Promise
A Promise with the result of the export.
PDFKit.PDFDocumentOptions or PDFKit.PDFDocument
Options to customise the PDF output:
"portrait" | "landscape"
default: 'portrait'
The page orientation.
number
default: 72
A single margin in PDF points (72 per inch) to be applied to all page edges.
object
default: { top: 72, right: 72, bottom: 72, left: 72 }
An object specifying individual margins in PDF points (72 per inch) to be applied to page edges.
string
default: 'letter'
The size of the generated PDF document.
string
default: 'view'
Specifies the contents of the exported image:
  • 'view': contains only the current on-screen view of the chart, the default aspect ratio is determined by the on-screen view.
  • 'chart': contains the whole chart, the default aspect ratio is determined by the whole chart.
For a Leaflet map, this option is ignored and KeyLines always generates the on-screen view of the chart.
object or string
An object in the form { width: x, height: y } specifying dimensions of the output. One or both values can be specified:
  • If one dimension is specified, the output is scaled to fit this dimension and keeps the aspect ratio determined by extents.
  • If both dimensions are specified, the output is scaled within the dimension limits and if needed, additional content is added to fill the remaining aspect ratio.
  • For PDF export only, fitTo can also be set to 'page' to scale the aspect ratio of the output to fit and fill the available page space.
For a Leaflet map, the fitTo option is ignored and the output size always corresponds to the size of the on-screen view. For PDF export of a Leaflet map, if the on-screen view is larger than the size of the generated PDF document, it is scaled down to fit the size of the generated PDF document.
object
A dictionary of font files indexed by font name to embed in the output for SVG and PDF export. Accepted formats are URL or base64 encoding of .woff or .ttf font files. See Font embedding in SVG and Text in PDF for details.
fonts: {
  'Font Awesome 5 Free Regular': { src: '../fonts/fontAwesome5/fa-regular-400.woff' },
  Raleway: { src: './fonts/Raleway/Raleway-Regular.ttf' },
}
string
A heading of the exported PDF document. The heading is displayed above the chart image and aligned to its centre. It uses the default PDFKit font (Helvetica) in font size that is proportional to the page size. Note that this option is ignored if a custom PDFDocument has been specified in the doc option.
required
"jpeg" | "pdf" | "png" | "svg"
default: 'png'
The file type of the output.

Allows items in the chart to be hidden or shown depending on your own criterion.

// this function filters out nodes with a value <= 10
// including those within combos.
function myFilter(item) {
  return (item.d.value > 10);
}
chart.filter(myFilter, { type: 'node' }).then((filterResults) => {
  // do more after filter
});

When type is set to 'node', 'link' or 'annotation', the function automatically shows or hides the connected items, so that:

  • any nodes that have only hidden links will also be hidden
  • any visible links will have nodes at both ends also visible
  • any annotations that have only hidden subjects will also be hidden
  • any visible annotations will have their subjects also visible

If the type is 'all', you have fine control over the visibility of all the links and nodes and the rules above do not apply.

Filtering with Combos

By default, the filter() function includes the contents inside the combos when considering what data should be visible in the chart.

The resolve value for the promise is an object containing a combos property, which describes the visible combos (combo links and combo nodes) which have been altered by the filtering process, as well as the visible items within the combo - i.e., those items that match the filter criteria.

A typical use for this property is to re-size, re-style, or change the glyphs of the visible combos based on their (filtered) contents.

chart.filter(timebar.inRange, {}).then((result) => {
  // Resize the combo nodes based on visible items within
  const nodeStyles = result.combos.nodes.map((comboInfo) => {
    return { id: comboInfo.id, e: Math.sqrt(comboInfo.nodes.length) };
  });
  return chart.animateProperties(nodeStyles);
});

If the combo itself becomes visible, it will appear in both the shown and combos properties. If the combo itself becomes hidden, it will only appear in the hidden property.

For more details, see the Filtering and foregrounding items section of the Combos Concepts page.

Return Object

Use the returned promise object to detect when the filter operation has completed. The return object describes items altered by the filter function:

  • shown items (with nodes/links/annotations properties as arrays of ids)
  • hidden items (with nodes/links/annotations properties as arrays of ids)
  • shown combos and items in combos (with combo ids and nodes/links properties as arrays of objects)

The form of the object is:

{
  shown:  { nodes: [...] , links: [...], annotations: [...] },
  hidden: { nodes: [...] , links: [...], annotations: [...] }
  combos: {
    nodes: [{ id: comboId, nodes: [node], links: [link] }]
    links: [{ id: comboId, links: [link] }]
  }
}
required
function
A function which takes an item as argument. Returns true if the item should be visible, false otherwise.
Options to control the filtering.
Promise
A Promise that resolves with result of the filter.
boolean
default: true
Whether the filtering operation should be animated.
boolean
Whether isolated nodes should be hidden, even if the filter criterion passed to chart.filter() returns true for them. The default is true if type is 'link', false otherwise.
"underlying" | "toplevel"
default: 'underlying'
The chart items to iterate over when using combos.
  • 'underlying': iterates over items that are not combo nodes or combo links.
  • 'toplevel': iterates over items, including combos, that are not inside other combos.
number
default: 1000
The time the animation should take, in milliseconds.
"link" | "all" | "annotation" | "node"
default: 'all'
The type of item to show or hide.
boolean
default: true
When true, if items is 'underlying', update combo nodes' glyph text to equal the number of nodes that are visible inside the combo node.

Allows nodes and links in the chart to be backgrounded or foregrounded depending on your own criteria.

// this function puts nodes with a value <=10 into the background
// including those inside of combos
function isForeground(item) {
  return (item.d.value > 10);
}
chart.foreground(isForeground, {}).then(() => {
  // do more after foreground
});

When using the type option 'node' or 'link', the function automatically changes the background state of connected items to keep the chart appearance clean. Backgrounded items are given an alpha value which can be set with the backgroundAlpha option.

At the end of the operation:

  • any nodes that have only background links will also be in the background
  • any foreground links will have both ends in the foreground

If the type is 'all', you have fine control over the background state of all the links and nodes - the rules above are not applied. This line of code will foreground all items in the chart:

chart.foreground((node) => true );

Return Object

Use the returned promise to detect when the foreground operation has completed. The return object describes exactly which items were put into the foreground or background and has the form:

{
  foreground: { nodes: [...] , links: [...] },
  background: { nodes: [...] , links: [...] }
}

For foreground or background objects, the nodes / links properties are arrays of ids.

For details on how to use foregrounding with combos, see the Filtering and foregrounding items and the Foregrounding open combos sections in Combos Concepts.

required
function
A function which takes an item as its argument, returning false if the item should be in the background, true otherwise.
Options to control the foreground operation.
Promise
A Promise that resolves with result of the foreground.
boolean
default: true
Whether open combos should be foregrounded. Set to false to put all open combos in the background. When set to false, manually opening/closing any combo overrides the option and foregrounds all combos. When opening/closing programmatically using chart.combo().open() / chart.combo().close(), the option remains set.
"underlying" | "toplevel"
default: 'underlying'
The chart items to iterate over when using combos.
  • 'underlying': iterates over items that are not combo nodes or combo links.
  • 'toplevel': iterates over items, including combos, that are not inside other combos.
"link" | "all" | "node"
default: 'node'
The type of item to foreground/background.

Returns aggregation information associated with the specified link(s).

required
string | string[]
The link(s) being queried.
AggregateInfo | null | (AggregateInfo | null)[]

An object containing the aggregation information associated with each specified link, or null if there is no link matching the id.

string | undefined
If an aggregate link: the key of the custom data on the child link's d property being used for aggregation.
required
any
If an aggregate link: the value of the custom data specified by aggregateByProp. All its child links have the same value of the property.
string[] | undefined
If an aggregate link: its child links.
"both" | "none" | "from" | "to" | undefined
If an aggregate link: the direction in which its child links are aggregated:
  • 'from': direction arrow points from id1 to id2
  • 'to': direction arrow points from id2 to id1
  • 'both': direction arrows in both directions
  • 'none': link aggregation is not based on direction
required
boolean
Whether the specified link is an aggregate link.
string | undefined
If the link is a child of an aggregate, specifies its parent link.

Returns a copy of the items in the chart which match the id.

Note:To update the items, use setProperties().

required
string | string[]
The id string or the array of id strings of the items to be retrieved.
Node | Link | Annotation | null | (Node | Link | Annotation | null)[]
The item or array of items matched. Returns null if there is no item matching an id.

Returns information on the item at the specified view coordinates.

Note: This function is intended for use in integration tests. For fetching items from the chart, use getItem().

required
number
The x position in view coordinates.
required
number
The y position in view coordinates.
object
An object describing the id and subItem of the item at the specified coordinates.

The graph object has methods for navigating the top level of your chart.

See KeyLines.getGraphEngine() to consider the underlying level of the chart.

The graph representation of the chart.

Hides item or items with the id(s) specified.

Hiding nodes automatically hides any links that are connected only to the hidden nodes.

Hiding a combo node will hide all its child items.

Hidden links will not be considered when running a layout.

If all annotation subjects (nodes, links and combos) are hidden, the annotation is also hidden.

To show items, call the show() function.

required
string | string[]
The ids of items to hide.
Options to control the hide operation.
Promise
A Promise.
boolean
default: false
Whether the transition should be animated.
number
default: 1000
The time the animation should take, in milliseconds.

Returns information about the label of the item with the specified id. Can be useful e.g. when overlaying text edit boxes over the chart surface. Does not return the label position for t1 or t2 labels on link ends.

required
string
The identity of the item.
number
If the item is styled by an array of label objects, represents the index of the specific label object.
object | null
An object containing label coordinate properties, or null if the items are hidden or don't exist. The coordinates are in view coordinates relative to the top left corner of the KeyLines HTML element.
{
  x1: valueX1, // left
  x2: valueX2, // right
  y1: valueY1, // top
  y2: valueY2, // bottom
  fs: value // font size at current zoom
}

The layout function positions the nodes of the chart.

The layouts are:

  • 'organic': The default force-directed layout offering excellent performance and results for any type or size of data.
  • 'sequential': lays out tree-like data in a traditional hierarchy structure, minimising crossed links.
  • 'hierarchy': a simpler tree-like layout.
  • 'lens': places the node in a circle-like grid, with connected nodes next to each other.
  • 'radial': places nodes in concentric circles.
  • 'structural': places nodes which are structurally similar together in the network.
  • Deprecated'standard': a force-directed graph layout which tries to keep link lengths consistent.

For more detail on our layouts, see Layout Basics.

Options can be passed in the second argument. For example:

chart.layout('organic', {
  mode: 'adaptive',
  animate: false
}).then(() => {
  // do more after layout
});

The layout is not performed on a Leaflet map.

Hidden items do not change their positions and are not considered by the layout function. When re-showing hidden items consider running a layout to ensure the chart looks good afterwards.

If you are using combos, be aware that layouts only consider nodes that are on the top-level of the chart. For more detail on chart levels, see Combos Concepts.

Return Object

The layout call is asynchronous - the function will return before the layout has completed. To discover the progress of the layout use the progress event. Use a promisified function to detect when the layout has finished.

The arrange() function is an alternative way to position nodes. It places nodes in close proximity into a specified shape.

"organic" | "sequential" | "hierarchy" | "lens" | "radial" | "structural" | "standard"
The name of the layout to be invoked. The default is 'organic'.
Options to control features of the layout.
Promise
A Promise.
boolean
default: true
Whether the result should be animated.
boolean
default: false
If set to true, each layout run will produce the same chart display for the same chart structure. The position of nodes in the chart may change during the layout, but their position in relation to other nodes will remain the same. If false, the layout will produce different results for a given network on each run. Only used by 'lens', 'organic', 'structural' and 'standard'.
"linear" | "cubic"
default: 'cubic'
The easing function for animation. If set to 'linear', the speed is constant. If set to 'cubic', the animation starts slow, speeds up and then finishes slow.
boolean
default: true
Whether to fit the chart into the window at the end of the layout.
string[]
An array of node ids whose positions are fixed relative to the other nodes in the same component. Their position on the chart may change during the layout, but their position in relation to the component's other nodes will remain the same. Only used by 'organic' and 'standard'.
boolean
default: false
Only used on 'hierarchy' layout. If true, the hierarchy will be flattened by removing extra space between levels.
string

The name of the custom property on the node's or combo node's d property that defines which level the node/combo belongs to in the 'sequential', 'hierarchy', or 'radial' layouts. The property must contain a numeric value, where the lowest value node is at the top of the 'sequential' or 'hierarchy', or in the centre of the 'radial' layout.

  • 'radial' and 'hierarchy' must have either level or top specified.
  • 'sequential' assigns levels automatically if neither property are specified (inferred from the nodes' links).
  • If both the level and top properties are specified, level is used.
"direct" | "curved" | "angled"
default: 'direct'
The shape of the path taken by links.
  • 'direct' - links are either straight or follow arcs when offset.
  • 'curved' - link follow a curved path, and attach to nodes in the direction of orientation.
  • 'angled' - links follow straight lines with corners: useful for hierarchical data sets. Currently in beta.

The direction of 'curved' and 'angled' links is inferred from orientation.

"full" | "adaptive"
default: 'full'
Specifies whether the layout is run in full or as a short force-directed layout that slightly adapts item positions to data changes. Available for 'organic', 'sequential' and 'standard' layouts.
string | object
When the layout name is 'sequential', specifies the order of nodes/combos within the same layout level of a connected component in the chart. Any disconnected nodes or combos are ignored.
string
The key of the custom data value on the node's d property used to order nodes alphanumerically within each level. When specified, nodes are ordered alphanumerically, in descending order, unless sortBy is also set.
"ascending" | "descending"
default: 'descending'
The direction of ordering.
"left" | "right" | "up" | "down"
default: 'down'
When name is set to 'sequential' or 'hierarchy', the orientation of the layout.
"none" | "circle" | "rectangle" | "adaptive" | "aligned"
default: 'circle' / 'aligned'
The packing mode to use for the layout. Not used by 'lens'.
  • 'adaptive': components only move to make space for new items or to use space created by removed items.
  • 'aligned': only for sequential, default option. Components are laid out in a single line with same level items aligned. If top is used, any components without top specified are packed using 'rectangle' packing.
  • 'circle': components are treated as circles, giving a roughly circular result.
  • 'rectangle': components are treated as rectangles, giving a grid-like result.
  • 'none': components are not packed.
"auto" | "equal" | "stretched"
default: 'auto'
The spacing between nodes at each level of the sequential layout.
  • ‘auto’: node spacing reduces link lengths and connected components are nested together to make the most of screen space.
  • ‘equal’: regular node positions with equal spacing within each connected component and a clear separation between them.
  • ‘stretched’: as for ‘equal’ but each level is stretched to take up an equal amount of screen space.
StackOptions
When name is set to 'sequential', stacking options for nodes sharing the same neighbours and level. If property is set in orderBy, stacking is only applied to nodes sharing the same property value.
required
"none" | "grid"
default: 'none'
If set to 'grid', four or more same-level nodes with identical neighbours are stacked in a grid.
boolean
default: true
By default, links are drawn ignoring off. If false, link offsets are preserved.
number
default: 1
When name is set to 'sequential', the spacing between levels. Values must be positive.
"auto" | "equal"
default: 'equal'
The type of spacing between levels in sequential layout. Set to 'auto' if individual levels contain unevenly sized items (nodes or combos) to optimise use of space and get more even distribution of levels.
number
default: 5
Controls how close nodes are to each other. Must be in the range 0 to 10, with higher values being closer.
number
default: 700
If animated, the time the animation should take, in milliseconds.
string | string[]
A node id or an array of node ids which should be at the top of the hierarchy and sequential layouts, or in the centre of the radial layout. Components without top specified are unchanged during the layout but can be repositioned by packing. If both the level and top properties are specified, top is ignored.
  • 'radial' and 'hierarchy' must have either level or top specified.
  • 'sequential' assigns levels automatically if neither are specified (inferred from the nodes' links).

Replaces the chart data with the new specified data and dereferences any existing objects in the chart.

Note that the data argument is a JavaScript Object, not a JSON string. It should have the properties specified for the relevant Item Format.

const data = { type: 'LinkChart', items: [
  { id: 'node1', type: 'node', t: 'Node 1' },
  { id: 'node2', type: 'node', t: 'Node 2' },
  { id: 'link', type: 'link', t: 'Link', id1: 'node1', id2: 'node2' },
  { id: 'annotation', type: 'annotation', subject: 'node1', t: { t: 'Annotation' } },

]};
chart.load(data).then(() => { // do something else });

If there are multiple links between two nodes, load() will automatically apply an offset to the links.

You can set the parentId of new nodes to add them into a combo. See Combos for more details.

When using Leaflet Integration, call load() before displaying the Leaflet map. See Special behaviour for more details.

required
The data to load into the chart.
Promise
A Promise.

Locks and unlocks the chart. When the chart is locked, end-user interactions using mouse, keyboard and touch cannot alter the state of the chart.

Note that the API can continue to modify the chart while it is locked.

To determine the current state of the chart, call lock() with no arguments.

boolean
If true, the chart is locked.
Options to control the chart's behaviour while locked.
boolean
True if the chart is locked, false otherwise.
boolean
Whether to show a 'wait' cursor while the chart is locked.

The map namespace has methods for displaying the chart on a Leaflet map. See Map Functions.
The map namespace object.

Adds new items to the chart, or modifies the properties of existing items. Properties of any items matched will be replaced with the new item properties.

Merging does not lay out the chart - if you want the chart to be laid out afterwards, call chart.layout() once the promise is resolved.

const newItems = [
  { id: 'newNode', type: 'node' },
  { id: 'newLink', type: 'link', id1: 'newNode', id2: 'existingNode' },  // new link connecting a new node with existing one
  { id: 'newAnnotation', type: 'annotation', subject: 'existingNode' },  // new annotation added on an existing node
];
chart.merge(newItems).then(() => { // do something else });

You can set the parentId of new items to add them into a combo, but cannot change the parentId of pre-existing items. See Combos for more detail.

If there are multiple links between two nodes, merging will automatically apply an offset to the links. Note that you cannot change the ends of an existing link.

required
To be added or modified in the chart, a choice of either:
  • KeyLines chart object.
  • A single item.
  • An array of items.
Promise
A Promise.

Detaches an event handler function for one or more events attached to the chart using the on() function.

chart.off('progress', progressEventHandler);

If no handler is supplied, all handlers for the specified event are detached. If no event name is supplied, all event handlers for all events are detached.

The name of the event to be detached from, e.g., 'click'. Use 'all' to detach from all events.
function
The event handler that was supplied to the on() call.
void

Attaches an event handler function for one or more Chart Events to the chart.

function progressEventHandler(task, progress) {
  // use progress to set progress bar value
}
chart.on('progress', progressEventHandler);

To detach event handlers, use off().

See Events Basics for more details.

required
The name of the event to listen for, e.g., 'click'. Use 'all' to listen to all events.
required
function
The event handler to call when the event occurs.
void

Sets or gets the current display and interaction options. See Chart Options.

Note that using this promisified function as a getter still returns an object in a synchronous way. See Special Cases: getters and setters for more detail.

chart.options({ minZoom: 0.01 });
Controls the chart options.
object | Promise
Getter: The current options.
Setter: A Promise object.

Pans the chart in the direction specified.

required
"left" | "right" | "up" | "down" | "selection"
Controls how to pan the chart:
  • 'up' / 'down' / 'left' / 'right' - Pans the chart as specified.
  • 'selection' - Pans the centre of the viewport to the centre of the selected items.
Options to control the pan operation.
Promise
A Promise.
boolean
default: false
Whether the transition should be animated.
number
default: 1000
The length of the animation in milliseconds.

Adds an animated effect to a specified node or link, and then removes it again. To animate nodes and links in other ways, use the animateProperties() function.

Ping and nodes

The function adds a halo to nodes. Animation expands the halo's radius and width to specified values while decreasing the alpha value of its specified colour, giving a fade effect.

Ping does not affect the ha0-9 properties used for displaying other halos on nodes.

Ping and links

The function adds an animated effect on links that's similar to halos on nodes. The animation expands from the outline of the link to a specified width while decreasing the alpha value of its specified colour, giving a fade effect. Note that you cannot apply halo properties to links.

Ping items in combos

If an item is in a closed combo when it is pinged, the ping appears on the closed combo.

required
string | string[]
The ids of items to be animated.
Options to control the animation.
Promise
A Promise.
string (Colour)
default: 'mid-grey'
The rgb colour to use for the animated effect.
number
default: 40
The maximum width of the links' animated effect.
number
default: 80
The radius of the nodes' halo at the end of the animation.
number
default: 1
The number of times the animation should be repeated.
number
default: 800
The time the animation should take, in milliseconds.
number
default: 20
The width of the nodes' halo at the end of the animation.

Removes item or items with the id(s) specified. Note that there is no event to detect items being removed from the chart.

required
string | string[]
The id string or array of id strings of items to remove.
void

Sets or gets the current chart selection as an array of ids. Selected items are drawn on top of non selected ones. Any link whose end is selected will also be drawn on top.

Note that hidden items cannot be selected.

string[]
Ids of items to be selected. Note that annotations cannot be selected.
string[]
The current selection as a list of item ids.

Returns a complete serialization of the current chart content in the form specified by the object properties section.

The serialized chart can be loaded back in by using the chart.load function. This can be used for saving the chart state in a database or for implementing features like undo or redo.

You can also load in serialized data with merge() or expand(), but be aware that when merging data with combos, only the underlying items will be loaded, and not combos or combo links. See Combos Concepts for more detail.

Calling chart.serialize() during animations, or when transitioning to and from a Leaflet map, may cause transient node positions to be saved into the serialized data.

Note: We do not recommend parsing the results of chart.serialize as a way to get items from the chart. Instead, use chart.each to iterate over items and return an array.

object
The representation of the chart state in the form of a KeyLines chart object.

Sets the location of the chart in the DOM. Pass null as the argument to hide it completely.

Things to note:

  • You must specify the container parameter in KeyLines.create() to use setContainer().
  • While the container is set to null, all drawing and animations are paused, and you cannot transition to and from a Leaflet map.
chart.setContainer('chartContainer');
string | HTMLElement | null
The id string or DOM element of the parent container that the chart should be appended to.
void

Creates a new item in the chart with the specified properties. The item should have the properties specified in Item Format, and must include all the desired properties of the new item including its type, either 'node' or 'link'. If there is an existing item in the chart with the same id, it is replaced and none of its properties are retained.

chart.setItem({ id: 'node1', type: 'node', c: 'blue', t: 'new label' }).then(() => {
  // do something else
});

Note that if the new item is a link, both of its end nodes must already be present in the chart. It is not possible to add links without ends, and you cannot change the ends of an existing link.

You can set the parentId of a new item to add it into a combo, but cannot change the parentId of a pre-existing item. See Combos for more detail.

To change some of the properties of an existing item without replacing it, use setProperties().

Note: Using setItem to add an additional link doesn't apply the automatic offset to the link. Use merge() if you want this.

required
The item to set in the chart.
Promise
A Promise.

Changes properties of items in the chart.

Use it to change properties of multiple items in a single call - see Data Manipulation for more details.

Accepts a single item object (or an array of items) in the form {id: id, propertyName1: value1, propertyName2: value2 }. Items with a matching id will take the new values.

Setting useRegEx = true treats the ids passed in as regular expressions. This is useful for global settings, for example to set the font size across the whole chart:

chart.setProperties({ id: '.', fs: 8 }, true);

Regular expressions are always evaluated with the 'i' (case-insensitive) and 'm' (multiline) modifiers set, and ids should be passed as strings (not regular expression objects).

Note that the new value will completely replace the previous one, even for Glyphs, Font Icons or properties for other item formats where the value is an object or an array.

If you want to update or merge object or array properties, the recommended way is to get the current value, modify it and set it back. For example:

const item = chart.getItem('item-id');

// now add a new property to the current one
const data = item.d;
data.myNewProperty = 'new value';

// and update the chart
chart.setProperties({ id: item.id, d: data });

When changing properties in the top level object, you only need to specify the properties that you want to change. When changing properties in the nested object, you need to specify both changing and unchanged properties:

// changing top level properties of a link
chart.setProperties({ id: 'link1', fbc:'orange', t: 'link', t1: 'endLabel1', t2: 'endLabel2', });

// changing the nested fbc property for t1 and t2 requires repeating the t properties as well
chart.setProperties([{ id: 'link1', t1: { t: 'endLabel1', fbc:'red' }, t2: { t: 'endLabel2', fbc:'green' } }]);

Notes:

required
The ids of items to be changed and the properties to be changed.
boolean
Whether the ids are to be treated as regular expression strings. The default is false.
Promise
A Promise.

Shows (unhides) the items specified by the id parameter.

Calling show() on a combo will also show the items inside it. Calling show() on an item inside a hidden combo or a nest of combos will show that item and its parent(s).

Hiding nodes with chart.hide() or chart.filter() automatically hides their links, but calling show() to unhide the nodes does not automatically reinstate the hidden links. To do that for the nodes specified in the id parameter, set showLinks to true.

Hiding all annotation subjects using chart.filter() automatically hides their annotations, but calling show() to unhide at least one subject does not automatically reinstate the hidden annotations. To do that for the subjects specified in the id parameter, set showAnnotations to true.

required
string | string[]
The ids of items to show.
Options to control the show operation.
Promise
A Promise.
boolean
default: false
Whether the transition should be animated.
boolean
default: false
If true, any hidden annotations attached to subjects that become shown will also be shown.
boolean
default: false
If true, any hidden links to nodes that become shown will also be shown.
number
default: 1000
The length of the animation in milliseconds.

This function is deprecated. Use the chart.export() function which supports more output types.

Returns a data URL of the chart image as the first argument of the fulfilled promise: a base64 encoded PNG image string will be passed to the fulfilled promise.

chart.toDataURL(300, 200, {}).then((dataURL) => {
  // do something with the image
});

The navigation controls and overview window are not drawn into the image.

If you reference an image that's on a different domain to the KeyLines library, your browser will display it, but won’t let KeyLines examine it or render it to a data URL. For details on how to fix this, see Cross-Origin Images (CORS).

toDataURL behaves slightly differently for charts on a Leaflet map:

  • Only the current visible viewport will be captured in the data URL, which means the width, height and options.fit parameters will be ignored.
  • Some layers within the Leaflet map, including markers and shadows, will not be included in the data URL.
number
The width of the required image in pixels. The default is the width of the chart element. Not supported for a Leaflet map.
number
The height of the required image in pixels. The default is the height of the chart element. Not supported for a Leaflet map.
Options to control how the image is created.
Promise
A Promise that resolves to a base64 encoded PNG image string.
"exact" | "view" | "chart" | "oneToOne"
default: 'exact'
How the current view settings are mapped when generating the image. Note that for a Leaflet map, the only available fit mode is 'exact'.
boolean
default: true
Whether the chart background gradient (if present) should be drawn.
boolean
default: true
Whether the logo (if present) should be drawn.
boolean
default: false
If true, the image is drawn as if it were a new component at 1-1 scale. This means that any logo or watermark will be drawn at 1-1 in the image. If false, the logo and watermark are sized to fit the image size.
boolean
default: false
Whether the current selection (if present) should be drawn as selected in the image.
boolean
default: true
Whether the watermark (if present) should be drawn.

Converts world coordinates (positions of items within the chart) to screen coordinates in the current view. This depends on the current view settings (zoom and pan). View coordinates are relative to the top left corner of the chart.

required
number
The x position in world coordinates.
required
number
The y position in world coordinates.
object
An object containing the view coordinates.
number
The horizontal coordinate.
number
The vertical coordinate.

Sets or gets the current chart view options, which covers the zoom setting and viewport location.

For a Leaflet map, view options must be set through the Leaflet API.

Note that using this promisified function as a getter still returns an object in a synchronous way. See Special Cases: getters and setters for more detail.

Controls the view options.
Transition
Options to control the transition between view states.
boolean
default: false
Whether the transition should be animated.
number
default: 1000
The time the animation should take, in milliseconds.
object | Promise
Getter: The current view options.
Setter: A Promise object.
number
The height of the view (read only).
number
default: 0
The view offset in the X direction measured in pixels.
number
default: 0
The view offset in the Y direction measured in pixels.
number
The width of the view (read only).
number
default: 1
The level of zoom. 1 is 1-to-1, which means that item sizes match the canvas pixel size. Note that you cannot use the zoom option on a Leaflet map. For details on controlling zoom on a Leaflet map, see the Leaflet Integration documentation.

Converts screen coordinates (in the current view) to the coordinates which are used to represent the position of items within the chart. This depends on the current view settings (zoom and pan).

required
number
The position in screen pixel coordinates relative to the left side of the chart.
required
number
The position in screen pixel coordinates relative to the top of the chart.
object
An object containing the world coordinates.
number
The horizontal coordinate.
number
The vertical coordinate.

Zooms the chart in the manner specified.

required
"height" | "one" | "selection" | "fit" | "in" | "out"
Controls how to zoom the chart:
  • 'in' / 'out' - Zooms the chart in/out as specified.
  • 'one'- Zooms the chart in/out so that node sizes match the canvas pixel size. Equal to chart.viewOptions({ zoom: 1 }).
  • 'fit'- Fits the chart or the specified ids to window.
  • 'height' - Fits the height of the chart or of the specified ids to window.
  • 'selection' - Fits the selected items to window.
Options to control the zoom operation.
Promise
A Promise.
boolean
default: false
Whether the transition should be animated.
string | string[]
The id or array of ids to zoom to in 'fit' or 'height' mode. If no ids are specified 'fit' will fit the chart to the window. 'height' will fit the chart height to the window.
number
default: 1000
The length of the animation in milliseconds. Cannot be set for a Leaflet map. See Special behaviour for more information.

Chart Events

Events let you customise your application by responding to user actions on the chart surface. To attach handlers to events, use chart.on().

The 'all' event fires when any event occurs on the chart.

It returns an object containing both the name of the event and the object returned by that event.

object | undefined
The object returned by the event when listened to directly, or undefined if event does not return a value.
string
The name of the event.

The click event fires on a click or tap.

Default action:

  • On an item: Selects the item (adds to current selection if consistentCtrl is pressed)
  • On the background: Deselects all items
  • On the navigation controls: Performs the navigation control action
  • On the overview icon: Opens or closes the overview window
number
The index of the button used.
boolean
If the default action was prevented.
string | null
The id of the target item, or null if not an item.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
number
The unique identifier of the pointer.
string
The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
function
Call to prevent the event's default action.
An object containing details of the targeted sub-item, if applicable.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

The context-menu event fires on a right click or long press for touch devices.

Default action: Suppresses the click event

number
The index of the button used.
boolean
If the default action was prevented.
string | null
The id of the target item, or null if not an item.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
number
The unique identifier of the pointer.
string
The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
function
Call to prevent the event's default action.
An object containing details of the targeted sub-item, if applicable.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

The double-click event fires on a double click or double tap.

Default actions:

  • On the background: Zooms in (animated)
  • On a combo: Opens or closes the combo
number
The index of the button used.
boolean
If the default action was prevented.
string | null
The id of the target item, or null if not an item.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
number
The unique identifier of the pointer.
string
The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
function
Call to prevent the event's default action.
An object containing details of the targeted sub-item, if applicable.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

The drag-end event fires when the drag is finished and pointer is released, or when the drag is cancelled. On touch devices this fires when the finger or pointing device is lifted from the surface.

Default actions:

  • Updates the chart selection if type is 'marquee'
  • Moves selected items to their final positions if type is 'node' or 'link'
  • Accepts the final viewport position if type is 'pan' or 'overview'
  • Creates the link if type is 'create-link'
number
The index of the button used.
boolean
If the default action was prevented.
string[]
If type is 'node', 'link' or 'annotation', contains the list of items being dragged.
string | null
The id of the target item, or null if not an item.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
number
The unique identifier of the pointer.
string
The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
function
Call to prevent the event's default action.
An object containing details of the targeted sub-item, if applicable.
"node" | "link" | "annotation" | "pan" | "marquee" | "map" | "resize" | "create-link" | "overview" | "slider"
The type of drag.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

The drag-move event fires continuously as the cursor moves during a drag.

Default action: None

Use debouncing or throttling to limit the number of times the event handler is called:

let timer;
function throttle(func, delay) {
  if (timer) return;
  timer = setTimeout(() => {
    func();
    timer = undefined;
  }, delay);
}
// throttle eventHandlerFunction to only run once every 100ms
chart.on('drag-move',() => {
  throttle(eventHandlerFunction, 100);
});
number
The index of the button used.
string[]
If type is 'node', 'link' or 'annotation', contains the list of items being dragged.
string | null
The id of the target item, or null if not an item.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
number
The unique identifier of the pointer.
string
The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
An object containing details of the targeted sub-item, if applicable.
"node" | "annotation" | "pan" | "marquee" | "map" | "resize" | "link" | "create-link" | "overview" | "slider"
The type of drag.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

The drag-over event fires when the cursor dragging a node or an annotation moves over another item during a drag.

Default action: None

number
The index of the button used.
string[]
The list of items being dragged.
string | null
The id of the item underneath the dragging cursor, or null if over the background.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
number
The unique identifier of the pointer.
string
The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
The details of the sub-item underneath the dragging cursor.
"node" | "annotation"
The type of item dragged by the cursor.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

The drag-start event fires when a drag is started.

Default action: Creates a dragger. Use setDragOptions to set the drag behaviour:

// pan the chart with the right mouse button
chart.on('drag-start', ({ setDragOptions, button }) => {
  if (button === 2) {
    setDragOptions({ type: 'pan' });
  }
});
number
The index of the button used.
boolean
If the default action was prevented.
string[]
If type is 'node', 'link' or 'annotation', contains the list of items being dragged.
string | null
The id of the target item, or null if not an item.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
number
The unique identifier of the pointer.
string
The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
function
Call to prevent the event's default action.
function
A function to control the dragging behaviour. See setDragOptions for a list of parameters.
An object containing details of the targeted sub-item, if applicable.
"node" | "annotation" | "pan" | "marquee" | "map" | "resize" | "link" | "create-link" | "overview" | "slider"
The type of drag.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

The hover event fires when the cursor hovers over an item or the chart background. The event only fires once when the hover id changes.

Pass the hover property to chart.options() to configure the hover delay.

Default action: None

number
The index of the button used.
string | null
The id of the target item, or null if not an item.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
number
The unique identifier of the pointer.
string
The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
An object containing details of the targeted sub-item, if applicable.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

The key-down event fires when the user presses a key.

Default actions:

  • Escape key: Cancels a drag if present
  • Delete key: Deletes selected items
  • consistentCtrl + A: Selects all selectable items
  • Arrow keys: Moves selected items
boolean
If the default action was prevented.
number
The keyCode of the key pressed.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
function
Call to prevent the event's default action.

The key-up event fires when the user releases a key.

Default action: None

number
The keyCode of the key pressed.
object
A dictionary detailing which modifier keys were pressed when the event occurred.

The link-aggregation event fires each time an aggregate link is created, deleted or updated.

The update occurs when a child link is added, removed, hidden or unhidden, a child link's arrow changes, or when the custom property in d object used for aggregating links is changed.

You can use the event to style aggregate links. The default styling is the same as for a regular link, i.e. a grey link with a width of 1.

To style an aggregate link, use chart.setProperties() in the event handler, providing the id of the aggregate link from the event props:

chart.on('link-aggregation', ({ id }) => {
  chart.setProperties({ id, c: 'blue' })
});

Aggregate links do not inherit any styling from their child links with the exception of arrows.

Note that you must call chart.on before loading the chart data (so that the handler is called when the data is first loaded).

Default action: None

"both" | "none" | "from" | "to" | undefined
The arrow direction of the child links, when aggregateByDirection is set to true, undefined otherwise.
any
The value of the property being used to group links into aggregate links. It is undefined when aggregateBy is not used.
"created" | "updated" | "deleted"
Describes the change occuring to the aggregate link.
string
The id for this aggregate link.
string
The id of the node/combo at one end of the aggregate link that comes first in alphanumeric order. This order may be relevant when using aggregate links with sequential layout without top or level specified, or when setting arrows or flow on aggregate links. See Enabling aggregate links.
string
The id of the node/combo at the other end of the aggregate link that comes second in alphanumeric order. This order may be relevant when using aggregate links with sequential layout without top or level specified, or when setting arrows or flow on aggregate links. See Enabling aggregate links.
string[]
An array of the ids of the child links.

The map event fires at the start and end of transitions to and from a Leaflet map.

Default action: None

"showstart" | "showend" | "hideend" | "hidestart"
The type of Leaflet map event.

The pointer-down event fires when a pointer presses down on the chart.

Default action: None

number
The index of the button used.
string | null
The id of the target item, or null if not an item.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
number
The unique identifier of the pointer.
string
The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
An object containing details of the targeted sub-item, if applicable.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

The pointer-move event fires continuously as the pointer moves on the chart.

Default action: None

Use debouncing or throttling to limit the number of times the event handler is called:

let timer;
function throttle(func, delay) {
  if (timer) return;
  timer = setTimeout(() => {
    func();
    timer = undefined;
  }, delay);
}
// throttle eventHandlerFunction to only run once every 100ms
chart.on('pointer-move',() => {
  throttle(eventHandlerFunction, 100);
});
number
The index of the button used.
string | null
The id of the target item, or null if not an item.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
number
The unique identifier of the pointer.
string
The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
An object containing details of the targeted sub-item, if applicable.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

The pointer-up event fires when the pointer is released.

Default action: None

number
The index of the button used.
string | null
The id of the target item, or null if not an item.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
number
The unique identifier of the pointer.
string
The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
An object containing details of the targeted sub-item, if applicable.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

The prechange event fires whenever the chart changes by either a user action, such as dragging items, or programmatically by calling API methods.

Note that prechange fires before the chart changes. This allows control over state which is useful for adding features like undo/redo.

Default action: None

string
The type of change: 'arrange', 'arrange combo', 'close', 'combine', 'delete', 'expand', 'hide', 'layout', 'merge', 'move', 'offset', 'open', 'properties', 'resize', 'show', 'transfer', 'uncombine'.

The progress event fires during longer tasks such as layouts and centrality calculations.

Default action: None

chart.on('progress', ({ task, progress }) => {
  if (task === 'layout') {
    // use progress value for something
  }
});
number

How near the task is to completion on a scale of 0 to 1, where 0 is just started and 1 is finished. A progress of 1 indicates that the layout has finished computing, but not that the nodes have finished repositioning themselves. Layouts report progress differently depending on the layout used:

  • Organic - Reports incrementally
  • Hierarchy - Only reports 0 or 1
  • Sequential - Only reports 0 or 1
  • Lens - Reports incrementally
  • Radial - Only reports 0 or 1
  • Structural - Reports incrementally
  • Standard - Reports incrementally
string
The name of the task.

The selection-change event fires when the chart selection changes from a click event or marquee drag. Note that it does not fire if the selection changes programmatically.

Use chart.selection() to find any changes.

Default action: None

Use debouncing or throttling to limit the number of times the event handler is called:

let timer;
function throttle(func, delay) {
  if (timer) return;
  timer = setTimeout(() => {
    func();
    timer = undefined;
  }, delay);
}
// throttle eventHandlerFunction to only run once every 100ms
chart.on('selection-change',() => {
  throttle(eventHandlerFunction, 100);
});

The view-change event fires continuously during any change to the view such as zoom or pan. It also fires when the view state is changed programmatically.

Use viewOptions to find any changes.

Default action: None

Use debouncing or throttling to limit the number of times the event handler is called:

let timer;
function throttle(func, delay) {
  if (timer) return;
  timer = setTimeout(() => {
    func();
    timer = undefined;
  }, delay);
}
// throttle eventHandlerFunction to only run once every 100ms
chart.on('view-change',() => {
  throttle(eventHandlerFunction, 100);
});

The wheel event fires continuously while the user is rotating a mouse wheel or scrolling using a trackpad.

Default action:

  • On the background: Zooms in or out
boolean
If the default action was prevented.
number

The unit of measurement for delta value:

  • 0: Pixels
  • 1: Lines
  • 2: Pages
number
The number of units that the wheel scrolled in the x direction.
number
The number of units that the wheel scrolled in the y direction.
object
A dictionary detailing which modifier keys were pressed when the event occurred.
function
Call to prevent the event's default action.
number
The x location of the pointer in view coordinates.
number
The y location of the pointer in view coordinates.

A dictionary detailing which modifier keys were pressed when the event occurred.
boolean
If an alt key was held down when the event occurred.
boolean
If a consistent control key was held down when the event occurred (i.e. cmd key on MacOS and ctrl key on other OS).
boolean
If a control key was held down when the event occurred.
boolean
If the meta key was held down when the event occurred. This is the Windows key on Windows and the cmd key on MacOS.
boolean
If a shift key was held down when the event occurred.

Options to control the dragging behaviour. This function is returned by the drag-start event and is not available in the main chart namespace.

Pass in options as a single object:

// set dragger to marquee when started on a link
function dragStartHandler({ type, setDragOptions }) {
  if (type === 'link') {
    setDragOptions({ type: 'marquee' });
  }
};

chart.on('drag-start', dragStartHandler);

See the Custom Dragging demo for more examples of use.

string | string[]
The ids of nodes and combos to be dragged in addition to selected items.
boolean
default: true
Controls if combos should be dragged when child nodes are. Set to false to drag child nodes separately.
boolean
default: true
Set to false to disable horizontal dragging.
"pan" | "marquee" | "node"
The type of drag.
boolean
default: true
Set to false to disable vertical dragging.

Contains details of the sub-item targetted by the event.
number
When the type of sub-item is 'label', 'glyph' or 'donut', specifies which label, glyph or donut segment in the array to access, e.g. node.t[index], link.g[index] or node.donut.v[index] respectively. Note that 'index' is not required when there is only one 'label' sub-item.
"t1" | "t2"
The end of the link the sub-item is attached to. Only available if type is 'arrowhead', 'glyph' or 'label'.
string
The id of the sub-item, e.g. 'ne' or 't'.
string[]
When type is 'connection' or 'container', tells you which annotation subjects the connector line points to, or which subjects are present in the annotation container.
"container" | "resize" | "label" | "donut" | "glyph" | "halo" | "bubble" | "arrowhead" | "connection"
The type of sub-item:
  • 'donut', 'halo' - node decorations
  • 'bubble' - node and link decoration
  • 'label', 'glyph' - node, link and annotation decoration
  • 'resize' - resize handles on open combos
  • 'arrowhead' - arrows on link ends
  • 'container' - the container surrounding annotation subjects
  • 'connection' - the line and subject end of the annotation connector

Chart Options

These are the options you can pass to the first argument of chart.options().

For an example of how these options work, see Styling Charts.

boolean | AggregateLinksOptions

Controls whether one or more links between a pair of nodes are displayed as an aggregate link. Set to true to aggregate all the links between each pair of nodes or set the options below to specify how links should be aggregated.
Also note that:

  • Graph functions ignore aggregate links and calculate the results based on the unaggregated chart.
  • Hiding or backgrounding aggregate links is done by hiding or backgrounding all of their child links. See Inheriting state from child links.
  • string
    The key of the custom data on the child link's d property to be used to aggregate links together. One aggregate link is created between two nodes for each value of the data. Remove the d property or set it to undefined to prevent the link from being aggregated.
    boolean
    default: false
    Controls whether separate aggregate links are created for each of the directions the child links could have ('from', 'to', 'both' or 'neither').
    "small" | "normal" | "large" | "xlarge"
    default: 'normal'
    Controls the appearance of arrows on links. Arrowhead size is also proportional to the link width w.
    string(Colour)
    default: 'white'
    The colour to use for the chart background.
    number
    default: 0.2
    The alpha value to apply to backgrounded items, in the range 0 to 1.
    Bands

    Set to give the chart a set of labelled vertical background bands.

    Note that bands on a Leaflet map are not supported.

    const options = { bands: { top: true, bottom: true, bands: [{ x: 100, w: 100, c: '#F0F0F0', t: 'Band 1' }, { x: 200, w: 100, c: '#F8F8F8', t: 'Band 2' }] } };
    chart.options(options);
    Band[]
    An array of objects defining each of the bands.
    string(Colour)
    default: 'light grey'
    The colour of the band.
    boolean
    default: false
    Whether the band label should be displayed in bold font.
    string(Colour)
    default: 'light grey'
    The colour for the band label font.
    string
    The font family to use for the band label. The default is inherited from the FontFamily setting of chart.options().
    number
    default: 20
    The font size (px) of the band label. The size may be reduced to fit the label in the band.
    string
    The text of the band label.
    number
    default: 100
    The width of the band, in world coordinates.
    number
    default: 0
    The position of the centre of the band along the X-axis, in world coordinates.
    boolean
    default: false
    Whether labels are displayed at the bottom of the bands.
    boolean
    default: true
    Whether labels are displayed at the top of the bands.
    ChartComboOptions
    Controls the shape of open combos.
    required
    "rectangle" | "circle"
    default: 'circle'
    Sets the shape of all open chart combos.
    string(Colour)
    The rgb colour to use for the navigation and overview window controls. Only the hue and saturation of the colour are used: the lightness is fixed. To further customise the overview window, use the backColour and borderColour properties.
    "light" | "dark"
    default: 'light'
    The colour theme of the navigation and overview window controls.
    StyleOptions
    Settings to control the default style of certain chart objects.
    Glyph | null
    Sets the style of the counter glyph. The default is red in the top right corner showing the number of nodes contained within the combo.
    boolean
    default: false
    Controls whether or not the counter glyph is shown on open combos.
    ComboLinkStyle
    Styling options for combo links created by chart.combo().combine(), or by adding new links. Any unspecified properties are inherited from the styling of a link contained in the combo. See Link for default values.
    number
    The distance to back-off from end id1 as a ratio of the total length of the link line. Value in the range 0 to 1.
    number
    The distance to back-off from end id2 as a ratio of the total length of the link line. Value in the range 0 to 1.
    string(Colour)
    The colour of the link.
    "solid" | "dashed" | "dotted"
    The style of the link line.
    number
    The width of the link line. Also affect the size of arrowheads if present.
    Settings for the open style of combos. Accepts all options of the oc property except for the t option.
    Settings to control how dragging operations work in the chart.
    required
    boolean
    default: false
    Controls if links will be offset when selected and dragged. If false, links can be selected but not dragged. If true, links can be dragged. Dragging of self links is not possible.
    required
    boolean
    default: true
    If true, the chart automatically pans when dragging an item near the boundary of the visible chart area.
    string
    default: 'sans-serif'
    The default font family to use, for example 'helvetica'.
    Gradient

    Set to give the chart a background gradient fill that runs from top to bottom of the chart. Note that backColour property takes precedence over the gradient property.

    const options = { gradient: { stops: [{ r: 0, c: 'rgb(250, 250, 250)' }, { r: 1, c: 'rgb(200, 200, 200)' }] } };
    chart.options(options);
    required
    GradientColour[]
    Defines the gradient colours.
    required
    string(Colour)
    The colour to apply at the corresponding r value.
    required
    number
    Defines how far down the background the corresponding colour should apply. Should be between 0 and 1.
    boolean
    default: false
    If true, dragging the chart background drags all items. If false, dragging the chart background draws a bounding box for selecting items.
    number
    default: 150
    The number of milliseconds delay before the hover event is triggered.
    string
    default: 'sans-serif'
    The default font family to use for font icons, for example 'Font Awesome 6 Free' or 'Material Icons Outlined'.

    Sets the position and scale for images and font icons on nodes. The object accepts properties where property names are image or font icon paths and property values are the values to be adjusted:

    chart.options({
      imageAlignment: {
        'fas fa-user': { e: 0.8, dx: 5 },
        '/images/icons/person4.png': { dx: -20, dy: 5, e: 2.5 }
      }
    });

    When using images and font icons in label objects for node and annotation labels, image alignment is handled differently. See Image labels and Text-based labels.

    number
    default: 0
    The horizontal offset as a percentage value of the item's size. The range is -50 to 50.
    number
    default: 0
    The vertical offset as a percentage value of the item's size. The range is -50 to 50.
    number
    default: 1
    The enlargement factor of the item relative to its parent. Must be greater than 0.
    number
    An integer to move the label text up or down. Useful only for certain fonts where the baseline is irregular (e.g. Open Sans).
    boolean
    default: false
    If set to true, labels are drawn over glyphs. If false, glyphs are drawn over labels.
    boolean
    default: false
    If set to true, nodes with w and h specified are drawn behind other chart items as legacy shape nodes.
    LinkEnds
    Settings that control how the ends of links are drawn.
    boolean
    default: true
    Whether link ends should avoid node labels.
    "loose" | "tight"
    default: 'tight'
    Controls the spacing between nodes and link ends connected to them. If set to 'loose', there is a small gap between the node and the link end. Also affects the spacing between node subjects and annotation lines.
    LinkStyleOptions
    Settings to control how links are drawn.
    "horizontal" | "along"
    default: 'horizontal'
    Controls the positioning of multiple glyphs on links without labels.
    • 'along' - glyphs are drawn along the link.
    • 'horizontal' - glyphs are drawn horizontally.
    boolean
    default: false
    Controls the orientation of labels, glyphs and bubbles on links. When true, sub-items are rotated to match the link orientation. Note that enabling this option overrides the glyphs option.
    "direct" | "horizontal" | "vertical"
    default: 'direct'

    Controls the shape of links. Most effective with sequential layouts. Deprecated as we recommend using the linkShape option instead.

    • 'direct' - links are either straight or follow arcs when offset.
    • 'horizontal' - link ends join to nodes horizontally, following a curved path.
    • 'vertical' - link ends join to nodes vertically, following a curved path.

    The 'horizontal' and 'vertical' shapes will not apply to links within combos.

    number
    default: 0.75
    Only for links with a colour gradient (c2 property set). Controls the size of the fraction at the midpoint of the link where the colour transition occurs. Must be between 0 and 1, with 0 providing an immediate transition between colours. The rest of the link is drawn with solid colours.
    Logo
    Settings for the logo to be displayed in a corner of the chart.
    const options = { logo: { u: 'path/to/images/myAwesomeLogo.png', p: 'se', x: 20, y: 20 } };
    chart.options(options);
    "ne" | "se" | "sw" | "nw"
    default: 'ne'
    The position of the logo.
    string | null
    The URL of the logo to be displayed, or null for no logo. On Retina devices, KeyLines will also check for a double-resolution @2x version of the logo, e.g. path/to/images/[email protected]
    number
    default: 0
    The horizontal offset in pixels from the logo's default position.
    number
    default: 0
    The vertical offset in pixels from the logo's default position.
    "off" | "centre" | "ends"
    default: 'centre'
    Controls which part (or parts) of a link needs to be included within a selection marquee for the link to be selected. When set to 'off', links cannot be selected by a selection marquee.
    number
    default: 4
    Sets the maximum zoom for items, from minZoom to 4. Values around 1 are suggested for an optimal result.
    number
    default: 0.05
    Sets the minimum zoom for the view. Use a smaller value to allow the chart to be zoomed out further. The value can be from 0.001 to 1.
    object | boolean

    Settings for the navigation controls.

    const options = { navigation: { p: 'ne', shown: true, x: 10, y: 15 } };
    chart.options(options);

    If you don't want navigation controls on your chart, or you'd prefer to add custom controls, use:

    const options = { navigation: false };
    chart.options(options);

    See the Social Network Analysis demo for examples how to customise navigation controls.

    "ne" | "se" | "sw" | "nw"
    default: 'nw'
    The position of the navigation controls.
    boolean
    default: true
    Whether the navigation controls are displayed.
    number
    default: 0
    The horizontal offset in pixels from the navigation controls' default position.
    number
    default: 0
    The vertical offset in pixels from the navigation controls' default position.
    object | boolean

    Settings for the overview window. To hide the overview window, you can set it to false. Overview window is not supported on a Leaflet map.

    string(Colour)
    default: value of chart backColour

    The background colour of the overview window. If an rgba colour is used, the alpha channel is ignored.

    string(Colour)
    default: 'light grey'
    The colour of the border and view marker of the overview window.
    boolean
    default: true
    Whether the icon to toggle opening/closing the overview window is shown. Setting this to false when shown is false hides the overview window.
    "ne" | "se" | "sw" | "nw"
    default: 'se'
    The position of the overview window.
    boolean
    default: false
    If set to true, the overview window is fully expanded. If false, the overview window is collapsed into an icon.
    number
    default: 100
    The size of the overview window in pixels.
    object | null
    Styling options for selected links. If a link is selected and:

    If the selected link has t1 and/or t2 set, their styling is the first specified of:

    Note that if t1 / t2 inherit the styling from the border object from any of the above, any unspecified values will be set to defaults.

    number
    The distance to back-off from end id1 as a ratio of the total length of the link line. Must be between 0 and 1.
    number
    The distance to back-off from end id2 as a ratio of the total length of the link line. Must be between 0 and 1.
    The border around the link label.
    string(Colour)
    The colour of the link.
    string(Colour)
    If specified, the link will have a colour gradient, with colour c at the id1 end and colour c2 at the id2 end. The transition setting of linkStyle controls the gradient's appearance.
    boolean
    Whether the label should be displayed in bold font.
    string(Colour)
    The background colour of the font. The default is inherited from selectionColour.
    string(Colour)
    The colour of the label font. The default is inherited from selectionFontColour.
    string
    The font family to use for the label. The default is inherited from the fontFamily setting of chart.options().
    boolean | FlowOptions
    Options to customise the flow animation on the link. Set to true to enable flow with a default velocity of 2. Note that flowing links are always shown as dashed (overriding the ls property).
    number
    The font size (px) of the link label.
    "solid" | "dashed" | "dotted"
    The style of the link line.
    number | string | number[] | object
    default: '2 2 0 2'
    The distance between the link label text and the label edge. Borders are excluded. If used on multiline labels with border set, applies to the whole label container.
    0 | 1
    default: 0
    The priority of the link; see Prioritising links.
    string | LinkEndLabel
    The link label at the id1 end. For multiline labels, use '\n' or '\r' to force a line break. Strings inherit properties from the label at the centre of the link.
    string | LinkEndLabel
    The link label at the id2 end. For multiline labels, use '\n' or '\r' to force a line break. Strings inherit properties from the label at the centre of the link.
    number
    The width of the link line. Also affects the size of arrowheads if present.
    object | null
    Styling options for selected nodes:

    If selectedNode is only partially set, any values unset are inherited from the unselected node's styling. See Node for default values.

    string(Colour)
    The border colour. The default is inherited from selectionColour.
    "solid" | "dashed"
    The style of the border line.
    number
    The width of the node's border.
    string(Colour)
    The node background fill colour.
    number
    The enlargement factor for the node. Does not apply to nodes with w and h specified.
    boolean
    Whether the label should be displayed in bold font.
    string(Colour)
    The background colour of the font. When overriding properties on a node that contains a Node Label object or array of objects, the change only applies if the fbc property was set on the top node level or to those labels that don't have a set fbc property.

    The default is inherited from selectionColour.

    string(Colour)
    The colour of the label font. When overriding properties on a node that contains a Node Label object or array of objects, the change only applies if the fc property was set on the top node level or to those labels that don't have a set fc property.

    The default is inherited from selectionFontColour.

    string
    The font family to use for the label.
    The font icon used on the node.
    number
    The font size (px) of the node label. By default the font size will scale with the node's e property.
    The halo shown on the node. There are ten halo properties, ha0, ha1, ha2, etc., up to ha9.
    The style of the open combo.
    boolean
    Whether resize handles are shown on a legacy shape node. Shape nodes are drawn behind other chart items and are only available when legacyShapeNodeBehaviour is enabled.
    boolean
    If true, labels are shown in the centre of the node. If false, labels are shown at the bottom of the node. Deprecated as we recommend using the position option instead.
    string
    The URL of the image used on the node. To prevent non-square images from being distorted, set the node dimensions in w and h node properties in proportion to the aspect ratio of the image.
    string(Colour)
    default: 'rgb(114, 179, 0)'
    The default colour to use for highlighting selected nodes and links. Includes the node border and font background for nodes and a coloured circle and font background for links. Only applies to nodes and/or links if selectedNode and/or selectedLink are null or undefined.
    string(Colour)
    default: 'rgb(255, 255, 255)'
    The default font colour to use for selected nodes and links. Only applies to nodes and/or links if selectedNode and/or selectedLink are null or undefined.
    boolean
    default: false
    If true, links from a node to itself can be added to the chart. If false, self links are not loaded into the model.
    object
    Controls how node and link labels are truncated. If not set, labels are not truncated.
    number
    default: 30
    The maximum character length of a node or link label before it is truncated. If set, labels are truncated to the length specified, and the last three characters are replaced with ....
    boolean
    default: true
    If true, hovering over a node or a link reveals the full length of all their truncated labels. Use the hover option to change the hover interval. Not supported on touch devices.
    WatermarkOptions

    An object whose properties are the settings for a watermark on the chart.

    Note that watermarks on a Leaflet map are not supported.

    const options = { watermark: { a: 'top', fb: true, fs: 15, fc: 'black', t: 'A custom watermark' } };
    chart.options(options);
    "top" | "bottom" | "centre"
    default: 'centre'
    The vertical alignment of the watermark text.
    boolean
    default: false
    Whether the watermark is to be shown in bold.
    string(Colour)
    The background colour for the watermark text.
    string(Colour)
    The colour of the watermark text.
    string
    The font family to use. The default is inherited from the FontFamily setting of chart.options().
    number
    default: 80
    The watermark's font size (px).
    string
    The text of the watermark.
    string
    The URL of the watermark if an image is to be shown.
    ChartZoomOptions
    Controls how the chart zooms.
    boolean
    default: true

    Adapts the chart at low zoom levels to improve the visual appearance. For example, small nodes are enlarged to stay visible and links and text fade. For best results, set avoidLabels to false.

    Combo

    Combos can be used to combine nodes and links together to simplify the visualisation. To access the combo namespace, use chart.combo().

    Arranges the items inside a combo.

    Items are arranged automatically (default) or manually. The available automatic options are:

    • lens - automatic arrangement with connected nodes next to each other. The default for circular combos.
    • concentric - circular arrangement with larger items at the centre.
    • grid - grid arrangement running from left to right, from the top down in the order in which they are added in the combo. The default for rectangular combos.
    • sequential - tree-like arrangement showing the sequence of links between distinct levels of nodes.

    To stop items from being arranged automatically, set name to 'none'.

    Multiple ids can be passed to the arrange() function: in this case, items inside open combos within the array will be arranged.

    Return Object

    Use the returned promise to know when the operation is complete.

    Note: You must wait for the combine promise to be fulfilled before performing another chart function.

    required
    string | string[]
    The ids of the combos to be arranged.
    Options controlling the operation.
    Promise
    A Promise. You must wait for the promise to be fulfilled before performing another chart function.
    "all" | "inCombo" | "none"
    default: 'all'
    Controls how items outside a combo (at the top chart level or within the combo's parent combo) pull back or push in to adapt to combos that changed during arrange. Note that parent combos with a 'grid' arrangement always adapt.
    • 'all': all items adapt.
    • 'inCombo': items inside the parent combo adapt, top level layout stays unchanged.
    • 'none': no items adapt.
    boolean
    default: true
    Whether the operation should be animated.
    "auto" | object
    default: 'auto'
    When name is set to 'grid', controls the row/column dimension of the grid. Specify an object in the form { rows: number } or { columns: number }.
    string

    When layout name is set to 'sequential', the name of the custom property on the node's or combo node's d property that defines which level the node/combo belongs to. The property must contain a numeric value, where the lowest value node is placed at the top of the hierarchy. Levels for nodes with no level data are inferred from the nodes' links.

    "direct" | "curved" | "angled"
    default: 'direct'
    The shape of the path taken by links.
    • 'direct' - links are either straight or follow arcs when offset.
    • 'curved' - link follow a curved path, and attach to nodes in the direction of orientation.
    • 'angled' - links follow straight lines with corners: useful for hierarchical data sets. Currently in beta.

    The direction of 'curved' and 'angled' links is inferred from orientation.

    "lens" | "concentric" | "grid" | "sequential" | "none"
    default: 'lens' / 'grid'
    Controls how nodes are arranged inside an open combo.
    • 'lens' - automatic arrangement with connected nodes next to each other. The default for circular combos.
    • 'concentric' - circlular arrangement with larger items at the centre.
    • 'grid' - grid arrangement running from left to right, from the top down in the order in which they are added in the combo. The default for rectangular combos.
    • 'sequential' - tree-like arrangement showing the sequence of links between distinct levels of nodes.
    • 'none' - items are kept in their original positions.
    string | OrderByOptions
    When the arrangement name is 'sequential', specifies the order of nodes/combos within the same arrangement level of a connected component in the chart. Any disconnected nodes or combos are ignored.
    string
    The key of the custom data value on the node's d property used to order nodes alphanumerically within each level. When specified, nodes are ordered alphanumerically, in descending order, unless sortBy is also set.
    "ascending" | "descending"
    default: 'descending'
    The direction of ordering.
    "left" | "right" | "up" | "down"
    default: 'down'
    When name is set to 'sequential', the orientation of the arrangement.
    "none" | "circle" | "rectangle" | "adaptive" | "aligned"
    default: 'aligned'
    When name is set to 'sequential', the packing mode to use.
    boolean
    default: true
    If true, the open combos will be resized to fit their contents. If false, they will not be resized.
    "auto" | "equal" | "stretched"
    default: 'auto'
    When name is set to 'sequential', the spacing between nodes at each level.
    StackOptions
    When name is set to 'sequential', stacking options for nodes sharing the same neighbours and level. If property is set in orderBy, stacking is only applied to nodes sharing the same property value.
    required
    "none" | "grid"
    default: 'none'
    If set to 'grid', four or more same-level nodes with identical neighbours are stacked in a grid.
    boolean
    default: true
    By default, links are drawn ignoring off. If false, link offsets are preserved.
    number
    default: 1
    When name is set to 'sequential', the spacing between levels. Values must be positive.
    "auto" | "equal"
    default: 'equal'
    The type of spacing between levels in sequential layout. Set to 'auto' if individual levels contain unevenly sized items (nodes or combos) to optimise use of space and get more even distribution of levels.
    number
    default: 5
    Controls how close items are to each other in open combos. Must be in the range 0 to 10, with higher values being closer.
    number
    default: 250
    If animated, the time the animation should take, in milliseconds.
    string | string[]
    When name is set to 'sequential', and level isn't set, specifies the node(s) in the top level of the arrangement. Nodes without top specified are unchanged during the layout but but may be repositioned by packing.

    Closes the specified open combo/s, concealing the items inside.

    required
    string | string[]
    The ids of the combos to be closed.
    Options controlling the operation.
    Promise
    A Promise. You must wait for the promise to be fulfilled before performing another chart function.
    "all" | "inCombo" | "none"
    default: 'all'
    Controls how items outside a combo (at the top chart level or within the combo's parent combo) pull back or push in to adapt to the opening or closing combo. Note that parent combos with a 'grid' arrangement always adapt.
    • 'all': all items adapt.
    • 'inCombo': items inside the parent combo adapt, top level layout stays unchanged.
    • 'none': no items adapt.
    boolean
    default: true
    Whether the operation should be animated.
    number
    default: 250
    If animated, the time the animation should take, in milliseconds.

    Combines a number of nodes into one or more 'combo nodes'. A combo definition object defines which nodes should be included in these combos and how they should be displayed.

    A combo can be created in one of two states:

    • closed (default) - items inside the combo are not visible.
    • open - items inside the combo are displayed inside a combo border on the chart.

    To open a combo, set the open property on its definition object.

    Any links that connect nodes outside the combo to nodes inside it are combined into 'combo links'.

    Return Object

    Use the returned promise to detect when the operation has completed. The fulfilled promise returns an array of the identities of the combo nodes created as the first argument.

    Note: You must wait for the combine promise to be fulfilled before performing another chart function.

    chart.combo().combine({ ids: [id1, id2] }).then((comboIds) => {
      // do more after combine
    });

    To create many combos at once, use an array of combo definitions.

    chart.combo().combine(
      [{ ids: [id1, id2] }, { ids: [id3, id4] }]).then((comboIds) => {
      // do more after combine
    });

    You cannot combine items that already exist inside a combo.

    Closed and open combo states should not be confused with hide() and show() chart functions. If you combine a mixture of hidden and shown nodes, the nodes inside the combo will remain hidden or shown as appropriate. If you combine only hidden nodes, the combo itself will be hidden.

    required
    ComboDefinition | ComboDefinition[]
    A definition of the combo/s to create.
    any
    If defined, all properties will be transferred to the new combo's d property.
    number
    default: 0
    An x offset for positions of members of the combo if it is later uncombined.
    number
    default: 0
    A y offset for positions of members of the combo if it is later uncombined.
    Glyph | null
    The style of the counter glyph showing the number of nodes inside the closed combo. The default counter glyph is red and is located in the top right corner. Set to null to disable counter glyphs.
    required
    string[]
    The ids of nodes to combine. This can contain one or more node ids.
    string
    The default combo label if no label is set in the style or openStyle properties.
    boolean
    default: false
    Whether the combo should be created in the open state.
    The style of the open combo node. If not set, the style is inherited from the openCombos setting of defaultStyles.
    "average" | "first"
    default: 'average'
    The chart position of the final combo.
    • 'average': use the average position of the nodes to centre the arrangement.
    • 'first': use the position of the first node in the ids array.
    The style of the closed combo node. If not set, the style is inherited from the first node in the ids array except for the t option. If hi is not set, the combo is visible if any of its member nodes are visible. Setting parentId in style is not supported.
    Options controlling the operation.
    Promise
    A Promise. You must wait for the promise to be fulfilled before performing another chart function.
    boolean
    default: true
    Whether the combination(s) should be animated.
    default: 'lens' / 'grid'
    Controls the arrangement of nodes inside an open combo. Can be set directly to any value from the name property, or to an object that sets a name and any properties associated with that arrangement.
    boolean
    default: true
    Whether the combo(s) should be selected.
    number
    default: 250
    If animated, the time the animation should take, in milliseconds.

    Finds the ids of the combos that contain the given nodes, links or child combos.

    required
    string | string[]
    The ids of the nodes, links or combos whose parents should be found.
    Options controlling how the find operates.
    string | null | (string | null)[]
    The ids of the combos containing the given items, or null if not found.
    "top" | "first"
    default: 'top'
    Specifies where to look for a parent of an item. There's a parent-child relationship between a combo and the items it contains.
    • 'first': finds the immediate parent of the item.
    • 'top': finds the parent at the top of the nested combo hierarchy.

    Finds every underlying node and link inside a combo or nest of combos, or null if the id is not a combo.

    required
    string
    The id of the combo.
    object | null
    An object in the form:
    {
      links:[link1, link2, ..],
      nodes:[node1, node2, ..]
    }

    Tests node or link ids to find out whether they are combo nodes or combo links. If a list of ids is used, it returns true if any of the items are combos.

    The options argument defines which items to test. For example, to test whether a selection contains a combo node:

    const selectionContainsNodeCombo = chart.combo().isCombo(chart.selection(), { type: 'node' });
    required
    string | string[]
    The id/s of the items to be tested.
    Options controlling whether links or nodes are tested.
    boolean
    True if any of the node or link id is a combo, false otherwise.
    "link" | "all" | "node"
    default: 'all'
    Specifies which types of item are tested.

    Tests whether an item is an open combo.

    required
    string
    The id of the item to be tested.
    boolean
    True if the item id is an open combo, false otherwise.

    Opens the specified combo/s so the contents are visible inside a combo border on the chart. To change the border style, set the openStyle options of chart.combo().combine.

    required
    string | string[]
    The id/s of the combos to be opened.
    Options controlling the open operation.
    Promise
    A Promise. You must wait for the promise to be fulfilled before performing another chart function.
    "all" | "inCombo" | "none"
    default: 'all'
    Controls how items outside a combo (at the top chart level or within the combo's parent combo) pull back or push in to adapt to the opening or closing combo. Note that parent combos with a 'grid' arrangement always adapt.
    • 'all': all items adapt.
    • 'inCombo': items inside the parent combo adapt, top level layout stays unchanged.
    • 'none': no items adapt.
    boolean
    default: true
    Whether the operation should be animated.
    number
    default: 250
    If animated, the time the animation should take, in milliseconds.

    Gets or sets the list of revealed links.

    Links which connect nodes inside a combo to nodes outside it are normally combined into a single link to reduce clutter. The reveal() function shows the original underlying links.

    Calling reveal() with a parameter replaces the previous list of revealed links. Pass an empty array to clear all revealed links.

    string | string[]
    The id/s of the links to be revealed.
    string[]
    The currently revealed links.

    Transfers the specified items into or out of a combo, increasing the size of the target combo as needed to fit its new contents.

    required
    string | string[]
    The id/s of nodes to be transferred into or out of a combo.
    required
    string | null
    The id of the combo to transfer the items to, or null to transfer items out of the combo and onto the chart.
    Options controlling the transfer operation.
    Promise
    A Promise. You must wait for the promise to be fulfilled before performing another chart function.
    "all" | "inCombo" | "none"
    default: 'all'
    Controls how items outside a combo (at the top chart level or within the combo's parent combo) pull back or push in to adapt to the combo that changed during transfer. Note that parent combos with a 'grid' arrangement always adapt.
    • 'all': all items adapt.
    • 'inCombo': items inside the parent combo adapt, top level layout stays unchanged.
    • 'none': no items adapt.
    boolean
    default: true
    Whether the transfer operation should be animated.
    default: 'lens' / 'grid'
    Controls the arrangement of nodes inside an open combo. Can be set directly to any value from the name property, or to an object that sets a name and any properties associated with that arrangement.
    boolean
    default: true
    Controls whether the open combo is reduced in size to fit if some contents have been removed or it's been arranged more densely. If true, the combo's size is decreased to fit. If false, its size is not reduced.
    number
    default: 250
    If animated, the time the animation should take, in milliseconds.

    Uncombines the specified combo nodes. Items inside the combo(s) are displayed on the chart. Combo links that connect nodes inside the combo to nodes outside it are also uncombined.

    When nodes are uncombined, their original position is used to place them in the same shape relative to the uncombined node.

    Multiple ids can be passed to the uncombine() function: in this case, all combo nodes in the array will be uncombined.

    You cannot uncombine nested items (combo nodes and combo links that exist inside other combos).

    Return Object

    Use the returned promise to know when the operation is complete.

    Note: You must wait for the combine promise to be fulfilled before performing another chart function.

    required
    string | string[]
    The id/s of the combos to be uncombined.
    Options controlling the uncombine operation.
    Promise
    A Promise. You must wait for the promise to be fulfilled before performing another chart function.
    boolean
    default: true
    Whether the operation should be animated.
    boolean
    default: false
    Whether all nodes inside the combo (including nodes inside nested combos) should be uncombined. If false, only the first level of the combo is uncombined.
    boolean
    default: true
    Whether the uncombined nodes should be selected.
    number
    default: 250
    If animated, the time the animation should take, in milliseconds.

    Graph

    Graph functions let you explore the graph structure of your data.

    For more information about chart levels, and using graph functions with combos, see the Running graph analysis section in Combos Concepts.

    Calculates the betweenness centrality of all nodes in the graph.

    Return Object

    The returned objects properties are the ids of the nodes in the graph. The values are the betweenness values.

    chart.graph().betweenness({}).then((betweenness) => {
      const sizes = Object.keys(betweenness).map((id) => {
        return { id: id, e: Math.pow(1 + betweenness[id], 2) };
      });
      return chart.animateProperties(sizes, { time: 500 });
    });

    The betweenness call is asynchronous - the function will return before the betweenness has completed. To discover the progress of the betweenness use the progress event.

    Use the returned promise to detect when betweenness has finished.

    Options which define if the graph is directed, the result normalized and values associated with the links.
    Promise
    A Promise that resolves to an object whose properties are the ids of the nodes in the graph. The values are the betweenness values.
    boolean
    default: false
    Whether the function should also iterate over hidden items in the chart.
    boolean
    default: false
    Whether the betweenness computation should consider the direction of links.
    "chart" | "unnormalized" | "component"
    default: 'component'
    Defines how the betweenness measure should be normalized.
    string
    The key of the custom data value on the node's d property that defines each link's length.
    boolean
    default: false
    If true, the path length of any link is the reciprocal of the value ( 1 / value ).

    Removes all items from the graph engine.

    void

    Calculates the closeness centrality of all nodes in the graph.

    Return Object

    The function returns an object whose properties are the ids of the nodes in the graph. The values are the closeness values.

    chart.graph().closeness({}).then((closeness) => {
      Object.keys(closeness).forEach((id) => {
        console.info(`node '${id}' closeness is ${closeness[id]}`);
      });
    });

    The closeness call is asynchronous - the function will return before the closeness has completed. To discover the progress of the closeness use the progress event.

    Use a promise function to detect when the closeness has finished.

    Options which define if the graph is directed, the result normalized and values associated with the links.
    Promise
    A Promise that resolves to an object whose properties are the ids of the nodes in the graph. The values are the closeness values.
    boolean
    default: false
    Whether the function should also iterate over hidden items in the chart.
    "from" | "to" | "any"
    default: 'any'
    How to treat the direction of links:
    • 'from': counts only links with arrows pointing away from nodes (out-degree).
    • 'to': counts only links with arrows pointing to nodes (in-degree).
    • 'any': counts all links regardless of whether they have arrows.
    Note that to use 'from' or 'to', your graph must have arrows on links.
    "chart" | "unnormalized" | "component"
    default: 'component'
    Defines how the closeness measure should be normalized.
    string
    The key of the custom data value on the node's d property that defines each link's length.
    boolean
    default: false
    This option means that the path length of any link is the reciprocal of the value, i.e. ( 1 / value ).

    Groups nodes in the graph into a set of clusters, and then returns an array describing them.

    Options which control how the calculation is done.
    array
    An array [cluster1, cluster2, ...] where cluster1, cluster2... are arrays containing ids of nodes that are all in the same cluster.
    boolean
    default: false
    Whether the function should also iterate over hidden items in the chart.
    boolean
    default: true
    If true, returns the same result every time you run a cluster.
    number
    default: 5
    A number from 0 to 10 that affects cluster size. Higher values give smaller clusters, but more of them, whereas lower values give larger clusters, but not as many.
    string
    The custom property which defines each link's value. Custom properties are set on the d property of the links. Higher valued links tend to cluster their nodes more closely.

    Returns the separate 'connected components' of the graph.

    Options which define special rules for items iteration.
    array

    An array of objects describing the items contained by each component:

    [
      { nodes: ['node1', 'node2'], links: ['link-12']},
      { nodes: ['node3']}
    ]
    boolean
    default: false
    Whether the function should also iterate over hidden items in the chart.

    Calculates the degrees (number of links) of all nodes in the graph.

    The degrees function does not count any self links (links that have the same node at both ends).

    Return Object

    The function returns an object whose properties are the ids of the nodes in the graph. The values are the degree values.

    const outDegrees = chart.graph().degrees({ direction: 'from' });
    const sizes = Object.keys(outDegrees).map((id) => {
      return { id: id, e: Math.sqrt(outDegrees[id]) };
    });
    chart.animateProperties(sizes, { time: 500 });
    Options which define the direction and values associated with the links.
    An object whose properties are the ids of the nodes, the values of which are the degree values.
    boolean
    default: false
    Whether the function should also iterate over hidden items in the chart.
    "from" | "to" | "any"
    default: 'any'
    How to treat the direction of links:
    • 'from': counts only links with arrows pointing away from nodes (out-degree).
    • 'to': counts only links with arrows pointing to nodes (in-degree).
    • 'any': counts all links regardless of whether they have arrows.
    Note that to use 'from' or 'to', your graph must have arrows on links.
    string
    The custom property which defines each link's value. Custom properties mean properties set on the d property of the links.

    Calculates the distances of all nodes from the node specified. The distance is the number of edges in a shortest path.

    All values must be positive numbers. If there are multiple links between two nodes, the minimum distance value will be used. No results are returned for disconnected nodes.

    If you do not specify a value property, the distance values of all links are set to 1.

    const distances = chart.graph().distances(chart.selection()[0]);
    const labels = Object.keys(distances).map((key) => {
      return { id: key, t: distances[key] };
    });
    chart.setProperties(labels);
    required
    string
    The id of the node to start from.
    Options for the direction and values associated with the paths.
    An object whose properties are the ids of the nodes and whose values are the distances.
    boolean
    default: false
    Whether the function should also iterate over hidden items in the chart.
    "from" | "to" | "any"
    default: 'any'
    How to treat the direction of links:
    • 'from': counts only links with arrows pointing away from nodes (out-degree).
    • 'to': counts only links with arrows pointing to nodes (in-degree).
    • 'any': counts all links regardless of whether they have arrows.
    Note that to use 'from' or 'to', your graph must have arrows on links.
    string
    The custom property which defines the distance value of a link. Custom properties mean properties set on the d property of the links.
    boolean
    default: false
    This option means that the path length of any link is the reciprocal of the value, i.e. ( 1 / value ).

    Computes the eigenvector centrality of each node.

    Eigenvector centrality is a measure of influence that takes into account the number of links each node has and the number of links their connections have, and so on throughout the network.

    All values must be positive numbers. If there are multiple links between two nodes, the sum of the values of each link will be used.

    If you do not specify a value property, the values of all links are set to 1.

    The results are normalised so that the sum of the eigenvector centrality values in each component equals the number of nodes in that component. For example, an isolated node will always have an eigenvector centrality of 1.

    Link direction does not affect the eigenvector centrality calculation.

    Options which define special rules for the eigenCentrality computation.
    An object listing the eigenvector centrality of each node.
    boolean
    default: false
    Whether the function should also iterate over hidden items in the chart.
    string
    The custom property which defines the value of a link. Custom properties mean properties set on the d property of the links. If not set, all links have value 1.

    Calculates subgraphs of the graph where each node has a degree of at least k. It works by successively removing nodes of degree less than k until no further nodes can be removed.

    Return Object

    The function returns an object with all kCores values and the maximum k found in the chart. With a given k it is possible to find all cores components:

    const kCores = chart.graph().kCores();
    const hidden = Object.keys(kCores.values).filter((id) => {
      return kCores.values[id] < 5;
    });
    chart.hide(hidden, { time: 500 });
    // the next call identifies the separate cores
    chart.graph().components();
    Options which define special rules for items iteration.
    object
    number
    The maximum k value in the graph.
    IdMap/Number
    An object whose property names are the ids of the nodes and whose values are the k value for that node.
    boolean
    default: false
    Whether the function should also iterate over hidden items in the chart.

    Replaces the graph data with the new data specified.

    Note that the data argument is a JavaScript Object, not a JSON string. It should have the properties specified in Item Format.

    required
    The data to load into the graph engine.
    void

    Finds items that are neighbours (are linked to) the id or ids passed in.
    string | string[]
    The id/s of the item/s whose neighbours should be found.
    Options which define special rules for items iteration.
    object
    string[]
    Array of neighbouring node ids.
    string[]
    Array of neighbouring link ids.
    boolean
    default: false
    Whether the function should also iterate over hidden items in the chart.
    "from" | "to" | "any"
    default: 'any'
    How to treat the direction of links:
    • 'from': counts only links with arrows pointing away from nodes (out-degree).
    • 'to': counts only links with arrows pointing to nodes (in-degree).
    • 'any': counts all links regardless of whether they have arrows.
    Note that to use 'from' or 'to', your graph must have arrows on links.
    number
    default: 1
    This defines how far away neighbours can be from the passed ids.

    Computes the PageRank of each node.

    The PageRank measure identifies important nodes by assigning each node a score based on its number of incoming links (its ‘indegree’). These links are weighted depending on the relative scores of their originating nodes.

    All values must be positive numbers. If there are multiple links between two nodes, the sum of the values of each link will be used.

    If you do not specify a value property, the values of all links are set to 1.

    Options which define special rules for PageRank computation.
    An object containing the PageRank of each node.
    boolean
    default: false
    Whether the function should also iterate over hidden items in the chart.
    boolean
    default: true
    If false, all the links are treated as undirected for the PageRank computation.
    string
    The custom property which defines the value of a link. Custom properties mean properties set on the d property of the links. If not set, all links have value 1.

    Calculates all the shortest paths between the nodes specified.

    const paths = chart.graph().shortestPaths('start', 'end', { direction: 'any' });
    console.log('Number of hops = ' + paths.distance);
    chart.selection(paths.items);

    All values must be positive numbers.

    If you do not specify a value property, the values of all links are set to 1.

    string
    The id of the starting node on the path.
    string
    The id of the ending node on the path.
    Options for the direction and values associated with the paths.
    object
    An object which describes the path structure.
    string[]
    One of the shortest paths found - returned as an array of alternating node and link ids, including the start and end nodes.
    string[]
    An array describing the same path as onePath, but containing node ids only, including the start and end nodes.
    string[]
    An array of all node and link ids that are on any of the shortest paths, including the start and end nodes.
    number
    The length of the shortest path - more precisely the combined link value of the path.
    boolean
    default: false
    Whether the function should also iterate over hidden items in the chart.
    "from" | "to" | "any"
    default: 'any'
    How to treat the direction of links:
    • 'from': counts only links with arrows pointing away from nodes (out-degree).
    • 'to': counts only links with arrows pointing to nodes (in-degree).
    • 'any': counts all links regardless of whether they have arrows.
    Note that to use 'from' or 'to', your graph must have arrows on links.
    string
    The custom property which defines the value of a link. Custom properties mean properties set on the d property of the links.
    boolean
    default: false
    Whether the path length of any link is the reciprocal of the value, i.e. ( 1 / value ).

    Map

    Map functions allow you to show chart items on a map. To access the map namespace, use chart.map(). See also the map event which is triggered by the chart.

    Hides the Leaflet map that was displayed with the show function. Chart nodes with lat and lng properties are repositioned as specified by the transition setting. The speed of the transition depends on settings made with the options function. The chart triggers a map event at the start and end of the hide operation.

    Note:
    • If the map is already hidden, or a show or hide transition is underway, this call has no effect.
    • Cannot be used while the chart's container is set to null.

    To show the Leaflet map again, call show().

    Discovers whether the Leaflet map is currently shown.

    When a show() transition is underway, isShown returns false until it is complete. When a hide() transition is underway, isShown returns true until it is complete.

    boolean
    True if the map is currently shown, false otherwise.

    Gets direct access to the underlying Leaflet map object. This allows you to use the Leaflet API directly, for example to add new layers to the map. The Leaflet map object is only returned when the map is shown. When the map is hidden, the underlying Leaflet map object is removed and this function returns null.

    Refer to the relevant release version of the Leaflet API Reference for details of the Leaflet API.

    object
    The Leaflet map object.

    Converts a set of view coordinates to the exact latitude and longitude.

    required
    number
    The x position in view coordinates.
    required
    number
    The y position in view coordinates.
    object
    The geospatial coordinates of the specified point.
    number
    The latitude of the location.
    number
    The longitude of the location.

    Sets or gets options for the Leaflet map. See Map Options.

    chart.map().options({
      tiles: {
        url: 'http://example.com/path/{z}/{x}/{y}.png',
        attribution: 'Attribution text',
        minZoom: 4,
        maxZoom: 12,
        noWrap: false
      }
    }).then(() => {
      // do more after options
    });

    Note: If you reference a Leaflet map tile URL or object that's on a different domain to the KeyLines library, your browser will display it, but won’t let KeyLines examine it or render it to a data URL. For details of how to fix this, see Cross-Origin Images (CORS).

    The options to set for the Leaflet map.
    object | Promise
    Getter: The current map options.
    Setter: A Promise object.

    Displays a Leaflet map behind the chart. Chart nodes with lat and lng properties are moved to the correct position on the map, see the Map Position Object. Nodes without valid lat and lng properties will be hidden.

    The speed of the transition and the appearance of the Leaflet map depend on settings made with the options function. The chart triggers a map event at the start and end of the show operation.

    Note:

    • If the map is already shown, or a show or hide transition is underway, this call has no effect.
    • Cannot be used while the chart's container is set to null.
    • When calling chart.map().show(), the handMode option is automatically set to true.

    To hide the map again, call chart.map().hide().

    Converts a set of latitude and longitude coordinates to the exact point in the view.

    required
    number
    The latitude position of the point.
    required
    number
    The longitude position of the point.
    object
    An object containing the view coordinates.
    number
    The horizontal coordinate.
    number
    The vertical coordinate.

    Map Options

    These are the options you can pass to the first argument of chart.map().options().

    boolean
    default: true
    Whether showing and hiding the Leaflet map should be animated.
    object

    Pass options directly into the Leaflet constructor. See the L.map options documentation in the relevant version of the Leaflet API Reference.

    number
    default: 5
    Specifies how much space, in pixels, to leave around the Leaflet map when zooming to fit.
    string | object | null

    An option to set the url template for Leaflet map tiles. Accepts either a string in the form of 'http://example.com/path/{z}/{x}/{y}.png', or an object in the Leaflet L.tileLayer options format with an additional url property:

    chart.map().options({
      tiles: {
        url: 'http://example.com/path/{z}/{x}/{y}.png',
        attribution: 'Attribution text',
        minZoom: 4,
        maxZoom: 12,
        noWrap: false
      }
    }).then(() => {
      // do more after options
    });

    If the url template isn't set, OpenStreetMap is used as a default tile provider. If set to null, the tile layer isn't created.

    See the L.tileLayer options documentation in the relevant version of the Leaflet API Reference.

    See the Map Layers documentation for more details about tiles and the default map tiles used by KeyLines.

    Note: If you reference a map tile URL or object that's on a different domain to the KeyLines library, your browser will display it, but won't let KeyLines examine it or render it to a data URL. For details on how to fix this, see Cross-Origin Images (CORS).

    number
    default: 800
    If animated, the time that showing or hiding the Leaflet map should take, in milliseconds.
    "layout" | "restore"
    default: 'restore'
    Controls how items are positioned when transitioning from Leaflet map to network. Use 'restore' to move items back to their previous positions, or 'layout' to position using a 'organic' layout.

    Time Bar

    Time bar functions allow you to get and set the time bar's range, and display a histogram with it. To obtain a time bar object to call these functions on, use KeyLines.create.

    Removes all data from the time bar.

    void

    Destroys the current instance of the time bar, freeing any allocated resources.

    Note: This action cannot be undone. Create a new time bar instance with KeyLines.create() to access the timebar namespace.

    timebar.destroy();
    void

    Returns an array of the ids that have datetimes in the specified range. A datetime dt is in the specified range if it satisfies dt1 <= dt < dt2.

    required
    number | Date
    The start of the required range of datetimes. This is inclusive of the stated value.
    required
    number | Date
    The end of the required range of datetimes. This is exclusive of the stated value.
    string[]
    The ids that have datetimes in the specified range.

    Determines whether the item has a datetime either within the time bar's time range, or which overlaps any part of a time period in the range. Note that the item must have been loaded into the time bar.

    If the item does not have a datetime, or the item does not exist or overlap a time period in the time bar's loaded data, then inRange() will return false.

    required
    TimeBarItem | string
    The item or id to range test.
    boolean
    True if the specified item exists in the time bar and has a datetime that's either within the time range, or which overlaps any part of a time period, false otherwise.

    Replaces the time bar data with the new data specified.

    The data argument is a JavaScript Object, not a JSON string. It should have the properties specified by the Time Bar Item Properties.

    If the loaded data changes the current time range, the timebar.change() event is not fired. If you don't want the range to change, first set the maxRange time bar option to take account of the data you're about to load.

    To fit the time bar to the data once it has been loaded, use returned promise:

    timebar.load(data).then(() => {
      return timebar.zoom('fit', { animate: false });
    });
    required
    The data to load into the time bar.
    Promise
    A Promise.
    required
    The KeyLines time bar data format.

    Sets or gets a list of dates or time periods (with both start time and end time specified) which should be marked in a different colour in the histogram.

    This example shows how to mark one time as well as a range of times:

    const marks = [
      // mark 1 - single date
      new Date('26 Jul 2010 08:00:00'),
      // mark 2 - time period - both start and end time must be set
      {
        dt1: new Date('18 Jul 2010 14:00:00'),
        dt2: new Date('21 Jul 2010 14:00:00')
      }
    ];
    timebar.mark(marks);

    To clear all the marks pass an empty array as an argument.

    number | Date | TimePeriod | (number | Date | TimePeriod)[]
    The timestamps to set marks on.
    (number | Date | TimePeriod)[]
    The current mark list.

    Inserts new data into the time bar, merging it with any existing time bar data.

    Incoming items that exactly match existing items in the time bar are merged with them on a one-to-one basis.

    Note that the items argument is a JavaScript object or array, not a JSON string. It should have the properties specified in the Time Bar Object Properties.

    required
    TimeBarItem[] | object
    The KeyLines time bar data object or array of items to merge into the existing time bar data.
    Promise
    A Promise.

    Detaches an event handler function for one or more events attached to the time bar using the on() function.

    timebar.off('change', changeEventHandler);

    If no handler is supplied, all handlers for the specified event are detached. If no event name is supplied, all event handlers for all events are detached.

    The name of the event to be detached from, e.g., 'click'. Use 'all' to detach from all events.
    function
    The event handler that was supplied to the on() call.
    void

    Attaches an event handler function for one or more Time Bar Events to the time bar.

    function changeEventHandler() {
      // respond to change event
    }
    timebar.on('change', changeEventHandler);

    To detach event handlers, use off().

    See Events Basics for more details.

    required
    The name of the event to be attached to, e.g., 'click'. Use 'all' to listen to all events.
    required
    function
    The event handler to call when the event occurs.
    void

    Sets or gets options for the time bar.

    Note that using this promisified function as a getter still returns an object in a synchronous way. See Special Cases: getters and setters for more detail.

    The options to set for the time bar.
    object | Promise
    Getter: The current time bar options. See Time Bar Options.
    Setter: A Promise object.

    Pans the time bar in the direction specified.

    "forward" | "back"
    The direction to pan. Default is 'forward'.
    Options controlling the pan operation.
    Promise
    A Promise.
    boolean
    default: true
    Whether the transition should be animated.
    number
    default: 200
    The length of the animation in milliseconds.

    Stops the continuous animation of the time bar range started by play().

    void

    Starts a continuous animation of the time bar range. The speed of the animation can be set via the options function's playSpeed property.

    Options controlling the play operation.
    void
    boolean
    default: false
    If true, the start of the range stays fixed and the end is extended.

    Sets or gets the time range of the time bar. If called without parameters, it returns the time range of the time bar without updating it.

    Setting the time range causes different visual effects according to whether the sliders are fixed, free, or not present.

    • If the sliders are fixed then setting the time range moves and zooms the scale underneath the sliders.
    • If the sliders are free then the sliders themselves move to the time range specified and scale does not change.
    • If there are no sliders (sliders:'none') then the time range is displayed in the full width of the time bar.

    Things to note:

    • There are minimum and maximum limits on the time range size, and the time range must either overlap or be adjacent to the time range of loaded data. The requested range may be adjusted to meet these constraints.
    • The range function returns a JavaScript Date object. For more details see Time Zones.
    • Using this promisified function as a getter still returns an object in a synchronous way. See Special Cases: getters and setters for more detail.
    number | Date
    The new start time for the time range of the time bar. This is inclusive of the stated value.
    number | Date
    The new end time for the time range of the time bar. This is exclusive of the stated value.
    Options controlling the operation.
    object | Promise
    Getter: An object with JavaScript Date objects.
    Setter: A Promise object.
    Items are in the range if their time dt satisfies dt1dt < dt2.
    Date
    The start time for the time range of the time bar, as a Date object.
    Date
    The end time for the time range of the time bar, as a Date object.
    boolean
    default: true
    Whether the transition should be animated.
    number
    default: 200
    The length of the animation in milliseconds.

    Removes item or items with the id(s) specified. Pass a single id to remove a single item, or an array of id strings to remove many items at once. Note that there is no event to detect items being removed from the time bar.

    required
    string | string[]
    The id string or array of id strings of items to remove.
    void

    Sets or gets the time bar selection lines.

    This example shows how to create multiple selection lines by passing an array:

    const lines = [
      // selection 1 - blue colour
      { id: ['id1', 'id2'], index: 0, c: 'blue' },
      // selection 2 - default colour
      { id: ['id3', 'id4'], index: 1 }
    ];
    timebar.selection(lines);

    To clear all the selections pass an empty array as argument. To clear a specific selection pass a selection object with an empty array as the id and its index.

    Things to note:

    • The maximum number of selection lines available is 3: any selection with an index greater than 2 will be ignored. The default colours for the selection lines are: 0: green; 1: orange; 2: dark red.
    • The selection lines use a different scale to the histogram bars. Selection lines are scaled depending on the values within the selection range.
    • Passing a smaller array in subsequent selection() calls will not clear all selection lines. To clear existing selection lines, pad the array with empty objects.
    An array of selection lines to be drawn on the time bar, or an object if just one selection line.
    string[][]
    Array of the current selection lines. Each line is given by an array of the id strings in the selection.
    string(Colour)
    The colour for the selection line.
    string | string[]
    An id string or array of id strings.
    number
    The index for the selection line. This field can be omitted when a single selection is passed.

    Sets the location of the time bar in the DOM. Pass null as the argument to hide it completely.

    Things to note:

    • You must specify the container parameter in KeyLines.create() to use setContainer.
    • While the container is set to null all drawing and animations are paused.
    timebar.setContainer('timebarContainer');
    required
    string | HTMLElement | null
    The id string or DOM element of the parent container that the time bar should be appended to.
    void

    Zooms the time bar in the manner specified.

    "fit" | "in" | "out"
    How to zoom the time bar. The default is 'in'.
    Options controlling the zoom operation.
    Promise
    A Promise.
    boolean
    default: true
    Whether the transition should be animated.
    string | string[]
    When running zoom('fit',...), the ids of items to include in the fit range. If not specified, all items are included.
    number
    default: 200
    The length of the animation in milliseconds.

    Time Bar Events

    Events let you customise your application by responding to user actions on the time bar surface. To attach handlers to events, use timebar.on().

    Fires when any event occurs on the time bar. It returns an object containing both the name of the event and the object returned by that event.

    Default action: None

    object | undefined
    The object returned by the event when listened to directly, or undefined if event does not return a value.
    string
    The name of the event.

    The change event fires when the time range is changed, either by the user or programmatically. To get the new range, use the range() function.

    The event also fires when the time bar data is changed but only if the change affects the current range.

    Default action: None

    "range" | "data"
    The type of change.

    The click event fires on a click or tap.

    Default actions:

    • On a control button: Performs the button action.
    number
    The index of the button used.
    boolean
    If the default action was prevented.
    number
    Index of clicked group within bar.
    number[]
    Value of each group within bar.
    number
    The index of the selection clicked on, or null for other click types.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.
    number
    The unique identifier of the pointer.
    string
    The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
    function
    Call to prevent the event's default action.
    Date
    The upper bound of the time at the pointer.
    Date
    The lower bound of the time at the pointer.
    number
    A suggested location for the tooltip in the x direction - the centre of the bar or selection point.
    number
    A suggested location for the tooltip in the y direction - the height of the bar or selection point.
    TimeBarItemId

    The type of clicked item:

    • 'area' - the area under the curve when in area mode
    • 'bar' - a histogram bar
    • 'selection' - a selection line point
    • 'scale' - the time axis scale
    • 'histo' - the histogram area between the sliders
    • 'left', 'right' - sliders
    • 'slider' - the areas outside the current slider range
    • 'controlbar' - the control bar at the bottom of the time bar
    • 'fit', 'previous', 'next', 'play', 'playextend', 'zoomin', 'zoomout' - control bar controls
    • null - if there is nothing under the pointer

    number
    The value of either the bar or selection, or null for other click types.
    number
    The x location of the pointer in view coordinates.
    number
    The y location of the pointer in view coordinates.

    The context-menu event fires on a right click or long press for touch devices.

    Default action: Suppresses the click event.

    number
    The index of the button used.
    boolean
    If the default action was prevented.
    number
    Index of clicked group within bar.
    number[]
    Value of each group within bar.
    number
    The index of the selection clicked on, or null for other click types.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.
    number
    The unique identifier of the pointer.
    string
    The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
    function
    Call to prevent the event's default action.
    Date
    The upper bound of the time at the pointer.
    Date
    The lower bound of the time at the pointer.
    number
    A suggested location for the tooltip in the x direction - the centre of the bar or selection point.
    number
    A suggested location for the tooltip in the y direction - the height of the bar or selection point.
    TimeBarItemId

    The type of clicked item:

    • 'area' - the area under the curve when in area mode
    • 'bar' - a histogram bar
    • 'selection' - a selection line point
    • 'scale' - the time axis scale
    • 'histo' - the histogram area between the sliders
    • 'left', 'right' - sliders
    • 'slider' - the areas outside the current slider range
    • 'controlbar' - the control bar at the bottom of the time bar
    • 'fit', 'previous', 'next', 'play', 'playextend', 'zoomin', 'zoomout' - control bar controls
    • null - if there is nothing under the pointer

    number
    The value of either the bar or selection, or null for other click types.
    number
    The x location of the pointer in view coordinates.
    number
    The y location of the pointer in view coordinates.

    The double-click event fires on a double click or double tap.

    Default action: Zooms in and centres at the clicked time (animated).

    number
    The index of the button used.
    boolean
    If the default action was prevented.
    number
    Index of clicked group within bar.
    number[]
    Value of each group within bar.
    number
    The index of the selection clicked on, or null for other click types.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.
    number
    The unique identifier of the pointer.
    string
    The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
    function
    Call to prevent the event's default action.
    Date
    The upper bound of the time at the pointer.
    Date
    The lower bound of the time at the pointer.
    number
    A suggested location for the tooltip in the x direction - the centre of the bar or selection point.
    number
    A suggested location for the tooltip in the y direction - the height of the bar or selection point.
    TimeBarItemId

    The type of clicked item:

    • 'area' - the area under the curve when in area mode
    • 'bar' - a histogram bar
    • 'selection' - a selection line point
    • 'scale' - the time axis scale
    • 'histo' - the histogram area between the sliders
    • 'left', 'right' - sliders
    • 'slider' - the areas outside the current slider range
    • 'controlbar' - the control bar at the bottom of the time bar
    • 'fit', 'previous', 'next', 'play', 'playextend', 'zoomin', 'zoomout' - control bar controls
    • null - if there is nothing under the pointer

    number
    The value of either the bar or selection, or null for other click types.
    number
    The x location of the pointer in view coordinates.
    number
    The y location of the pointer in view coordinates.

    The drag-end event fires when the drag is finished and the pointer released, or when the drag is cancelled. On touch devices this fires when the finger or input device is lifted from surface.

    Default action:

    • On the background: Accepts the final panned range of the time bar.
    • On the slider: Accepts the final range of the time bar and zooms to fit the view.
    number
    The index of the button used.
    boolean
    If the default action was prevented.
    number
    Index of clicked group within bar.
    number[]
    Value of each group within bar.
    number
    The index of the selection clicked on, or null for other click types.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.
    number
    The unique identifier of the pointer.
    string
    The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
    function
    Call to prevent the event's default action.
    Date
    The upper bound of the time at the pointer.
    Date
    The lower bound of the time at the pointer.
    number
    A suggested location for the tooltip in the x direction - the centre of the bar or selection point.
    number
    A suggested location for the tooltip in the y direction - the height of the bar or selection point.
    TimeBarItemId

    The type of dragged item:

    • 'area' - the area under the curve when in area mode
    • 'bar' - a histogram bar
    • 'selection' - a selection line point
    • 'scale' - the time axis scale
    • 'histo' - the histogram area between the sliders
    • 'left', 'right' - sliders
    • 'slider' - the areas outside the current slider range
    • 'controlbar' - the control bar at the bottom of the time bar
    • 'fit', 'previous', 'next', 'play', 'playextend', 'zoomin', 'zoomout' - control bar controls
    • null - if there is nothing under the pointer

    number
    The value of either the bar or selection, or null for other click types.
    number
    The x location of the pointer in view coordinates.
    number
    The y location of the pointer in view coordinates.

    The drag-start event fires when a drag is started.

    Default action:

    • On the background: Starts a pan controlled by the pointer.
    • On the slider: Starts dragging the slider.
    number
    The index of the button used.
    boolean
    If the default action was prevented.
    number
    Index of clicked group within bar.
    number[]
    Value of each group within bar.
    number
    The index of the selection clicked on, or null for other click types.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.
    number
    The unique identifier of the pointer.
    string
    The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
    function
    Call to prevent the event's default action.
    Date
    The upper bound of the time at the pointer.
    Date
    The lower bound of the time at the pointer.
    number
    A suggested location for the tooltip in the x direction - the centre of the bar or selection point.
    number
    A suggested location for the tooltip in the y direction - the height of the bar or selection point.
    TimeBarItemId

    The type of dragged item:

    • 'area' - the area under the curve when in area mode
    • 'bar' - a histogram bar
    • 'selection' - a selection line point
    • 'scale' - the time axis scale
    • 'histo' - the histogram area between the sliders
    • 'left', 'right' - sliders
    • 'slider' - the areas outside the current slider range
    • 'controlbar' - the control bar at the bottom of the time bar
    • 'fit', 'previous', 'next', 'play', 'playextend', 'zoomin', 'zoomout' - control bar controls
    • null - if there is nothing under the pointer

    number
    The value of either the bar or selection, or null for other click types.
    number
    The x location of the pointer in view coordinates.
    number
    The y location of the pointer in view coordinates.

    The end event fires when the end data point is reached.

    Default action: None

    "data" | "range"

    The type of end reached:

    • 'range' - left slider reaching the right-most data point
    • 'data' - right slider reaching the right-most data point

    The hover event fires when the cursor hovers over an item. The event only fires once when the type of the hover target changes.

    Default action: None

    number
    The index of the button used.
    number
    Index of clicked group within bar.
    number[]
    Value of each group within bar.
    number
    The index of the selection clicked on, or null for other click types.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.
    number
    The unique identifier of the pointer.
    string
    The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
    Date
    The upper bound of the time at the pointer.
    Date
    The lower bound of the time at the pointer.
    number
    A suggested location for the tooltip in the x direction - the centre of the bar or selection point.
    number
    A suggested location for the tooltip in the y direction - the height of the bar or selection point.
    TimeBarItemId

    The type of hovered item:

    • 'area' - the area under the curve when in area mode
    • 'bar' - a histogram bar
    • 'selection' - a selection line point
    • 'scale' - the time axis scale
    • 'histo' - the histogram area between the sliders
    • 'left', 'right' - sliders
    • 'slider' - the areas outside the current slider range
    • 'controlbar' - the control bar at the bottom of the time bar
    • 'fit', 'previous', 'next', 'play', 'playextend', 'zoomin', 'zoomout' - control bar controls
    • null - if there is nothing under the pointer

    number
    The value of either the bar or selection, or null for other click types.
    number
    The x location of the pointer in view coordinates.
    number
    The y location of the pointer in view coordinates.

    The key-down event fires when the user presses a key.

    Default actions:

    • Space key: Toggles Play/Pause buttons
    boolean
    If the default action was prevented.
    number
    The keyCode of the key pressed.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.
    function
    Call to prevent the event's default action.

    The key-up event fires when the user releases a key.

    Default action: None

    number
    The keyCode of the key pressed.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.

    The pause event fires when the time bar is paused.

    The event also fires when pausing the time bar programmatically.

    Default action: None

    The play event fires when the time bar starts to play.

    The event also fires when playing the time bar programmatically.

    Default action: None

    "normal" | "extend"
    The type of play mode.

    The pointer-down event fires when a pointer presses down on the surface.

    Default action: None

    number
    The index of the button used.
    number
    Index of clicked group within bar.
    number[]
    Value of each group within bar.
    number
    The index of the selection clicked on, or null for other click types.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.
    number
    The unique identifier of the pointer.
    string
    The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
    Date
    The upper bound of the time at the pointer.
    Date
    The lower bound of the time at the pointer.
    number
    A suggested location for the tooltip in the x direction - the centre of the bar or selection point.
    number
    A suggested location for the tooltip in the y direction - the height of the bar or selection point.
    TimeBarItemId

    The type of item under the pointer:

    • 'area' - the area under the curve when in area mode
    • 'bar' - a histogram bar
    • 'selection' - a selection line point
    • 'scale' - the time axis scale
    • 'histo' - the histogram area between the sliders
    • 'left', 'right' - sliders
    • 'slider' - the areas outside the current slider range
    • 'controlbar' - the control bar at the bottom of the time bar
    • 'fit', 'previous', 'next', 'play', 'playextend', 'zoomin', 'zoomout' - control bar controls
    • null - if there is nothing under the pointer

    number
    The value of either the bar or selection, or null for other click types.
    number
    The x location of the pointer in view coordinates.
    number
    The y location of the pointer in view coordinates.

    The pointer-move event fires continuously as the pointer moves on the surface.

    Default action: None

    number
    The index of the button used.
    number
    Index of clicked group within bar.
    number[]
    Value of each group within bar.
    number
    The index of the selection clicked on, or null for other click types.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.
    number
    The unique identifier of the pointer.
    string
    The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
    Date
    The upper bound of the time at the pointer.
    Date
    The lower bound of the time at the pointer.
    number
    A suggested location for the tooltip in the x direction - the centre of the bar or selection point.
    number
    A suggested location for the tooltip in the y direction - the height of the bar or selection point.
    TimeBarItemId

    The type of item under the pointer:

    • 'area' - the area under the curve when in area mode
    • 'bar' - a histogram bar
    • 'selection' - a selection line point
    • 'scale' - the time axis scale
    • 'histo' - the histogram area between the sliders
    • 'left', 'right' - sliders
    • 'slider' - the areas outside the current slider range
    • 'controlbar' - the control bar at the bottom of the time bar
    • 'fit', 'previous', 'next', 'play', 'playextend', 'zoomin', 'zoomout' - control bar controls
    • null - if there is nothing under the pointer

    number
    The value of either the bar or selection, or null for other click types.
    number
    The x location of the pointer in view coordinates.
    number
    The y location of the pointer in view coordinates.

    The pointer-up event fires when the pointer is released.

    Default action: None

    number
    The index of the button used.
    number
    Index of clicked group within bar.
    number[]
    Value of each group within bar.
    number
    The index of the selection clicked on, or null for other click types.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.
    number
    The unique identifier of the pointer.
    string
    The type of pointing device as returned by the browser. The standard values are 'mouse', 'touch' and 'pen'.
    Date
    The upper bound of the time at the pointer.
    Date
    The lower bound of the time at the pointer.
    number
    A suggested location for the tooltip in the x direction - the centre of the bar or selection point.
    number
    A suggested location for the tooltip in the y direction - the height of the bar or selection point.
    TimeBarItemId

    The type of item under the pointer:

    • 'area' - the area under the curve when in area mode
    • 'bar' - a histogram bar
    • 'selection' - a selection line point
    • 'scale' - the time axis scale
    • 'histo' - the histogram area between the sliders
    • 'left', 'right' - sliders
    • 'slider' - the areas outside the current slider range
    • 'controlbar' - the control bar at the bottom of the time bar
    • 'fit', 'previous', 'next', 'play', 'playextend', 'zoomin', 'zoomout' - control bar controls
    • null - if there is nothing under the pointer

    number
    The value of either the bar or selection, or null for other click types.
    number
    The x location of the pointer in view coordinates.
    number
    The y location of the pointer in view coordinates.

    The start event fires when the starting data point is reached.

    Default action: None

    "data" | "range"

    The type of start reached:

    • 'range' - left slider reaching the left-most data point
    • 'data' - right slider reaching the left-most data point

    The wheel event fires continuously while the user is rotating a mouse wheel or scrolling using a trackpad.

    Default actions:

    • On the surface: Zooms in or out (animated)
    boolean
    If the default action was prevented.
    number

    The unit of measurement for delta value:

    • 0: Pixels
    • 1: Lines
    • 2: Pages
    number
    The number of units that the wheel scrolled in the x direction.
    number
    The number of units that the wheel scrolled in the y direction.
    object
    A dictionary detailing which modifier keys were pressed when the event occurred.
    function
    Call to prevent the event's default action.
    number
    The x location of the pointer in view coordinates.
    number
    The y location of the pointer in view coordinates.

    Time Bar Options

    These are the options you can pass to the first argument of timebar.options().

    For an example of how these options work, see Customise the Time Bar.

    TimeBarAreaOptions
    Options controlling the time bar when type is set to 'area'.
    string(Colour)
    default: 'rgba(32, 32, 200, 0.67)'
    The colour of the time bar area border line. The fill area will be a translucent version of this colour.
    string(Colour)
    default: 'white'
    The colour to use for the background of the time bar.
    number
    default: 250
    The minimum interval between change events in milliseconds.
    "light" | "dark"
    default: 'light'
    The colour theme of the time bar's control bar.
    string(Colour)
    default: 'grey'
    The colour to set the font of the time bar (used in the scales).
    string
    default: 'sans-serif'
    The default font family to use, for example, 'sans-serif'.
    number
    default: 12
    The font size to use. There is no size limit, but most fonts look best with a value between 7 and 13.
    TimeBarDataGroups
    Options controlling the grouping within histogram bars.
    (string | number)[] | null
    default: null
    Values of the custom property that the time bar should accept. Items with other values will be placed in an uncategorised group. Set to null to disable bar groups.
    string(Colour)[] | null
    default: null
    Colours to use for bar groups, or null to use a set of default colours.
    string | null
    default: null
    The custom property that defines item grouping, or null to disable bar groups.
    string(Colour)[] | null
    default: null
    Colours to use for bar groups when highlighted, or null to calculate highlight colours based on the bar group colours.
    HeightChange
    Options controlling the animation of height changes for stacked histogram bars and selection lines.
    boolean
    default: true
    Whether height changes should be animated.
    number
    default: 200
    If animated, the time the animation should take, in milliseconds.
    Histogram
    Options for the histogram bars.
    string(Colour)
    default: 'light grey'
    The colour of the histogram bars.
    string(Colour)
    default: 'grey'
    The colour of the histogram bars when they are hovered over.
    string(Colour)
    default: light red
    The colour of histogram bars which contain marked times.
    string(Colour)
    default: 'red'
    The colour of the marked histogram bars when they are hovered over.
    Locale
    Specifies how dates and times are displayed.
    string[]
    default: ['AM', 'PM']
    An array of two strings giving the text for AM and PM for 12-hour clock times and 2 more optional strings, used to label time bar intervals for the first and second halves of days.
    boolean
    default: true
    Whether a 12-hour clock should be used to display times. If false, a 24-hour clock is used.
    string
    default: 'H'
    A prefix used to indicate halves of years.
    string[]
    default: ['January', etc]
    An array of strings giving the full names of the months, starting with January.
    "dmy" | "mdy"
    default: 'mdy'

    A string controlling the order of dates:

    • 'dmy' - day-month-year
    • 'mdy' - month-day-year
    string
    default: 'Q'
    A prefix used to indicate quarters of years.
    string[]
    default: ['Jan', etc]
    An array of strings giving abbreviated names of the months, starting with January.
    string | MaxRange
    default: 'auto'
    Specifies the time range at the time bar's maximum zoom level, for example with a maxRange fixed to { units: 'hour', value: 6 } the time bar will not zoom out beyond six-hour intervals. This is useful if your dataset spans a large time range and you want to limit the amount of data visible. By default, KeyLines calculates the range between the data's earliest and latest dates/times and multiplies it by two.
    "year" | "month" | "week" | "day" | "hour" | "min" | "sec"
    The unit of the maximum range.
    number
    The size of the maximum range, in the units specified.
    MinScale
    Specifies the time interval at the time bar's minimum scale level, for example with a minScale fixed to { units: 'hour', value: 6 } the time bar will not zoom in beyond six-hour intervals. This can be useful when the data has no precise information about the hour or the minute of the event to stop zooming further. The default behaviour scales with the range of the data.
    "year" | "month" | "week" | "day" | "hour" | "min" | "sec"
    default: 'sec'
    The unit of the minimum scale level.
    number
    default: 1
    The number of the specified units.
    number
    default: 60
    The speed that the time bar moves at when playing, in pixels per second. May be negative to animate backwards in time in 'normal' mode, or to animate the right hand slider moving backwards in time in 'extend' mode.
    Scale
    Options for the minor and major time scales.
    string(Colour)
    default: 'light grey'
    The colour of the time scale section that is hovered over.
    boolean
    default: true
    Whether the major time scale (the lower scale) is shown.
    boolean
    default: true
    Whether the minor time scale (the higher scale) is shown.
    boolean
    default: true
    Whether the control bar at the base of the time bar is shown.
    boolean
    default: false
    Whether the extend button is displayed.
    boolean
    default: true
    Whether the fit button is displayed.
    boolean
    default: true
    Whether the play button is displayed.
    string(Colour)
    default: 'white', 0.6 opacity
    The colour of the the slider.
    string(Colour)
    default: 'grey'
    The colour of the bars at the inner edge of the slider.
    "fixed" | "none" | "free"
    default: 'fixed'
    Sets the slider behaviour. If set to 'fixed', the slider width is fixed to 25% of the view area and the slider animates back to this width after each drag and drop. If set to 'free', sliders can be dragged and dropped freely. Setting to 'none' hides the sliders. Setting this option changes the visual effects when timebar.range() is called.
    "area" | "histogram"
    default: 'histogram'
    Whether the time bar should display as a series of rectangular histogram bars or as a smooth area plot.