Chart

The Chart component draws nodes, links and annotations passed in through the items property. When new or updated data is passed in, it will redraw with an animation to reflect the new state.

import { Chart } from 'regraph';

<Chart
  items={{
    node1: { color: 'red' },
    node2: { color: 'red' },
    link:  { id1: 'node1', id2: 'node2' },
    annotation: { subject: 'node1' }
  }}
/>

You can control the state, appearance and behavior of the chart by setting the props below. The chart also supports standard element props - including id, className, and interaction events (e.g. onClick).

Chart Props

  • animation object

    Controls animations on the chart.

    • animate booleandefault:true

      Animates transitions between chart states. Set to false during drag events to ensure they complete before associated animations start.

    • time numberdefault:250

      The total duration in milliseconds in which animations should run. This time is shared between all animations on a particular update.

  • annotationPositions object
    Beta

    A dictionary containing angle/distance for each annotation.

    • [annotationid] object

      An object representing an annotation's position relative to its subjects.

      • angle string | numberdefault:'n'

        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).

      • distance numberdefault:20

        Distance between the annotation and its subject(s) in view coordinates.

  • className string

    If the chart receives a className, it will not apply any default styles. We recommend styling the chart's parent element, rather than passing a className to the chart itself.

  • combine object

    Specifies how nodes should be grouped into combos. Defines a hierarchy of properties on the data object to combine by, and specifies how deeply nodes should be combined within this hierarchy.

    Setting the combine property to a new object will cause the onCombineNodes and onCombineLinks event handlers to be called, allowing you to update the styles of all combos and summary links.

    <Chart
      combine={{
        // Combine items first by City, then by State, then by Country
        properties: ['City', 'State', 'Country'],
        // Combine items only one level deep, i.e. just by City
        level: 1
      }}
    />
    
    • level number

      The combo nesting level. A value of 0 means no nodes will be combined, 1 combines nodes using the first property in the properties array, 2 combines by the first and then the second properties in the array, and so on. If level is not specified then ReGraph uses all properties in the properties array.

    • properties array of strings

      The hierarchy of properties which are used to control combos. These properties come from the data property of nodes. Nodes with matching property values are combined into a single combo that represents the property value itself. The first property in the array is the deepest/innermost combo, and the last is the outermost combo.

    • shape 'rectangle' | 'circle'default:'circle'

      The shape of combos.

  • items object

    A dictionary of nodes, links and annotations, where each property is an item id and each value is the definition of that item.

    • [id] Node | Link | Annotation

      An object describing a node, link or an annotation.

  • layout object

    The currently active layout, used to position any nodes without an entry in the positions object. Setting this will run a layout and may cause node positions to change.

    • level string

      The name of the custom property on the node's or combo node's data property that defines which level the node/combo belongs to in the radial or sequential layout. The property must contain a numeric value, where the lowest number is the center or top respectively.

      If both level and top are specified, level is used.

      • 'radial' must have either level or top specified.
      • 'sequential' assigns levels automatically if neither are specified.
    • linkShape 'angled' | 'curved' | 'direct'default:'direct'

      The default shape for the path taken by links. The direction of 'curved' and 'angled' links is inferred from orientation. Can be overridden using linkShape for open combos or linkShape for individual links. See the Link Shapes documentation.

      'angled' links are in beta from v5.1.

    • name 'organic' | 'sequential' | 'structural' | 'radial' | 'lens' | 'standard' | 'tweak'default:'organic'

      The layout name to apply. 'Standard' and 'tweak' layouts are deprecated since 4.0.

    • orderBy 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.

      • property string

        The key of the custom data value on the node's data property that orders the items within the same level in sequential layout. When specified, items are ordered alphanumerically and in the descending order unless sortBy is also set.

      • sortBy 'ascending' | 'descending'default:'descending'

        The direction of ordered items.

    • orientation 'left' | 'right' | 'up' | 'down'default:'down'

      The orientation of sequential layouts.

    • packing 'rectangle' | 'circle' | 'aligned'default:'circle' | 'aligned'

      The packing mode to arrange subgraphs. Not used by 'lens'. The 'aligned' packing is only available for sequential and it's the default option for this layout.

    • stacking object

      The positioning of nodes that share the same neighbors and level in the sequential layout. If property is set in orderBy, stacking only applies to nodes also sharing the same property value.

      • arrange 'grid' | 'none'default:'none'

        If set to 'grid', four or more same-level nodes with identical connections are stacked in a grid.

    • stretch numberdefault:1

      The spacing between levels in sequential layout. Values must be positive.

    • stretchType '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 optimize use of space and get more even distribution of levels.

    • tightness numberdefault:5

      The spacing between nodes, with higher values making nodes closer. Ranges from 0-10.

    • top string | array of strings

      A node id or an array of ids that should be at the top of a sequential layout or in the center of a radial layout. Components without top specified are unchanged during the layout but can be arranged by packing.

      If both level and top are specified, top is ignored.

      • 'radial' must have either level or top specified.
      • 'sequential' assigns levels automatically if neither are specified.
  • map booleandefault:false

    Set to true to display a Leaflet map. Note that Leaflet must be available in the global scope.

  • options object

    Specifies options on the Chart. See Chart Options.

  • positions object

    A dictionary containing positions for each node and combo in the chart. Passing an empty object runs a new layout and returns new positions via the onChange handler. For organic layout, passing positions manually fixes these nodes in the chart even when a layout is run.

    • [nodeid] object

      An object representing a node or combo's position in world coordinates.

      • x number

        The x location of the node or combo.

      • y number

        The y location of the node or combo.

  • selection object

    A dictionary with a truthy property for each selected item.

    • [id] boolean

      Indicates that an item should be selected by the chart. Note that annotations cannot be selected.

  • style object

    Standard styling properties for the element. We recommend styling the chart's parent element, not the chart itself. Default is:

    {
      position: 'relative',
      height: '100%',
      minHeight: '100px',
      width: '100%',
    }
    
  • view object

    Settings to precisely control the view of the chart (note that all properties must be specified).

    • Chart Mode
      • offsetX number

        The x-offset (horizontal pan).

      • offsetY number

        The y-offset (vertical pan).

      • zoom number

        The zoom level.

    • Map Mode
      • mapCenter array of numbers

        The latitude and longitude of the center point of the map, as an array of the form [lat, long].

      • mapZoom number

        The zoom level of the map.

Chart Events

In 3.0 we deprecated the onChart- events.

Chart events notify you about:

  • Internal state changes - for example, when a layout is run and positions update. These are passed as an object to the onChange prop with details of the change.

  • User interactions - for example, when the user clicks on a node. User event handlers are passed a set of arguments with more information about the event.

If present, calling preventDefault() in an event's handler will prevent the default behavior.

Events generally occur on items (i.e., nodes, links and annotations), but they can can also be triggered against parts of items, or sub-items. See Styling Chart Items for more details about sub-items.

The chart also supports standard element events, including onKeyDown, onFocus etc.

<Chart
  items={{this.state.items}}
  onClick={({id}) => { console.log(`User clicked on ${id}`); }}
