Network diagram

Simple network visualisations

Updated 2 years ago by Template retirement home

How to use this template

Network graph

A template that renders a network of points and links as a force-directed graph (AKA a “node-link diagram”).

Data requirements

The minimum data requirement is a two-column list of “Links”. Each row in the list specifies the points (displayed as circles) at either end of a link (displayed as a line). You can optionally include a third column that is used to set the width of the link. (This can be thought of as visual indicator of the strength or weight of a link.)

While the Links sheet is sufficient to create a network diagram, a second “Points” sheet allows for further flexibility. Rather than letting Flourish determine all the points to add to the network based on those listed in the Links sheet, the rows in the Points sheet define the complete collection of points. This sheet can also be used to assign groups (encoded using colour) and sizes to the points.

Tips

  • Initially it is assumed that the network diagram is undirected. However, the “Network is directional” checkbox in the “Arrows” settings panel will turn each link into an arrow going from the “Source” point to the “Destination” point.
  • The D3 force documentation may be useful for understanding the advanced settings.

This section documents API usage specific to this template, so for an introduction we suggest you refer to the generic API documentation instead.

template: _210

version: _10

Template data

There are two different formats in which you can supply data to this template. Which one will be more convenient for you likely depends on the source of your data, as described below.

Array of objects with arbitrary keys, and a bindings object

This format is most likely useful when you have data from an external source, such as CSV data loaded from d3-dsv. You should supply this attached to the opts.data, which might look like:

    {
        links: [
            { "LinksHeader1": ..., "LinksHeader2": ..., ... },
            { "LinksHeader1": ..., "LinksHeader2": ..., ... },
            { "LinksHeader1": ..., "LinksHeader2": ..., ... },
            ...
        ],
        nodes: [
            { "NodesHeader1": ..., "NodesHeader2": ..., ... },
            { "NodesHeader1": ..., "NodesHeader2": ..., ... },
            { "NodesHeader1": ..., "NodesHeader2": ..., ... },
            ...
        ]
    }

... but with the keys being the column headers from your source data instead. To tell the API how these values from each column should be associated with the keys that the template is expecting, you must also supply an object attached to opts.bindings. (The meanings of the keys in the bindings object are documented below.) The minimal bindings you can supply for this template are as shown in this example:

{
    template: "_210",
    version: "_10",
    bindings: {
        links: {
            source: "LinksHeader1",
            target: "LinksHeader2"
        },
        nodes: {
            
        }
    },
    data: {
        links: [
            { "LinksHeader1": ..., "LinksHeader2": ..., ... },
            { "LinksHeader1": ..., "LinksHeader2": ..., ... },
            { "LinksHeader1": ..., "LinksHeader2": ..., ... },
            ...
        ],
        nodes: [
            { "NodesHeader1": ..., "NodesHeader2": ..., ... },
            { "NodesHeader1": ..., "NodesHeader2": ..., ... },
            { "NodesHeader1": ..., "NodesHeader2": ..., ... },
            ...
        ]
    }
}

All possible bindings that you can supply are shown in this example:

{
    template: "_210",
    version: "_10",
    bindings: {
        links: {
            source: "LinksHeader1",
            target: "LinksHeader2",
            value: "LinksHeader3"
        },
        nodes: {
            id: "NodesHeader1",
            group: "NodesHeader2",
            size: "NodesHeader3"
        }
    },
    data: {
        links: [
            { "LinksHeader1": ..., "LinksHeader2": ..., ... },
            { "LinksHeader1": ..., "LinksHeader2": ..., ... },
            { "LinksHeader1": ..., "LinksHeader2": ..., ... },
            ...
        ],
        nodes: [
            { "NodesHeader1": ..., "NodesHeader2": ..., ... },
            { "NodesHeader1": ..., "NodesHeader2": ..., ... },
            { "NodesHeader1": ..., "NodesHeader2": ..., ... },
            ...
        ]
    }
}

(As before, the keys containing "Header" would be replaced by column names from your data source.)

Array of objects with template-defined keys

There is an alternative format you can use, which is likely to be easier to use if your data is not from a spreadsheet source. With this alternative format you supply your data to the template as an array of objects, attached to opts.data, where the keys must be those used by the template, as documented below. In this case there is no need to supply a bindings object, since the key names are already those expected by the template. The required properties in the data object are as follows (scroll down for a description of what each property is):

{
template: "_210",
version: "_10",
data: {
    links: [
        {
            source: ...,
            target: ...
        },
        ...
    ]
},
...
}

And the full list of all possible properties is as follows:

{
template: "_210",
version: "_10",
data: {
    links: [
        {
            source: ...,
            target: ...,
            value: ...
        },
        ...
    ],
    nodes: [
        {
            id: ...,
            group: ...,
            size: ...
        },
        ...
    ]
},
...
}

Meanings of the template data keys:

  • links.source: source
  • links.target: target
  • links.value: A numerical value used to set the thickness of the links.
  • nodes.id: A unique identifier for each point in the network. If not specified, node information will be extracted from the links sheet.
  • nodes.group: A group to which the point belongs. If set, can be used to colour the points. Ignored if ID not set
  • nodes.size: A numerical value used to size the points. Ignored if ID not set

Template settings

Options for opts.state.

Title and subtitle

title string

Title.

subtitle string

Subitle.

title_text_color color

Text colour.

title_padding number

Margin below.

General

background_color color

Background colour.

fade_opacity number

Opacity of de-emphasized items.

Max: 1

legend_show boolean

Show legend.

Points

node_size number

Default size. Only used if point size not set in data

palette string

Colour scheme.

Allowed values:

  • schemeCategory10 (Category 10)
  • schemeCategory20 (Category 20)
  • schemeCategory20b (Category 20b)
  • schemeCategory20c (Category 20c)
  • schemeAccent (Accent)
  • schemeDark2 (Dark 2)
  • schemePaired (Paired)
  • schemePastel1 (Pastel 1)
  • schemePastel2 (Pastel 2)

node_stroke_width number

Width.

Max: 5

node_stroke_color color

Colour.

node_highlight_stroke_color color

Colour (highlighted).

directional boolean

Show arrows on links.

Link weight multiplier. Control the thickness of the links

Colour.

Opacity.

Max: 1

Colour (highlighted).

Opacity (highlighted).

Max: 1

Popups

Show popup on points.

Text in popup. Use HTML markup, plus {{ brackets }} to include data

Text.

Outline.

Opacity.

Min: 0.1

Max: 1

Forces

manybodyforce_strength number

Many-body-force strength. Arbitrary units

Max: 50