/>
  • onChange function

    Invoked whenever the chart triggers a change of state. Typically caused by layouts and user interactions.

    Parameters
    • change object

      An object describing the change.

      • annotationPositions object

        Contains the positions of all annotations in the chart.

      • handMode boolean

        Indicates the current status of the hand mode option.

      • leaflet object

        The underlying Leaflet map object. The property is set to the Leaflet map object when the map is shown. When the map is hidden, the property is set to null.

      • overview boolean

        Indicates the current status of the overview's visible option.

      • positions object

        Contains the positions of all nodes in the chart.

      • selection object

        Indicates which items are currently selected.

      • view object

        The current view settings.

        • Chart Mode
          • offsetX number

            The x-offset (horizontal pan).

          • offsetY number

            The y-offset (vertical pan).

          • zoom number

            The zoom level.

        • Map Mode
          • mapCenter array of numbers

            The latitude and longitude of the center point of the map, as an array of the form [lat, long].

          • mapZoom number

            The zoom level of the map.

      • why 'auto' | 'user'

        Indicates whether the onChange event was triggered by user action or internal ReGraph state.

  • onClick function

    Invoked when the user clicks or taps on the chart surface.

    Default actions depending on the clicked item:

    • Node or link: Selects the item (adds to selection if consistentCtrl is pressed).
    • Background: Deselects all.
    • Navigation controls: Performs the navigation action.
    • Overview icon: Opens or closes the overview window.

    To listen for right click, use the onContextMenu event.

    Parameters
    • props object
      • button number

        The index of the button used.

      • defaultPrevented boolean

        A read-only value indicating if the default action was prevented.

      • id string | null

        The id of the target item.

      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null

        The type of the target item.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • preventDefault function

        Call to prevent the default action of the event.

      • subItem object

        An object containing details of the target sub-item, if applicable. See Sub-item.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onCombineNodes function

    Invoked each time a combo is created or updated. You can adjust the style of the combo by using the setStyle function. You can optionally include a string id property if you wish to use your own identifiers instead of the default. These must be unique.

    <Chart onCombineNodes={
      (comboDefinition) => {
         const { nodes, combo, id, setStyle } = comboDefinition;
         setStyle({
           // insert any styling properties
           open: false,
           label: {
             text: combo.country,
           }
         });
      }
    }/>
    
    Parameters
    • comboDefinition object

      An object describing the combo and its contents.

      • combo object

        An object containing the specific values for the combine properties. For example, properties ['county', 'state'] could result in a combo object { county: ‘Cambridge’, state: ‘Massachusetts’ }.

      • id string

        The default id for this combo. This can be overridden in the combo setStyle function.

      • nodes object

        The nodes belonging to this combo.

      • setStyle function

        Use to specify the style of this combo. See Combo setStyle

  • onContextMenu function

    Invoked on a right click, long press or left click + Ctrl for MacOS.

    Default action: Suppresses the onClick event.

    Parameters
    • props object
      • button number

        The index of the button used.

      • defaultPrevented boolean

        A read-only value indicating if the default action was prevented.

      • id string | null

        The id of the target item.

      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null

        The type of the target item.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • preventDefault function

        Call to prevent the default action of the event.

      • subItem object

        An object containing details of the target sub-item, if applicable. See Sub-item.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onDoubleClick function

    Invoked when the user double-clicks or double-taps on the chart surface.

    Parameters
    • props object
      • button number

        The index of the button used.

      • id string | null

        The id of the target item.

      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null

        The type of the target item.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • subItem object

        An object containing details of the target sub-item, if applicable. See Sub-item.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onDrag function

    Invoked continuously while the cursor moves during a drag.

    Parameters
    • props object
      • button number

        The index of the button used.

      • draggedItems object

        If the type is 'node' or 'annotation', contains the list of items being dragged.

      • id string | null
        The id of the item under the pointer when dragging started.
      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null

        The type of the target item.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • subItem object
        Details of the sub-item under the pointer when dragging started.
      • type 'pan' | 'marquee' | 'create-link' | 'slider' | 'overview' | 'node' | 'map' | 'annotation' | null

        The type of drag.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onDragEnd function

    Invoked when the drag is finished and pointer is released, or when the drag is canceled.

    Default actions depending on the drag type:

    • 'node' or 'link' - Moves selected items to their final positions. Prevent the default action to snap the drag back.
    • 'marquee' - Updates the chart selection.
    • 'pan' or 'overview' - Accepts the final viewport position.
    • 'create-link' - Creates the link.
    Parameters
    • props object
      • button number

        The index of the button used.

      • defaultPrevented boolean

        A read-only value indicating if the default action was prevented.

      • draggedItems object

        If the type is 'node' or 'annotation', contains the list of items being dragged.

      • id string | null
        The id of the item the pointer is released on.
      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null

        The type of the target item.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • preventDefault function

        Call to prevent the default action of the event.

      • subItem object
        Details of the sub-item the pointer is released on.
      • type 'pan' | 'marquee' | 'create-link' | 'slider' | 'overview' | 'node' | 'map' | 'annotation' | null

        The type of drag.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onDragOver function

    Invoked when the cursor dragging a node or an annotation moves over another item during a drag. Switch animation off during drag events to ensure they complete before associated animations start.

    Parameters
    • props object
      • button number

        The index of the button used.

      • draggedItems object
        The list of items being dragged.
      • id string | null
        The id of the item underneath the dragged item, or null if over the background.
      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null
        The type of the item underneath the dragged item, or null if over the background.
      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • subItem object
        The details of the sub-item underneath the dragged item.
      • type 'node' | 'annotation'
        The type of item dragged by the cursor.
      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onDragStart function

    Invoked when a drag is started. Switch animation off during drag events to ensure they complete before associated animations start.

    Default action: Creates a dragger. Prevent the default action to disable dragging.

    Parameters
    • props object
      • button number

        The index of the button used.

      • defaultPrevented boolean

        A read-only value indicating if the default action was prevented.

      • draggedItems object

        If the type is 'node' or 'annotation', contains the list of items being dragged.

      • id string | null
        The id of the item under the pointer when dragging started.
      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null

        The type of the target item.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • preventDefault function

        Call to prevent the default action of the event.

      • setDragOptions function

        Call to set options for the drag. See setDragOptions.

      • subItem object
        Details of the sub-item under the pointer when dragging started.
      • type 'pan' | 'marquee' | 'slider' | 'overview' | 'node' | 'map' | 'annotation' | null

        The type of drag.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onHover function

    Invoked when the user hovers over an item for a specified time. You can modify the delay in the hoverDelay Chart option. Only invoked when the hover id changes. To apply custom styling when an item is hovered over, consider using onItemInteraction.

    Parameters
    • props object
      • button number

        The index of the button used.

      • id string | null

        The id of the target item.

      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null

        The type of the target item.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • subItem object

        An object containing details of the target sub-item, if applicable. See Sub-item.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onItemInteraction function

    Invoked each time an item or sub-item is hovered over or selected. Use hoverDelay to modify the event delay.

    If an item is styled by both onItemInteraction and the selection prop in chart options, the selection styling takes precedence. Set selection: false to override this.

    The interaction styling set by the event's setStyle function only affects the properties/sub-properties specified and it is cleared once the user interaction is over.

    onItemInteraction={({ id, setStyle, hovered }) => {
      if (hovered) {                        // when hovered by the user
        setStyle({
          [id]: {
            color: '#17BA99',               // node color changes
            label: [
              { text: 'hovered label 1' },  // label 1 text changes
              {},                           // label 2 does not change
              { text: 'hovered label 3' },
            ],
          },
        });
    }}}/>
    
    Parameters
    • props object
      • aggregate object

        Information about the target aggregate link.

      • combo object

        Lists the combine properties of the target combo.

      • hovered boolean

        True if the target is being hovered over.

      • id string

        The id of the target item.

      • The target item.

      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null

        The type of the target item.

      • nodes object

        Lists the nodes inside the target combo.

      • selected boolean

        True if the target is selected.

      • signal object

        An event signal that can be aborted by an AbortController to cancel the styling.

      • subItem object

        Details of the sub-item interacted with. See Sub-item.

      • subjects object

        Lists the subjects of the target annotation.

      • setStyle function

        Sets the interaction style of chart items specified by the function. See Data Formats for all item styles.
        Setting fade to false in this function automatically backgrounds every other chart item that doesn't have fade set to false.
        When styling node labels, the format of label specified in setStyle must follow the same format as the unstyled label.

        Parameters
        • items object

          A dictionary of items.

          • [id] Node | Link

            An object with node or link properties to be applied.

        Returns
        void
  • onLinkAggregation function

    Invoked each time an aggregate link is created, deleted or updated. The update occurs when a child link is added or removed, a child link's arrow changes, or when the custom property in data object used for aggregating links is changed. To style an aggregate link, call setStyle with an object with style information.

    The onLinkAggregation event is in beta from v4.4.

    <Chart onLinkAggregation={
      (aggregateLinkDefinition) => {
         const { links, id1, id2, id, aggregateByValue, change, setStyle } = aggregateLinkDefinition;
         setStyle({
           // insert any styling properties
           width: Math.sqrt(Object.keys(links).length)
         });
      }
    }/>
    
    Parameters
    • aggregateLinkDefinition object

      An object describing the aggregate link and its contents.

      • aggregateByDirection 'none' | 'both' | 'from' | 'to' | undefined

        The arrow direction of the child links, when aggregateByDirection: true. Otherwise is undefined.

      • aggregateByValue string

        The value of the property being used to group links into aggregate links. This is undefined when aggregateLinks prop is set to true.

      • change 'created' | 'updated' | 'deleted'

        Describes the change occuring to the aggregate link.

      • id string

        The id of this aggregate link.

      • id1 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.

      • id2 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.

      • setStyle function

        Specifies the style to be used for this aggregate link. See Aggregate link setStyle.

  • onPointerDown function

    Invoked when the pointer presses down on the chart surface.

    Parameters
    • props object
      • button number

        The index of the button used.

      • id string | null

        The id of the target item.

      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null

        The type of the target item.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • subItem object

        An object containing details of the target sub-item, if applicable. See Sub-item.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onPointerMove function

    Invoked continuously while the pointer moves on the chart surface.

    Parameters
    • props object
      • button number

        The index of the button used.

      • id string | null

        The id of the target item.

      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null

        The type of the target item.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • subItem object

        An object containing details of the target sub-item, if applicable. See Sub-item.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onPointerUp function

    Invoked when the pointer is released.

    Parameters
    • props object
      • button number

        The index of the button used.

      • id string | null

        The id of the target item.

      • itemType 'node' | 'link' | 'annotation' | 'combo' | 'summaryLink' | 'aggregateLink' | null

        The type of the target item.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • subItem object

        An object containing details of the target sub-item, if applicable. See Sub-item.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onUpdateComplete function

    Invoked each time the chart has finished updating.

  • onViewChange function

    Invoked continuously when the chart view changes, e.g. during zooming or panning.

    Parameters
    • props object
      • Chart Mode
        • offsetX number

          The x-offset (horizontal pan).

        • offsetY number

          The y-offset (vertical pan).

        • zoom number

          The zoom level.

      • Map Mode
        • mapCenter array of numbers

          The latitude and longitude of the center point of the map, as an array of the form [lat, long].

        • mapZoom number

          The zoom level of the map.

  • onWheel function

    Invoked continuously while the user is rotating a mouse wheel or scrolling using a trackpad.

    Default action: Animated zoom in or out.

    Parameters
    • props object
      • defaultPrevented boolean

        A read-only value indicating if the default action was prevented.

      • deltaMode number

        The unit of measurement for the delta value.

      • deltaX number

        The number of units that the wheel scrolled in the x direction.

      • deltaY number

        The number of units that the wheel scrolled in the y direction.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • preventDefault function

        Call to prevent the default action of the event.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

Chart Options

You can set various options and defaults on the chart itself by setting the options prop.

<Chart
  options={{
    backgroundColor: 'rgb(60, 60, 60)',
    iconFontFamily: 'Font Awesome 5 Free',
    overview: {
      visible: false
    },
    navigation: {
      position: 'se'
    }
  }}
/>

The options prop accepts an object with the following format:

  • backgroundColor stringdefault:'white'

    The color to use for the background of the chart itself.

  • backgroundGradient array

    Set to give the chart a linear background gradient. The gradient runs from top to bottom of the chart. To create a gradient you must define an array of at least two color/stop objects.

    <Chart options={{
      backgroundGradient: [
        { color: 'yellow', stop: 0 },
        { color: 'red', stop: 1 },
      ],
    }}/>
    
    • color string

      The color for the specified location.

    • stop number

      The point at which the background color is set. A value of 0.4 would mean that the background takes on the specified color at 40% of the chart's height (the top of the chart is at 0%). If there are colors on either side of this stop, then the background color will transition linearly from/to these colors. We recommend using values between 0 and 1.

  • combo object

    Options to control combo behavior.

    • autoSelectionStyle booleandefault:true

      When true, provides default combo selection behavior. Nodes and links that are selected and within combos or summary links, or connected to a combo, are brought into the foreground of the chart along with any neighbors they have. This includes showing the contents of summary links. Other items in the chart are faded. If chart items have fade set explicitly these items will not be altered.

  • controlColor string

    The color to use for the navigation and overview window control. Only the hue and saturation values of the color are used: the lightness is fixed.

  • controlTheme 'light' | 'dark'default:'light'

    The color theme of the navigation and overview window controls.

  • dragPan booleandefault:true

    If true, drag operations will pan the chart automatically if the mouse or touch position moves near the edge of or outside the chart area. If false, the chart will not pan if the mouse or touch position moves near the edge of the chart area during a drag operation, and the drag will be canceled if the mouse moves outside the chart area.

  • fadeOpacity numberdefault:0.2

    The opacity level of faded items. In the range 0 to 1, where 0 is totally transparent.

  • fit string or objectdefault:'auto'

    Controls how the chart view should respond to changes. Note that these behaviors do not take effect if the view prop is set. Valid values are:

    • 'all' - Fits all items to the viewport at the end of an update.
    • 'auto' - Automatically adjusts the view during the update. This setting shows changes without disrupting their context.
    • 'none' - Does not adjust the view during the update. Note that layouts may still adjust node positions relative to the chart.
    • 'selection' - Fits the currently selected items to the viewport at the end of an update.
    • object - Fits the specified items to the viewport at the end of an update. Accepts a dictionary whose properties are valid chart items. Defaults to 'auto' if no valid items are passed.
  • handMode booleandefault:true

    If true, dragging the chart background drags all items. If false, dragging the chart background draws a bounding box for selecting items.

  • hoverDelay numberdefault:150

    The number of milliseconds delay before the onItemInteraction and onHover events are triggered.

  • iconFontFamily stringdefault:'sans-serif'

    The default font family to use for font icons, such as 'FontAwesome' or 'Octicon'. If the font isn't supported by the browser, or if none is set, 'sans-serif' is used.

  • imageAlignment object

    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.

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

    <Chart options={{
      imageAlignment: {
        'fas fa-user': { size: 2 },
        '/assets/img/logo.png': { size: 1.5 }
      }
    }}/>
    
    • [pathOrName] object

      A dictionary where the id is the image path or icon name, and the value contains the following properties:

      • dx numberdefault:0

        Sets how far to move the icon horizontally. The value is a percentage from -50 to 50.

      • dy numberdefault:0

        Sets how far to move the icon vertically. The value is a percentage from -50 to 50.

      • size numberdefault:0

        The factor by which you want to resize the icon relative to its parent. Must be greater than 0.

  • labels object

    Options to control the appearance of labels on items.

    • fontFamily stringdefault:'sans-serif'

      The default font family to use, such as 'arial' or 'helvetica'. If the font isn't supported by the browser, or if none is set, 'sans-serif' is used.

    • legacyGlyphAndLabelOrdering booleandefault:false

      If set to true, labels are drawn over glyphs. If false, glyphs are drawn over labels.

    • maxLength number

      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 ....

    • offset 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).

    • showOnHover booleandefault:true

      If true, hovering over a node or a link reveals the full length of all their truncated labels.

  • map object

    Specifies options for the Leaflet map.

    <Chart options={{
      map: {
        tiles: 'http://example.com/path/{z}/{x}/{y}.png'
      }
    }}/>
    
    • leaflet object

      Pass options directly into the Leaflet constructor. See the Leaflet API for more details.

    • tiles string | object

      An option to set the url template for map tiles. Accepts either a string in the form of http://example.com/path/{z}/{x}/{y}.png, or an object in the Leaflet TileLayer options format with an additional url property. 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.

  • maxItemZoom numberdefault:4

    Sets the maximum zoom for items, from minZoom to 4. We suggest a value of around 1 to have an optimal result.

  • minZoom numberdefault: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.

  • navigation object | boolean

    An object whose properties are the settings for the navigation controls. For brevity, you can pass a value of false to hide the navigation controls.

    • position 'ne' | 'se' | 'sw' | 'nw'default:'nw'

      The position of the navigation controls.

    • visible booleandefault:true

      Whether the navigation controls are displayed.

    • x numberdefault:0

      The horizontal offset in pixels from the navigation controls' default position.

    • y numberdefault:0

      The vertical offset in pixels from the navigation controls' default position.

  • overview object | boolean

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

    • backgroundColor stringdefault:value of chart backgroundColor

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

    • borderColor stringdefault:'light grey'

      The border color of the overview window.

    • position 'ne' | 'se' | 'sw' | 'nw'default:'se'

      The position of the overview window.

    • showIcon booleandefault:true

      Whether the icon the user can click on to open/close the overview is shown.

    • size numberdefault:100

      The size of the overview window in pixels.

    • visible booleandefault:false

      If set to true, the overview window is fully expanded. If false, the overview window is collapsed into an icon.

  • selection object | boolean

    Options to control the appearance of selected items. Set to false or an empty object to disable selection styles.

    • color stringdefault:'rgb(255, 109, 102)'

      Sets the color of the selection indicator for items. Adds colored halos to nodes, colored selection markers to the middle of links and changes background color of node and link labels. When setting color for node that has an array of node labels, the node label background color only changes for labels that don't have a set backgroundColor property.

    • labelColor stringdefault:'white'

      Sets the font color of any labels on the selected item. When setting labelColor for node that has an array of node labels, the node label font color only changes for labels that don't have a set color property.

  • watermark object

    An object whose properties are the settings for the watermark in the center of the chart.

    • align 'center' | 'top' | 'bottom'default:'center'

      The vertical alignment of the watermark text.

    • image string

      Sets the watermark image as a URL.

    • label WatermarkLabel

      Sets a text label on the watermark.

Chart Instance Methods

Use ref to call methods on an instance of a chart. For more information on how to do this, see the Chart Instance Methods documentation.

To create and use a ref, you could use:

function MyComponent({ items }) {
  const chartRef = React.useRef(null);

  const pinger = () => {
    chartRef.current.ping('node1');
  };

  return (
      <>
        <Chart ref={chartRef} items={items} />
        <button onClick={pinger}>
          Ping Node 1
        </button>
      </>
  );
}
  • export (options)

    Exports a static image of the Chart. The exported image is encoded in a blob URL.

    Parameters
    • options object

      Options for the exported image.

      • doc object | PDFDocument

        Options to customize the PDFDocument by passing any PDFKit options, or to pass your own PDFDocument.

        • layout 'portrait' | 'landscape'default:'portrait'

          The page orientation.

        • margin numberdefault:72

          A single value in DPI for all page edge margins. Overrides the margins option.

        • margins object

          The margins in DPI for individual page edges. The form is an object with top, bottom, left, and right values where all values must be provided.

        • size stringdefault:'letter'

          The size of the page.

      • extents 'chart' | 'view'default:'view'

        Specifies whether the exported result contains only the current view or the full chart.

      • fitTo object | 'page'

        Scales the result to fit to the specified size while keeping the aspect ratio. For PDF this can also be set to 'page' to fit and fill the page space. Browsers set varying limits on max size, and will error if exceeded. Note that this option is not supported on a Leaflet map.

        • height numberdefault:The current Chart height

          The height of the exported image. May be reduced to maintain the aspect ratio.

        • width numberdefault:The current Chart width

          The width of the exported image. May be reduced to maintain the aspect ratio.

      • fonts object

        A dictionary to manually define font resources, indexed by font names. Only required when automatic font loading fails, giving a 'Font not found' warning.

        fonts: {
          'Font Awesome 5 Free Regular': {
             src: '../fonts/fontAwesome5/fa-regular-400.woff'
          },
          Muli: {
             src: '../fonts/Muli/Muli-Regular.ttf'
          }
        }
        
        • src string

          URL or base64 encoding of the .woff or .ttf font file for this style.

        • weight 'bold' | 'regular'

          Optional parameter for PDF export to specify the weight of the font encoded by this font file.

      • heading string

        The heading to be shown above the chart image in the exported PDF. This option is ignored when a custom PDFKit doc is passed.

      • type 'jpeg' | 'png' | 'svg'| 'pdf'default:'png'

        The file format to export to.

    Returns
    Promise

    Resolves to an object containing an image data URL and a download function.

    • download function

      A function that downloads the image when called. Cannot be used when a custom PDFKit doc is passed. Create a custom function to download the PDF.

      Parameters
      • name string
        The name of the downloaded file.
      • options object
        • revokeObjectURL booleandefault:true

          Whether the browser should release the reference to the image after the download. Set to false to keep the image accessible.

    • url string

      The url containing the blob url for the exported image.

    • warnings object

      Any array of warnings generated by the export.

      • msg string

        The warning message.

      • type string

        The type of warning.

  • fit (items, options)

    Fit the chart to the items specified.

    Parameters
    • items 'all' | 'selection' | 'height' | array of strings | object

      The items to zoom to. You can either specify a shorthand string like 'all' or a list or dictionary of items to fit to.

    • options object
      • time numberdefault:200

        The time the animation should take, in milliseconds.

    Returns
    void
  • getItemAtViewCoordinates (x, y)

    Returns an object with information about the item or sub-item at the specified view coordinates. This function can be used in integration testing, see Testing Tips for more details. The function is in beta from v4.5.

    Parameters
    • x number

      The x view coordinate to be queried.

    • y number

      The y view coordinate to be queried.

    Returns

    An object with an id property of the parent item, an item property detailing the item, and a subItem property detailing the sub-item.

  • getItemInfo (id)

    Returns an object with information about the item with the specified id. This function can be used in integration testing, see Testing Tips for more details. The function is in beta from v4.5.

    Parameters
    • id string

      The id of the item to query.

    Returns

    An object with an item property detailing the item's base properties and an overwrite property detailing any currently applied interaction styling. If called without arguments, returns a dictionary of items indexed by ids.

  • getViewCoordinatesOfItem (id, subItem)

    Returns an object with the x and y view coordinates which are at the center of the specified item or sub-item. Note there may be multiple items at or under the returned central coordinates. This function can be used in integration testing, see Testing Tips for more details. The function is in beta from v4.5.

    Parameters
    • id string

      The id of the item to query.

    • subItem object

      If applicable, an object describing the sub-item to query.

    Returns
    object

    The view coordinates as an object with x, y properties.

  • image (options) function

    Generates a static image of the current Chart, encoded as a base64 PNG. The navigation controls and overview window are not drawn into the image. Deprecated since v5.0. Use export instead.

    Parameters
    • options object
      • fit 'chart' | 'exact'default:'exact'

        How the view settings are mapped when generating the image. 'chart' fits the whole chart into the image. 'exact' fit uses the same zoom and pan as the component which produces identical image if using the same dimensions as the browser component. This reproduces the view exactly as the user sees it.

        Note that for a Leaflet map, only 'exact' fit is available.

      • height numberdefault:The Chart's current height

        Height of exported image, in pixels.

      • width numberdefault:The Chart's current width

        Width of exported image, in pixels.

    Returns
    Promise

    Returns a Promise which resolves to an image encoded in a data URL.

  • labelPosition (id, index)

    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 end1 or end2 labels on link ends.

    Parameters
    • id string

      The id of the item.

    • index number

      The index of the label in the array of label objects if the item is styled by an array of labels.

    Returns

    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 ReGraph HTML element.

    • fontSize number

      The font size at the current zoom level.

    • x1 number

      The view coordinate of the left edge.

    • x2 number

      The view coordinate of the right edge.

    • y1 number

      The view coordinate of the top edge.

    • y2 number

      The view coordinate of the bottom edge.

  • pan (direction, options)

    Pan the chart in the direction specified.

    Parameters
    • direction 'left' | 'right' | 'up' | 'down'
    • options object
      • time numberdefault:200

        The time the animation should take, in milliseconds.

    Returns
    void
  • ping (id, options)

    Adds a temporary animated halo effect to a node or link.

    Parameters
    • id string or object
      The id (or object of id properties) for the item / items to be animated. For example: ping('node1') or ping({ node1: true })
    • options object
      • color stringdefault:'rgb(255,109,102)'

        The color to use for the animated effect.

      • haloRadius numberdefault:80

        The radius of a halo at the end of its animation.

      • haloWidth numberdefault:40

        The width of a halo at the end of its animation.

      • linkWidth numberdefault:40

        The width of a link at the end of its animation.

      • repeat numberdefault:1

        The number of times the animation should be repeated.

      • time numberdefault:800

        The time the animation should take, in milliseconds.

    Returns
    void
  • viewCoordinates (worldX, worldY)

    Converts world coordinates (absolute positions relative to the center of the chart) into view coordinates (relative to the top-left of the viewport) and is dependent on the current view (zoom and pan). On a Leaflet map, the passed world coordinates should represent longitude (worldX) and latitude (worldY).

    Parameters
    • worldX number
    • worldY number
    Returns
    object

    The view coordinates as an object with x, y properties.

  • worldCoordinates (viewX, viewY)

    Converts view coordinates (relative to the top-left of the viewport) into world coordinates (absolute positions relative to the center of the chart).

    Parameters
    • viewX number
    • viewY number
    Returns
    object

    The world coordinates as an object with x, y properties. On a Leaflet map, will return lng, lat properties instead.

  • zoom (direction, options)

    Zoom the chart in the manner specified.

    Parameters
    • direction 'in' | 'out'
    • options object
      • time numberdefault:200

        The time the animation should take, in milliseconds.

    Returns
    void

Time Bar

The time bar shows items with date stamps in a histogram, showing volumes of activity over time.

Like the chart, it is populated by passing data into the items prop.

Time Bar Props

  • animation object

    Controls animations on the Time Bar.

    • animate booleandefault:true

      If true, animates changes.

    • time numberdefault:250

      The total duration in milliseconds in which animations should run.

  • className string

    If the Time Bar receives a className, it will not apply any default styles. We recommend styling the Time Bar's parent element, rather than passing a className to the Time Bar itself.

  • highlight array of objects

    Highlights a time or range of times in the Time Bar using the color defined in the highlightColor option.

    <TimeBar
      highlight={[
        new Date(),
        {
          start: Date.now() + 1000 * 60 * 60,
          end: Date.now() + 3 * 1000 * 60 * 60
        }
      ]}
    />
    
    • end number | Date

      The end of the range.

    • start number | Date

      The start of the range.

  • items object

    An indexed list of all the items in the Time Bar. Each item must have a times property. See the Item data format.

    • [id] Node | Link

      An object describing a node or link.

  • mode 'smooth' | 'histogram'default:'histogram'

    Sets the display mode of the Time Bar to show histogram bars, or a smooth line with shaded area.

  • options object

    Specifies options on the Time Bar. See Time Bar Options.

  • play booleandefault:false

    Indicates whether the Time Bar is playing.

  • range object

    Specifies the visible range of the Time Bar.

    • end number | Date

      The end of the range.

    • start number | Date

      The start of the range.

  • selection object | array of objects

    Draws a selection line for items with truthy values in the supplied object, or multiple lines if multiple objects are supplied in an array. The maximum number of selection lines is 3.

    <TimeBar
      items={items}
      selection={[{ node1: true }, { node2: true }]}
    />
    
    • [id] boolean

      A truthy value indicates that an item should be included in the selection line.

  • selectionColor string | array of stringsdefault:'sunset red', 'dark green' and 'orange'

    Indicates the colors to use for any selection lines drawn.

    <TimeBar
      items={items}
      selection={[{ node1: true }, { node2: true }]}
      selectionColor={["blue", "red"]}
    />
    
  • style object

    Standard styling properties for the element. We recommend styling the Time Bar's parent element, not the Time Bar itself. Default is:

    {
      position: 'relative',
      height: '100%',
      minHeight: '100px',
      width: '100%',
    }
    

Time Bar Events

In 3.0 we deprecated the onTimeBar- events.

  • onChange onChangeHandler

    Invoked whenever the range of the Time Bar changes. Returns a list of items in the updated range.

    Parameters
    • change object

      An object describing the change.

      • items object

        Shows which items are currently in the visible range.

      • play boolean

        Indicates if the play state has changed.

      • range object

        The current visible time-range, always returned as Date objects in the end user's time zone.

        • end number | Date

          The end of the range.

        • start number | Date

          The start of the range.

  • onClick function

    Invoked when the user clicks or taps on the time bar surface.

    Parameters
    • props object
      • button number

        The index of the button used.

      • end Date

        The date at the end of the clicked range.

      • index number

        The index of the clicked selection point, or null for other click types.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • stackIndex number

        Index of clicked stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • stackValues array of numbers

        Values of each stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • start Date

        The date at the start of the clicked range.

      • tooltipX number

        A suggested location for the tooltip in the x direction - the center of the bar or selection point.

      • tooltipY number

        A suggested location for the tooltip in the y direction - the height of the bar or selection point.

      • type 'bar' | 'area' | 'selection' | 'scale' | 'left' | 'right' | 'slider' | null

        The type of clicked item.

      • value number

        The value of either the bar or selection.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onContextMenu function

    Invoked on a right click, long press or left click + Ctrl for MacOS.

    Default action: Suppresses the onClick event.

    Parameters
    • props object
      • button number

        The index of the button used.

      • defaultPrevented boolean

        A read-only value indicating if the default action was prevented.

      • end Date

        The date at the end of the clicked range.

      • index number

        The index of the clicked selection point, or null for other click types.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • preventDefault function

        Call to prevent the default action of the event.

      • stackIndex number

        Index of clicked stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • stackValues array of numbers

        Values of each stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • start Date

        The date at the start of the clicked range.

      • tooltipX number

        A suggested location for the tooltip in the x direction - the center of the bar or selection point.

      • tooltipY number

        A suggested location for the tooltip in the y direction - the height of the bar or selection point.

      • type 'bar' | 'area' | 'selection' | 'scale' | 'left' | 'right' | 'slider' | null

        The type of clicked item.

      • value number

        The value of either the bar or selection.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onDoubleClick function

    Invoked when the user double-clicks or double-taps on the time bar surface.

    Default action: Animated zoom in that centres at the clicked time.

    Parameters
    • props object
      • button number

        The index of the button used.

      • defaultPrevented boolean

        A read-only value indicating if the default action was prevented.

      • end Date

        The date at the end of the clicked range.

      • index number

        The index of the clicked selection point, or null for other click types.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • preventDefault function

        Call to prevent the default action of the event.

      • stackIndex number

        Index of clicked stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • stackValues array of numbers

        Values of each stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • start Date

        The date at the start of the clicked range.

      • tooltipX number

        A suggested location for the tooltip in the x direction - the center of the bar or selection point.

      • tooltipY number

        A suggested location for the tooltip in the y direction - the height of the bar or selection point.

      • type 'bar' | 'area' | 'selection' | 'scale' | 'left' | 'right' | 'slider' | null

        The type of clicked item.

      • value number

        The value of either the bar or selection.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onDragEnd function

    Invoked when the drag is finished and pointer is released, or when the drag is canceled.

    Default actions depending on drag type:

    • 'slider' - Accepts the final panned range of the time bar and zooms to fit the view.
    • other types - Accepts the final panned range of the time bar. Prevent the default action to snap the pan back.
    Parameters
    • props object
      • button number

        The index of the button used.

      • defaultPrevented boolean

        A read-only value indicating if the default action was prevented.

      • end Date

        The date at the end of the clicked range.

      • index number

        The index of the clicked selection point, or null for other click types.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • preventDefault function

        Call to prevent the default action of the event.

      • stackIndex number

        Index of clicked stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • stackValues array of numbers

        Values of each stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • start Date

        The date at the start of the clicked range.

      • tooltipX number

        A suggested location for the tooltip in the x direction - the center of the bar or selection point.

      • tooltipY number

        A suggested location for the tooltip in the y direction - the height of the bar or selection point.

      • type 'bar' | 'area' | 'selection' | 'scale' | 'left' | 'right' | 'slider' | null

        The type of clicked item.

      • value number

        The value of either the bar or selection.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onDragStart function

    Invoked when a drag is started.

    Default actions depending on drag type:

    • 'slider' - Starts dragging the slider.
    • other types - Starts a pan controlled by the pointer. Prevent the default action to disable panning.
    Parameters
    • props object
      • button number

        The index of the button used.

      • defaultPrevented boolean

        A read-only value indicating if the default action was prevented.

      • end Date

        The date at the end of the clicked range.

      • index number

        The index of the clicked selection point, or null for other click types.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • preventDefault function

        Call to prevent the default action of the event.

      • stackIndex number

        Index of clicked stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • stackValues array of numbers

        Values of each stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • start Date

        The date at the start of the clicked range.

      • tooltipX number

        A suggested location for the tooltip in the x direction - the center of the bar or selection point.

      • tooltipY number

        A suggested location for the tooltip in the y direction - the height of the bar or selection point.

      • type 'bar' | 'area' | 'selection' | 'scale' | 'left' | 'right' | 'slider' | null

        The type of clicked item.

      • value number

        The value of either the bar or selection.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onHover function

    Invoked when the user hovers over an item. Only invoked whenever the hover id changes.

    Parameters
    • props object
      • button number

        The index of the button used.

      • end Date

        The date at the end of the clicked range.

      • index number

        The index of the clicked selection point, or null for other click types.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • stackIndex number

        Index of clicked stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • stackValues array of numbers

        Values of each stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • start Date

        The date at the start of the clicked range.

      • tooltipX number

        A suggested location for the tooltip in the x direction - the center of the bar or selection point.

      • tooltipY number

        A suggested location for the tooltip in the y direction - the height of the bar or selection point.

      • type 'bar' | 'area' | 'selection' | 'scale' | 'left' | 'right' | 'slider' | null

        The type of clicked item.

      • value number

        The value of either the bar or selection.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onPointerDown function

    Invoked when the pointer presses down on the time bar surface.

    Parameters
    • props object
      • button number

        The index of the button used.

      • end Date

        The date at the end of the clicked range.

      • index number

        The index of the clicked selection point, or null for other click types.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • stackIndex number

        Index of clicked stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • stackValues array of numbers

        Values of each stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • start Date

        The date at the start of the clicked range.

      • tooltipX number

        A suggested location for the tooltip in the x direction - the center of the bar or selection point.

      • tooltipY number

        A suggested location for the tooltip in the y direction - the height of the bar or selection point.

      • type 'bar' | 'area' | 'selection' | 'scale' | 'left' | 'right' | 'slider' | null

        The type of clicked item.

      • value number

        The value of either the bar or selection.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onPointerMove function

    Invoked continuously while the pointer moves on the time bar surface.

    Parameters
    • props object
      • button number

        The index of the button used.

      • end Date

        The date at the end of the clicked range.

      • index number

        The index of the clicked selection point, or null for other click types.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • stackIndex number

        Index of clicked stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • stackValues array of numbers

        Values of each stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • start Date

        The date at the start of the clicked range.

      • tooltipX number

        A suggested location for the tooltip in the x direction - the center of the bar or selection point.

      • tooltipY number

        A suggested location for the tooltip in the y direction - the height of the bar or selection point.

      • type 'bar' | 'area' | 'selection' | 'scale' | 'left' | 'right' | 'slider' | null

        The type of clicked item.

      • value number

        The value of either the bar or selection.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onPointerUp function

    Invoked when the pointer is released.

    Parameters
    • props object
      • button number

        The index of the button used.

      • end Date

        The date at the end of the clicked range.

      • index number

        The index of the clicked selection point, or null for other click types.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • pointerId number

        The unique identifier of the pointer.

      • pointerType string

        The type of pointing device.

      • stackIndex number

        Index of clicked stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • stackValues array of numbers

        Values of each stack in the bar. Undefined if type parameter is not 'bar' or the bar is highlighted.

      • start Date

        The date at the start of the clicked range.

      • tooltipX number

        A suggested location for the tooltip in the x direction - the center of the bar or selection point.

      • tooltipY number

        A suggested location for the tooltip in the y direction - the height of the bar or selection point.

      • type 'bar' | 'area' | 'selection' | 'scale' | 'left' | 'right' | 'slider' | null

        The type of clicked item.

      • value number

        The value of either the bar or selection.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

  • onWheel function

    Invoked continuously while the user is rotating a mouse wheel or scrolling using a trackpad.

    Default action: Animated zoom in or out.

    Parameters
    • props object
      • defaultPrevented boolean

        A read-only value indicating if the default action was prevented.

      • deltaMode number

        The unit of measurement for the delta value.

      • deltaX number

        The number of units that the wheel scrolled in the x direction.

      • deltaY number

        The number of units that the wheel scrolled in the y direction.

      • modifierKeys object

        A dictionary detailing which modifier keys were pressed when the event occurred. See Modifier Keys.

      • preventDefault function

        Call to prevent the default action of the event.

      • x number

        The x location of the pointer in view coordinates.

      • y number

        The y location of the pointer in view coordinates.

Time Bar Options

You can set various options and defaults on the time bar by setting the options prop.

<TimeBar
  options={{
    backgroundColor: 'rgb(60, 60, 60)',
    style: {
      color: 'blue',
      hoverColor: 'red'
    }
  }}
/>

The options prop accepts an object with the following format:

  • backgroundColor stringdefault:'white'

    The color to set the background of the Time Bar.

  • changeEventThrottling numberdefault:250

    The minimum interval between onChange events in milliseconds.

  • heightChange object

    Options controlling animation of height changes for histogram bars and selection lines.

    • animate booleandefault:true

      If true, animates changes.

    • time numberdefault:250

      The total duration in milliseconds in which animations should run.

  • labels object

    Options to control the appearance of labels on the Time Bar (used in the scales).

    • color stringdefault:'gray'

      The color to set the font of the Time Bar.

    • fontFamily stringdefault:'sans-serif'

      The default font family to use, such as 'arial' or 'helvetica'. If the font isn't supported by the browser, or if none is set, 'sans-serif' is used.

    • fontSize numberdefault:12

      The font size to use. There is no size limit, but most fonts look better if you use a value between 7 and 13.

  • locale object

    Specifies how dates and times are displayed.

    • ampm array of stringsdefault:['AM', 'PM']

      An array of two strings giving the text to use for AM and PM when displaying 12-hour clock times. Optionally this array may contain two more strings, which are used to label Time Bar intervals representing the first and second halves of days.

    • h12 booleandefault:true

      A flag indicating whether the 12-hour clock should be used to display times. If false, the 24-hour clock is used.

    • half stringdefault:'H'

      A prefix used to indicate halves of years.

    • longMonths array of stringsdefault:['January', etc]

      An array of strings giving the full names of the months, starting with January.

    • order stringdefault:'mdy'

      A string controlling the order of dates. Supported values are 'dmy' for day-month-year, and 'mdy' for month-day-year.

    • quarter stringdefault:'Q'

      A prefix used to indicate quarters of years.

    • shortMonths array of stringsdefault:['Jan', 'Feb', ...etc]

      An array of strings giving abbreviated names of the months, starting with January.

  • playSpeed numberdefault:60

    The speed that the Time Bar moves at when playing, in pixels per second. May be negative to animate backwards.

  • scale object

    Options for the minor and major time scales.

    • hoverColor stringdefault:'light gray'

      The color of the time scale section that is hovered over.

    • showMajor booleandefault:true

      Whether the major time scale (the lower scale) is shown.

    • showMinor booleandefault:true

      Whether the minor time scale (the higher scale) is shown.

  • sliders object

    Options to control the appearance of the sliders to the left and right of the histogram bars.

    • color string

      The color to set the sliders. The default is white with an opacity of 0.6.

    • lineColor stringdefault:'gray'

      The color to set the bars at the inner edge of the sliders.

    • type 'none' | 'fixed' | 'free'default:'fixed'

      Specifies slider behavior after a drag. Set to 'none' to hide the sliders.

  • stack object

    Specifies how to create stacked bars.

    • by string

      Splits histogram stacks by this value on an item's data property. Items which don't have a matching property will be grouped into an 'other' stack.

      const items = {
          a: { times: [Date.now()], data: { country: 'us' } },
          b: { times: [Date.now()], data: { country: 'uk' } },
        };
        const stackOpts = { stack: { by: 'country' }};
        return <TimeBar items={items} options={stackOpts} />
      
    • styles Index

      A dictionary of styles, where each property corresponds to a value for the by property, and its value contains a definition of the styles to be applied to it.

      Stacks are stacked vertically upwards following the order of the styles defined in this object. The default time bar styling is used for the 'other' stack, containing items with no matching by value.

      const items = {
         a: { times: [Date.now()], data: { country: 'us' } },
         b: { times: [Date.now()], data: { country: 'uk' } },
        };
        const stackOpts = {
          stack: {
            by: 'country',
            styles: {
              us: { color: 'maroon', hoverColor: 'red' } },
              uk: { color: 'navy', hoverColor: 'blue' } },
            }
          }
        };
        return <TimeBar items={items} options={stackOpts} />
      
  • style object

    Controls the appearance of histogram bars and smooth areas.

    • color stringdefault:'light gray'

      The color of the histogram bars or smooth area line.

    • highlightColor stringdefault:'light red'

      The color of histogram bars which contain highlighted times. Only available in histogram mode.

    • highlightHoverColor stringdefault:'red'

      The color of the highlighted histogram bars when they are hovered over. Only available in histogram mode.

    • hoverColor stringdefault:'gray'

      The color of the histogram bars when they are hovered over. Only available in histogram mode.

  • zoom object

    Specifies the bounds within which the user can zoom.

    • max ZoomExtent

      Sets the maximum zoom level (i.e., the smallest scale that the Time Bar will zoom in to). Note that this sets the smallest allowed scale, although the smallest scale actually realized may be larger.

    • min ZoomExtent

      Sets the minimum zoom level (i.e., the largest scale that the Time Bar will zoom out to). Note that this value should be larger than that set in the max object, and if left unset, ReGraph calculates the range between the data's earliest and latest times and multiplies it by two.

Time Bar Instance Methods

  • fit (items, options)

    Fit the time bar to the items specified.

    Parameters
    • items 'all' | array of strings | object
    • options object
      • time numberdefault:200

        The time the animation should take, in milliseconds.

    Returns
    void
  • pan (direction, options)

    Pan the time bar in the direction specified.

    Parameters
    • direction 'forward' | 'backward'
    • options object
      • time numberdefault:200

        The time the animation should take, in milliseconds.

    Returns
    void
  • zoom (direction, options)

    Zoom the time bar in the manner specified.

    Parameters
    • direction 'in' | 'out'
    • options object
      • time numberdefault:200

        The time the animation should take, in milliseconds.

    Returns
    void

Data Formats

Nodes, links and annotations in ReGraph are described as plain JavaScript objects whose properties configure the appearance of each item. Links also describe their relationship to other nodes.

Nodes, links and annotations are defined on the items prop of the chart and time bar components.

The formats below describe the data structures used to define items in the chart.

Item

The following properties are common to nodes, links and annotations.

  • color string

    The fill color. Defaults to gray for nodes and links and rgba(0, 0, 0, 0) for annotations.

  • data object

    Used to store custom data on an item. Used by graph functions, layouts and combos.

  • glyphs Array of Glyphs

    An array of objects describing the glyphs shown on the item.

Node

Nodes, also known as vertices, define a single entity within the graph. Nodes provide various properties to control their appearance.

A node can be a combo, which means it is a parent or container for other nodes. Combos can be in an open or closed state. Closed combos look just like regular nodes, but open combos only support the border, color and label properties.

In addition to all Item properties, nodes support the following properties:

  • border objectdefault:No border

    Defines a border around a node. Set a color property to make a border appear.

    <Chart items={{
        node1: {
          border: {
             color: 'maroon'
          }
        }
      }}
    />
    
    • color string

      The border color.

    • lineStyle 'solid' | 'dashed'default:'solid'

      The style of the border line.

    • radius number | string | number[] | objectdefault:0

      The radius of border corners. Use a number for equal radius for all corners, a string (separated by spaces) containing two, three or four numbers, an array (separated by commas) containing two, three or four numbers, or an object setting values for individual properties such as topLeft or bottomRight.

    • width numberdefault:4

      The width of the border.

  • coordinates object

    An object describing the position of the node on the Leaflet map.

    • lat number

      The latitude in degrees that this node is positioned at when a map is shown.

    • lng number

      The longitude in degrees that this node is positioned at when a map is shown.

  • cutout booleandefault:false

    Crops an image to a cutout circle. Affected by cross-origin restrictions and does not apply to font icons.

  • donut object

    An object describing a 'donut' border of segmented sections around the node. Doesn't apply to nodes with shape set to 'box'. If both donut and border are set then donut takes precedence.

    • border object

      Defines the border between segments.

      • color stringdefault:'white'

        The border color.

      • width numberdefault:2

        The width of the border.

    • segments array

      Defines the segments of the donut.

      • color string

        The color of this segment.

      • size number

        The size of this segment. Values should be positive. Segments are positioned clockwise around the node starting at the top.

    • width numberdefault:10

      The width of the donut segments (excluding the border).

  • fade booleandefault:false

    Fades the item into the background. Can be used in the setStyle function passed to onItemInteraction to foreground items.

  • fontIcon object
    The font icon to use on the node. Use imageAlignment for positioning and scaling.
    <Chart items={{
       node1: {
         fontIcon: {
           text: 'fas fa-user', // or '\u{f007}'
           fontFamily: 'Font Awesome 5 Free',
         },
       },
       node2: {
         fontIcon: {
           text: 'person',
           fontFamily: 'Material Icons',
         },
       },
     }}
    />
    
    • color stringdefault:'black'

      The color of the font icon fill.

    • fontFamily string

      The font family to use for the font icon. Defaults to the iconFontFamily option in the chart's options prop.

    • text string | number

      The text of the font icon to show. You can pass a CSS class name here which will be converted to a unicode character, or you can pass an escaped Unicode code point, e.g. '\u{f007}'.

  • halos Array of objects

    Adds halos to the node. Halos are concentric circles which are drawn around nodes. A node can have up to ten halos.

    • color string

      The color of the halo.

    • radius number

      The radius of the halo.

    • width number

      The width of the halo.

  • image string

    The URL to the node image. Unavailable images are shown as a blue X. If requesting images directly from external domains, see Cross-Origin Images.

  • label object | array of objects

    Defines one or more labels for a node as described in Node Label. Labels can be styled using Advanced Node Styling which is in beta from v4.0.

  • shape 'box' | 'circle' | objectdefault:'circle'

    The node's shape. Can also be set to an object with parameters in world units to set a rectangular node.

    • height number | 'auto'

      The height of a rectangular node. Set to 'auto' to automatically size the height to contain all the inside labels.

    • minHeight numberdefault:54

      An optional parameter to set the minimum height of a rectangular node. If height is set to 'auto' and the content is smaller than the minimum height, the minimum height is applied.

    • minWidth numberdefault:54

      An optional parameter to set the minimum width of a rectangular node. If width is set to 'auto' and the content is smaller than the minimum width, the minimum width is applied.

    • width number | 'auto'

      The width of a rectangular node. Set to 'auto' to automatically size the width to contain all the inside labels.

  • size numberdefault:1

    Scales the node size by an enlargement factor. Does not apply to nodes with width and height set in the shape property.

  • times Array

    Associates timestamps with the item. A timestamp can represent a single moment or a period of time.

    <TimeBar items={{
        node1: {
          times: [{ time: new Date(2019, 4, 1) }],
        },
        node2: {
          times: [
            {
              time: {
                start: 1554713715658,
                end: 1558624743356,
              },
            },
          ],
        },
      }}
    />
    
    • time object | Date | number

      Set the time as a specific moment as a Date or a time in milliseconds. To specify a time interval, set the time as an object with start and end. If only start or end is provided, the interval is treated as an open interval.

      • end number | Date

        The timestamp for the end of the time period, either a Date object or a millisecond number.

      • start number | Date

        The timestamp for the start of the time period, either a Date object or a millisecond number.

    • value numberdefault:1

      The value associated with a timestamp (for example, the amount of a transaction or the duration of a call).

Node Label

Labels show information on nodes. Each node can have one or more labels associated with it.

Beta The label property accepts either a single object or an array of one or more objects, each of which defines one label. Labels can be styled using Advanced Node Styling which is in beta from v4.0, and support the following properties:

  • backgroundColor stringdefault:'rgba(255,255,255,0.6)'

    The label background color. Ignored if image is set.

  • bold booleandefault:false

    Whether the label should be displayed in bold font.

  • border objectdefault:No border

    The border around the label.

    • color string

      The border color.

    • radius number | string | number[] | objectdefault:0

      The radius of border corners. Use a number for equal radius for all corners, a string (separated by spaces) containing two, three or four numbers, an array (separated by commas) containing two, three or four numbers, or an object setting values for individual properties such as topLeft or bottomRight.

    • width numberdefault:4

      The width of the border.

  • color stringdefault:'black'

    The color of the label font.

  • fontFamily string

    The font family to use for the label. Defaults to the fontFamily property of the labels options in the chart's options prop.

  • fontIcon object

    The label font icon. Use position and margin for positioning and offset and fontSize for scaling. If text is also set, only fontIcon is shown. If image is also set, fontIcon is ignored.

  • fontSize number | 'auto'default:14

    The font size (px) of the label. Set to 'auto' to size the font automatically depending on the node size. Ignored if image is set.

  • image string

    The URL to the label image. To specify image size, set both maxHeight and maxWidth. To set its position and offset within the node, use position and margin. Also supports border but other label customization properties are ignored.

  • margin number | string | number[] | object

    The space between the label and the next label or the parent node. Use a number for equal margin on all sides, a string (separated by spaces) containing two, three or four numbers, an array (separated by commas) containing two, three or four numbers, or an object setting values for individual properties such as top or right.

  • maxHeight numberdefault:54 for images

    The height of the label container. For non-image labels, use this when fontSize is set to 'auto' to set the maximum height of the text. For image labels, if maxWidth is also set, specifies the height of the image.

  • maxWidth numberdefault:54 for images

    The width of the label container, defaulting to that of the parent node. For non-image labels, set this option when textWrap is set to 'normal' to reduce the maximum text width before a line break, or when fontSize is set to 'auto' to set the maximum text width. For image labels, if maxHeight is also set, specifies the width of the image.

  • minHeight number | 'stretch'

    The minimum height of the label container. It will increase to fit the content if necessary. When set to 'stretch', it fills the whole height of the parent node. Ignored if image is set.

  • minWidth number | 'stretch'

    The minimum width of the label container. It will increase to fit the content if necessary. When set to 'stretch', it fills the whole width of the parent node. Set to a number if textWrap is set to 'normal' to increase the minimum text width before a line break. Ignored if image is set.

  • padding number | string | number[] | objectdefault:'2 2 0 2'

    The space between the label border and the content inside the label. Use a number for equal padding on all sides, a string (separated by spaces) containing two, three or four numbers, an array (separated by commas) containing two, three or four numbers, or an object setting values for individual properties such as top or right. Ignored if image is set.

  • position string | objectdefault:{ horizontal: 'center', vertical: 'middle' }

    The position of the label's top left corner relative to the top left node corner. Can either be a compass point string ( 'n', 'ne' etc.) to place the label outside the node, or an object with horizontal and/or vertical properties to place the label inside the node.

    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.

    • horizontal number | 'left' | 'center' | 'right'

      The horizontal position. Can be a predefined string or a number in world coordinates.

    • vertical number | 'top' | 'middle' | 'bottom' | 'initial' | 'inherit'

      The vertical position. Can be a predefined string or a number in world coordinates.

  • text string

    The label text. If either fontIcon or image is set, text is ignored.

  • textAlignment objectdefault:{ horizontal: 'center', vertical: 'middle' }

    The alignment of the content inside the label. Applies when labels are not sized automatically to their content due to minHeight and/or minWidth options set. Ignored if image is set.

    • horizontal 'left' | 'center' | 'right'

      The horizontal alignment.

    • vertical 'top' | 'middle' | 'bottom'

      The vertical alignment.

  • textWrap 'normal' | 'initial'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.

Annotation Beta

Annotations are notes connected to items in the chart. You can annotate nodes, links and open and closed combos.

Annotations are drawn in their own layer on top of the chart and positioned relatively to their subjects. When a layout is run or when their subjects move, annotations keep their position relative to their subjects. See also Annotations documentation for more details.

In addition to all Item properties, annotations support the following properties:

  • border object

    The border around the annotation.

    • color stringdefault:'rgb(230, 230, 230)'

      The border color.

    • lineStyle 'solid' | 'dashed'default:'solid'

      The style of the border line.

    • radius number | string | number[] | objectdefault:3

      The radius of border corners. Use a number for equal radius for all corners, a string (separated by spaces) containing two, three or four numbers, an array (separated by commas) containing two, three or four numbers, or an object setting values for individual properties such as topLeft or bottomRight.

    • width numberdefault:1

      The width of the border.

  • connectorStyle object

    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.
    • color stringdefault:'rgb(0, 0, 0)'

      The color of the line(s) and of the container.

    • container 'rectangle' | 'circle' | 'none'default:'none'

      Whether there is a container surrounding the subject(s):

      • 'none' - No container. This is the only option available for link annotations.
      • 'circle' - Draws a circle around the subject node(s) or combo(s).
      • 'rectangle' - Draws a rectangle around the subject node(s) or combo(s).
    • lineStyle 'solid' | 'dashed'default:'solid'

      The style of the connector line(s) and subject container(s).

    • subjectEnd 'none' | 'arrow' | 'dot'default:'dot'

      The decoration shown at the subject end of the connector line.

    • width numberdefault: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.

  • label object | array of objects

    Defines one or more annotation labels as described in Annotation Label. Annotation label supports the same properties as Node Label and can be styled using Advanced Node Styling which is in beta from v4.0.

  • shape object

    The annotation's dimensions in view units. Annotations are always rectangular.

    • height number | 'auto'

      The height of the annotation. When set to 'auto', the annotation automatically sizes to fit any content inside. When setting dimensions, both height and width must be set.

    • minHeight number

      The minimum height of the annotation.

    • minWidth number

      The minimum width of the annotation.

    • width number | 'auto'

      The width of the annotation. When set to 'auto', the annotation automatically sizes to fit any content inside. When setting dimensions, both width and height must be set.

  • subject string | array of strings | object

    The id(s) of the item(s) to which the annotation refers. This can be the id, an array of ids, or a dictionary of the ids with truthy values.

    Note that subject cannot be changed by the onItemInteraction event.

Annotation Label Beta

Labels show information on annotations. Each annotation can have one or multiple labels.

The label property accepts either a single object or an array of one or more objects, each of which defines one label.

  • backgroundColor stringdefault:'transparent'

    The label background color.

  • bold booleandefault:false

    Whether the label should be displayed in bold font.

  • border objectdefault:No border

    The border around the label.

    • color string

      The border color.

    • radius number | string | number[] | objectdefault:0

      The radius of border corners. Use a number for equal radius for all corners, a string (separated by spaces) containing two, three or four numbers, an array (separated by commas) containing two, three or four numbers, or an object setting values for individual properties such as topLeft or bottomRight.

    • width numberdefault:4

      The width of the border.

  • color stringdefault:'black'

    The color of the label font.

  • fontFamily string

    The font family to use for the label. Defaults to the fontFamily property of the labels options in the chart's options prop.

  • fontIcon object

    The label font icon. Use position and margin for positioning and offset and fontSize for scaling. If text is also set, only fontIcon is shown. If image is also set, fontIcon is ignored.

  • fontSize number | 'auto'default:14

    The font size (px) of the label. Set to 'auto' to size the font automatically depending on the annotation size.

  • image string

    The URL to the label image. To specify image size, set both maxHeight and maxWidth. To set its position and offset within the node, use position and margin. Also supports border but other label customization properties are ignored.

  • margin number | string | number[] | object

    The space between the label and the next label or the parent annotation. Use a number for equal margin on all sides, a string (separated by spaces) containing two, three or four numbers, an array (separated by commas) containing two, three or four numbers, or an object setting values for individual properties such as top or right.

  • maxHeight number

    The maximum height of the label container. Use this option when fontSize is set to 'auto' to set the maximum height of the text.

  • maxWidth numberdefault:240

    The maximum width of the label container. It defaults to the parent annotation width. Set this option when textWrap is set to 'normal' to reduce the maximum text width before a line break, or when fontSize is set to 'auto' to set the maximum text width.

  • minHeight number | 'stretch'

    The minimum height of the label container. It will increase to fit the content if necessary. When set to 'stretch', it fills the whole height of the parent annotation.

  • minWidth number | 'stretch'

    The minimum width of the label container. It will increase to fit the content if necessary. When set to 'stretch', it fills the whole width of the parent annotation. Set to a number if textWrap is set to 'normal' to increase the minimum text width before a line break.

  • padding number | string | number[] | objectdefault:'10 10 10 10'

    The space between the label border and the content inside the label. Use a number for equal padding on all sides, a string (separated by spaces) containing two, three or four numbers, an array (separated by commas) containing two, three or four numbers, or an object setting values for individual properties such as top or right.

  • position string | objectdefault:{ horizontal: 'center', vertical: 'middle' }

    The position of the label's top left corner relative to the top left annotation corner. Can either be a compass point string ( 'n', 'ne' etc.) to place the label outside the annotation, or an object with horizontal and/or vertical properties to place the label inside the annotation.

    • horizontal number | 'left' | 'center' | 'right'

      The horizontal position. Can be a predefined string or a number in world coordinates.

    • vertical number | 'top' | 'middle' | 'bottom' | 'initial' | 'inherit'

      The vertical position. Can be a predefined string or a number in world coordinates.

  • text string

    The label text. If both text and fontIcon are set, text is ignored.

  • textAlignment objectdefault:{ horizontal: 'left', vertical: 'top' }

    The alignment of the content inside the label. Applies when labels are not sized automatically to their content due to minHeight and/or minWidth options set.

    • horizontal 'left' | 'center' | 'right'

      The horizontal alignment.

    • vertical 'top' | 'middle' | 'bottom'

      The vertical alignment.

  • textWrap '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.

Glyph

Glyphs are circular decorations or badges which can be applied to items. They can be used to report information about an item, or to allow user interaction.

A glyph can be a simple colored 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 priority order, from highest to lowest:

  1. text (both glyph fill color and label are set)
  2. image (image)
  3. font icon (fontIcon)
  4. colored circle (only glyph fill color is set)

On nodes, annotations and combos, glyphs are drawn along the border at either a compass position or an integer angle from 0-359. On links, glyphs are drawn next to labels at the link center or at link ends.

See Styling Items for more details about glyphs.

Glyphs have the following properties:

  • angle number

    The glyph position relative to the node or combo. Values are integer angles measured clockwise from north (in the range 0-359). Multiple glyphs on the same node or combo must be positioned using the same positioning property (either angle or position).

  • border objectdefault:No border

    Applies a border to the glyph. Borders on image glyphs without a glyph background are not supported.

    • color string

      The border color.

    • width numberdefault:2

      The width of the border.

  • color stringdefault:'rgb(60,60,60)'

    The glyph fill color. 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.

  • fontIcon object
    The font icon to use on the glyph. Use imageAlignment for positioning and scaling.
  • image string

    The URL of the image to use for the glyph. The image can be any size, but 64X64 should be adequate.

  • label object

    Specifies the label of the glyph. If a label is specified and a glyph fill color is set, the a label take precedence over images and font icons on the same object.

    • backgroundColor stringdefault:'rgba(255,255,255,0.6)'

      The label background color.

    • bold booleandefault:false

      Whether the label should be displayed in bold font.

    • color stringdefault:'white'

      The color of the label font.

    • fontFamily string

      The font family to use for the label. Defaults to the fontFamily property of the labels options in the chart's options prop.

    • text string

      The glyph label text.

  • position 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw'default:'ne'

    The position of the glyph relative to the node or combo. Values are compass points. Multiple glyphs on the same node or combo must be positioned using the same positioning property (either angle or position).

  • radius number

    Sets the distance from the center of the node or closed combo at which the glyph is drawn. Only available when the glyph's angle is defined. If specified, link ends will no longer avoid the glyph.

  • size numberdefault:1

    Sets an enlargement factor on the glyph.

Sub-item

Sub-items are item decorations (such as node labels or link glyphs) or item parts (such as annotation container or connection). See Sub-items docs for more details.

When a user interacts with a sub-item, the details are reported on the subItem argument of the event handler.

  • index number

    When the type of sub-item is 'label', 'glyph', 'donut' or 'halo', specifies which label, glyph, donut segment or halo in the array to access. Note that the 'index' is not required when there is only one 'label' sub-item.

    function onClick({id, x, y, button, subItem}) {
      if (subItem && subItem.type === 'glyph') {
         console.log(subItem.index); // 0 for first glyph, 1 for second, etc
       }
    }
    
  • linkEnd 'end1' | 'end2'

    The end of the link the sub-item is attached to. Only set if the type is 'arrowhead', 'glyph' or 'label'.

  • subjects object

    The subjects of the annotation the sub-item is a part of. Only set if the type is 'container' or 'connection'.

  • type 'label' | 'donut' | 'container' | 'arrowhead' | 'glyph' | 'halo' | 'connection'

    The type of the sub-item:

    • 'donut', 'halo' - node decorations
    • 'label', 'glyph' - node, link and annotation decoration
    • 'arrowhead' - arrows on link ends
    • 'container' - the container surrounding annotation subjects
    • 'connection' - the line and subject end of the annotation connector

Modifier Keys

A dictionary detailing which modifier keys were pressed when the event occurred.

  • alt boolean

    If an alt key was held down when the event occurred.

  • consistentCtrl boolean

    If a consistent control key (ctrl key, cmd key on MacOS) was held down when the event occurred.

  • ctrl boolean

    If a control key was held down when the event occurred.

  • meta boolean

    If the meta key was held down when the event occurred.

  • shift boolean

    If a shift key was held down when the event occurred.

Combo setStyle

Closed combo styling supports all Node properties.
Open combo styling supports:

  • border, color and label Node properties
  • data, fade and glyphs Item properties

Some of the properties for open combos may have different defaults as described below.

The setStyle function also accepts the following properties:

  • arrange string | object

    Sets the arrangement of items inside an open combo. Accepts a string with the arrangement name or an object to also set additional options.

    • gridShape 'auto' | objectdefault:'auto'

      If name is set to 'grid', this can be set to an object in the form of { rows: number } or { columns: number } to set the row/column dimension of the grid.

    • level string

      The name of the custom property on the node's or combo node's data property that defines which level the node/combo belongs to in the sequential arrangement. The property must contain a numeric value, where the lowest number is the top of the hierarchy. If both the level and top properties are specified, top is ignored.

    • linkShape 'angled' | 'curved' | 'direct'default:'direct'

      The default shape for the path taken by links in the open combo. The direction of 'curved' and 'angled' links is inferred from orientation. Can be overridden using linkShape for individual links. See the Link Shapes documentation.

      Angled links are in beta from v5.1.

    • name 'none' | 'lens' | 'concentric' | 'grid' | 'sequential' | 'auto'default:'lens' | 'grid'

      The arrangement to apply. Circular combos use 'lens' by default, rectangular combos use 'grid' by default.

    • orderBy string | object

      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.

      • property string

        The key of the custom data value on the node's data property that orders the items within the same level in sequential layout. When specified, items are ordered alphanumerically and in the descending order unless sortBy is also set.

      • sortBy 'ascending' | 'descending'default:'descending'

        The direction of ordered items.

    • orientation 'left' | 'right' | 'up' | 'down'default:'down'

      The orientation of the sequential arrangement.

    • packing 'rectangle' | 'circle' | 'aligned'default:'aligned'

      The packing mode to arrange subgraphs in the sequential arrangement.

    • stacking object

      The positioning of nodes that share the same neighbors and level in the sequential arrangement. If property is set in orderBy, stacking only applies to nodes also sharing the same property value.

      • arrange 'grid' | 'none'default:'none'

        If set to 'grid', four or more same-level nodes with identical connections are stacked in a grid.

    • stretch numberdefault:1

      The spacing between levels in the sequential arrangement. Values must be positive.

    • stretchType 'auto' | 'equal'default:'equal'

      The type of spacing between levels in the sequential arrangement. Set to 'auto' if individual levels contain unevenly sized items (nodes or combos) to optimize use of space and get more even distribution of levels.

    • tightness numberdefault:5

      The spacing between items inside open combos, with higher values making nodes closer. Ranges from 0-10.

    • top string | array of strings

      A node id or an array of ids that should be at the top of the sequential arrangement. If both level and top are specified, top is ignored.

  • border object

    Defines a border around the combo. Defaults to a grey border for open combos, and no border for closed combos. See node border.

  • closedStyle object

    Sets the style of the closed combo. All Node properties are supported.

    <Chart onCombineNodes={({setStyle}) => {
      setStyle({
        // open combo will be white
        color: 'white',
        closedStyle: {
          // closed combo will be blue
          color: 'blue',
        },
      });
    }}/>
    
  • color string

    The fill color. Defaults to rgba(240,240,240,0.8) for open combos, and grey for closed combos.

  • data object

    Used to store custom data on a combo. Used by graph functions and layouts.

  • fade boolean

    Fades the combo into the background. Defaults to false, unless all the children are faded causing the default to be true.

  • glyphs array of Glyphs

    An array of objects describing the glyphs shown on the combo. Glyphs are not inherited between open and closed combos.

  • gridShape 'auto' | objectdefault:'auto'

    If arrange is set to 'grid', this can be set to an object in the form of { rows: number } or { columns: number } to set the row/column dimension of the grid.

    Deprecated since v5.0. Use the gridShape option in the arrange property instead.

  • id string

    Overrides the default id of the combo.

  • label object | array of objects

    Defines one or more labels for a combo; see Node Label for details. Combo labels can be styled using Advanced Node Styling. This in beta from v4.4.

    Closed combos with no label inherit the open style label if the open label is an object. 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.

  • open booleandefault:true

    Opens the combo so that its children are visible.

  • size numberdefault:1

    Scales the closed combo size by an enlargement factor. When the combo is open, only glyphs and labels are scaled.

Summary link setStyle

Sets the style of a summary link. The default style is inherited from the first link it combines, i.e. the first link between the two combos. To change the styling, pass in options as a single object. All Link properties are supported, except for id1 and id2. In addition, you can provide the following properties:

  • contents object | booleandefault:false

    Display the summary link's contents. You can supply a boolean to hide or show all child links, or supply a dictionary with truthy values for each child link you want to display.

  • id string

    Override the default id of the summary link.

  • summary booleandefault:true

    Display the summary link.

Aggregate link setStyle Beta

Sets the style of an aggregate link, which is in beta from v4.4. The default style of an aggregate link is the same as for a regular link, i.e. a gray link with a width of 1.
Aggregate links do not inherit any styling from their child links with the exception of arrowheads. To change the styling of an aggregate link, pass in the styling options as a single object.

All link properties are supported except for id1, id2 and fade. An aggregate link is faded only when all of its children are set to fade.

setDragOptions

Options to control the dragging behavior. Pass in options as a single object.

  • includeCombos boolean

    Set to false to drag child nodes independently of their parent combos.

  • type 'node' | 'pan' | 'marquee'

    The type of drag.

Color

Colors can be specified as a string in several formats:

  • One of the 17 CSS standard named colors, e.g. 'red'
  • Shorthand hexadecimal colors, e.g., '#F00'
  • Hexadecimal colors, e.g., '#FF0000'
  • rgb or rgba formats - i.e., 'rgb(255, 0, 0)' or 'rgba(255, 0, 0, 0.5)'

Graph Functions

ReGraph exposes a number of powerful graph analysis functions to add insight to your data. These functions are in the 'regraph/analysis' package.

The example below shows how to remove singletons (nodes without any neighbors) from your data using the degrees function, which returns the number of neighbors each item has.

import React from 'react';
import { Chart} from 'regraph';
import { degrees } from 'regraph/analysis';

async function removeSingletons(items) {
  const neighbors = await degrees(items);
  const filtered = { ...items };
  for (var id in neighbors) {
    if (neighbors[id] < 1) {
      delete filtered[id];
    }
  }
  return filtered;
}

function FilteredChart() {
  const [items, setItems] = React.useState(getData());
  const filter = async () => {
    const filtered = await removeSingletons(items);
    setItems(filtered);
  };

  return (
    <div style={{ width: '100%', height: '100%' }}>
      <button onClick={filter}>Filter</button>
      <Chart items={items} />
    </div>
  );
}

By default, graph functions run on nodes and links in the underlying chart level and ignore combos, summary links and aggregate links. For more details, see the Graph Analysis documentation.

  • betweenness (items, options)

    Calculates the betweenness centrality of all nodes in the graph.

    Parameters
    • items object

      The items to analyze.

    • options object

      Various options which define whether the graph is directed, the result normalized and values associated with the links.

      • directed booleandefault:false

        Whether the betweenness computation should consider the direction of links.

      • normalization 'chart' | 'unnormalized' | 'component'default:'component'

        Normalizes the results to ensure that returned values are between 0 and 1. ‘chart’ normalizes the scores of all nodes on the chart by dividing by a single value. ‘component’ considers each unconnected part of a chart as a separate graph, dividing all connected nodes by the same value, but other components by a different value.

      • value string

        The name of the custom property which defines each link's weighting value. Custom properties mean properties set on the data property of the links.

      • weights booleandefault:false

        Specifies if the path length of links are the reciprocal of their value, i.e. ( 1 / value ).

    Returns
    Promise

    Returns a Promise which resolves to a dictionary whose properties are the ids of the nodes in the graph. The values are the betweenness values.

  • closeness (items, options)

    Calculates the closeness centrality of all nodes in the graph.

    Parameters
    • items object

      The items to analyze.

    • options object

      Options which define whether the graph is directed, the result normalized and values associated with the links.

      • direction 'from' | 'to' | 'any'default:'any'

        Specifies whether to take link direction into account. 'from' only includes links in the direction of arrows, 'to' only includes links against the direction of arrows, and 'any' includes any link regardless of arrows. Note that to use 'from' or 'to', your graph must have arrows on links.

      • normalization 'chart' | 'component'default:'component'

        Normalizes the results to ensure that returned values are between 0 and 1. ‘chart’ normalizes the scores of all nodes on the chart by dividing by a single value. ‘component’ considers each unconnected part of a chart as a separate graph, dividing all connected nodes by the same value, but other components by a different value.

      • value string

        The name of the custom property which defines each link's weighting value. Custom properties mean properties set on the data property of the links.

      • weights booleandefault:false

        Specifies if the path length of links are the reciprocal of their value, i.e. ( 1 / value ).

    Returns
    Promise

    Returns a Promise which resolves to a dictionary whose properties are the ids of the nodes in the graph. The values are the closeness values.

  • clusters (items, options)

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

    Parameters
    • items object

      The items to analyze.

    • options object

      Options which special rules for the clusters calculation.

      • consistent booleandefault:true

        Set to true to see the same result every time you run a cluster, or false if you want to see different results.

      • factor numberdefault:5

        A number from 0 to 10 that affects cluster size. Higher values give smaller clusters, but more of them; lower values give larger clusters, but not as many.

      • value string

        The name of a custom property which defines each link's weighting value. Custom properties mean properties set on the data property of the links. Higher valued links tend to cluster their nodes more closely.

    Returns
    Promise

    Returns a Promise which resolves to an array of dictionaries, one entry for each cluster. The values of each dictionary are the items in that cluster.

  • components (items)

    Returns the separate 'connected components' of the graph.

    Parameters
    • items object

      The items to analyze.

    Returns
    Promise

    Returns a Promise which resolves to an array of dictionaries, one entry for each component. The values of each dictionary are the items in that component.

  • degrees (items, options)

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

    Parameters
    • items object

      The items to analyze.

    • options object

      Options which define the direction and values associated with the links.

      • direction 'from' | 'to' | 'any'default:'any'

        Specifies whether to take link direction into account. 'from' counts only links with arrows pointing away from nodes (out-degree), 'to' counts only links with arrows pointing to nodes (in-degree), and 'any' counts all links regardless of whether they have arrows. Note that to use 'from' or 'to', your graph must have arrows on links.

      • value string

        The name of the custom property which defines each link's weighting value. Custom properties mean properties set on the data property of the links.

    Returns
    Promise

    Returns a Promise which resolves to an object whose properties are the ids of the nodes, the values of which are the degree values.

  • distances (items, id, options)

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

    Parameters
    • items object

      The items to analyze.

    • id string

      The id of the node to start from.

    • options object

      Options for the direction and values associated with the paths.

      • direction 'from' | 'to' | 'any'default:'any'

        Specifies whether to take link direction into account. 'from' only includes links in the direction of arrows, 'to' only includes links against the direction of arrows, and 'any' includes any link regardless of arrows. Note that to use 'from' or 'to', your graph must have arrows on links.

      • value string

        The name of the custom property which defines the distance value of a link. Custom properties mean properties set on the data property of the links.

      • weights booleandefault:false

        Specifies if the path length of links are the reciprocal of their value, i.e. ( 1 / value ).

    Returns
    Promise

    Returns a Promise which resolves to a dictionary object, where the properties are the ids of the nodes and the values are the distances.

  • eigenCentrality (items, options)

    Computes the eigenvector centrality of each node.

    Parameters
    • items object

      The items to analyze.

    • options object

      Options which define special rules for the eigencentrality computation.

      • value string

        The name of the custom property which defines each link's weighting value. Custom properties mean properties set on the data property of the links. If not set, all links have value 1.

    Returns
    Promise

    Returns a Promise which resolves to a dictionary object, where the properties are the ids of the nodes and the values are the eigenvector centralities.

  • kCores (items)

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

    Parameters
    • items object

      The items to analyze.

    Returns
    Promise

    Returns a Promise which resolves to an object which describes the kCores found.

  • neighbors (items, id, options)

    Calculates the list of neighboring (i.e. linked) items to the ids supplied.

    Parameters
    • items object

      The items to analyze.

    • id string | array of strings | object

      The items whose neighbors should be found. Can be either a string id, an array of string ids, or an object of items (indexed by id).

    • options object

      Options which define special rules for items iteration.

      • direction 'from' | 'to' | 'any'default:'any'

        Specifies whether to take link direction into account. 'from' only finds neighbors in the direction of arrows, 'to' only finds neighbors against the direction of arrows, and 'any' finds neighbors on any link regardless of arrows. Note that to use 'from' or 'to', your graph must have arrows on links.

      • hops numberdefault:1

        Defines how far away neighbors can be from the passed ids.

    Returns
    Promise

    Returns a Promise which resolves to a dictionary of neighboring items.

  • pageRank (items, options)

    Computes the Page Rank of each node.

    Parameters
    • items object

      The items to analyze.

    • options object

      Options which define special rules for the Page Rank computation.

      • directed booleandefault:true

        Whether the Page Rank computation should consider the direction of links.

      • value string

        The name of the custom property which defines each link's weighting value. Custom properties mean properties set on the data property of the links. If not set, all links have value 1.

    Returns
    Promise

    Returns a Promise which resolves to a dictionary object, where the properties are the ids of the nodes and the values are the Page Rank scores.

  • shortestPaths (items, id1, id2, options)

    Calculates all the shortest paths between the nodes specified.

    Parameters
    • items object

      The items to analyze.

    • id1 string

      The id of the starting node on the path.

    • id2 string

      The id of the ending node on the path.

    • options object

      Various options for the direction and values associated with the paths.

      • direction 'from' | 'to' | 'any'default:'any'

        Specifies whether to take link direction into account. 'from' only traverses links in the direction of arrows, 'to' only traverses links against the direction of arrows, and 'any' can traverse any link regardless of arrows. Note that to use 'from' or 'to', your graph must have arrows on links.

      • value string

        The name of the custom property which defines each link's weighting value. Custom properties mean properties set on the data property of the links.

      • weights booleandefault:false

        Specifies if the path length of links are the reciprocal of their value, i.e. ( 1 / value ).

    Returns
    Promise

    Returns a Promise which resolves to an object which describes the path structure.

    • distance number

      The length of the shortest path - more precisely the combined link value of the path.

    • items object

      A dictionary whose properties are the ids of items on the shortest paths. The values are the item definitions.

    • one array of strings

      An array of ids describing the same path as onePath, but containing nodes only. Includes the start and end nodes.

    • onePath array of strings

      One of the shortest paths found - returned an array of alternating node and link ids. Includes the start and end nodes.

Config Functions

Functions to help you configure the behavior of ReGraph. Config functions are in the 'regraph/config' package and need to be imported before use.

  • setCorsAdapter (adapter)

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

    import { setCorsAdapter } from 'regraph/config';
    
    setCorsAdapter((url) => {
      if (url.startsWith('https://regraph.io/')) {
        return 'use-credentials';
      } else {
        return 'anonymous'
      }
    });
    
    Parameters
    • adapter 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.

    Returns
    void