3D Scatter

3D scatter plot based on Plotly.js

Updated 8 years ago by Duncan Clark

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

template: _84

version: _1

Template data

There are three different formats in which you can supply data to this template. The most convenient for you to use likely depends on the source of your data, as described below.

1. Array of arrays, and a bindings object

You can supply arrays of arrays to opts.data, which might look like:

{
    data: {
        points: [
            [ "PointsColumn1Value1", "PointsColumn2Value1",
            [ "PointsColumn1Value2", "PointsColumn2Value2",
            [ "PointsColumn1Value3", "PointsColumn2Value3",
            ...
        ],
        config: [
            [ "ConfigColumn1Value1", "ConfigColumn2Value1",
            [ "ConfigColumn1Value2", "ConfigColumn2Value2",
            [ "ConfigColumn1Value3", "ConfigColumn2Value3",
            ...
        ]
    }
}

where each array of arrays represents the rows in a data sheet.

To tell the API how the 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: "_84",
    version: "_1",
    bindings: {
        points: {
            set: 0, // index of a column in your data
            x: 1, // index of a column in your data
            y: 2, // index of a column in your data
            z: 3, // index of a column in your data
        },
        config: {
            name: 0, // index of a column in your data
            col: 1, // index of a column in your data
            size: 2, // index of a column in your data
        }
    },
    data: {
        points: [
            [ "PointsColumn1Value1", "PointsColumn2Value1",
            [ "PointsColumn1Value2", "PointsColumn2Value2",
            [ "PointsColumn1Value3", "PointsColumn2Value3",
            ...
        ],
        config: [
            [ "ConfigColumn1Value1", "ConfigColumn2Value1",
            [ "ConfigColumn1Value2", "ConfigColumn2Value2",
            [ "ConfigColumn1Value3", "ConfigColumn2Value3",
            ...
        ]
    }
}

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

{
    template: "_84",
    version: "_1",
    bindings: {
        points: {
            set: 0, // index of a column in your data
            x: 1, // index of a column in your data
            y: 2, // index of a column in your data
            z: 3, // index of a column in your data
        },
        config: {
            name: 0, // index of a column in your data
            col: 1, // index of a column in your data
            size: 2, // index of a column in your data
        }
    },
    data: {
        points: [
            [ "PointsColumn1Value1", "PointsColumn2Value1",
            [ "PointsColumn1Value2", "PointsColumn2Value2",
            [ "PointsColumn1Value3", "PointsColumn2Value3",
            ...
        ],
        config: [
            [ "ConfigColumn1Value1", "ConfigColumn2Value1",
            [ "ConfigColumn1Value2", "ConfigColumn2Value2",
            [ "ConfigColumn1Value3", "ConfigColumn2Value3",
            ...
        ]
    }
}

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

{
        points: [
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            ...
        ],
        config: [
            { "ConfigHeader1": ..., "ConfigHeader2": ..., ... },
            { "ConfigHeader1": ..., "ConfigHeader2": ..., ... },
            { "ConfigHeader1": ..., "ConfigHeader2": ..., ... },
            ...
        ]
    }

... but with the keys being the column headers from your source data instead. You must also supply an object attached to opts.bindings. The minimal bindings you can supply for this template are as shown in this example:

{
    template: "_84",
    version: "_1",
    bindings: {
        points: {
            set: "PointsHeader1",
            x: "PointsHeader2",
            y: "PointsHeader3",
            z: "PointsHeader4",
        },
        config: {
            name: "ConfigHeader1",
            col: "ConfigHeader2",
            size: "ConfigHeader3",
        }
    },
    data: {
        points: [
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            ...
        ],
        config: [
            { "ConfigHeader1": ..., "ConfigHeader2": ..., ... },
            { "ConfigHeader1": ..., "ConfigHeader2": ..., ... },
            { "ConfigHeader1": ..., "ConfigHeader2": ..., ... },
            ...
        ]
    }
}

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

{
    template: "_84",
    version: "_1",
    bindings: {
        points: {
            set: "PointsHeader1",
            x: "PointsHeader2",
            y: "PointsHeader3",
            z: "PointsHeader4",
        },
        config: {
            name: "ConfigHeader1",
            col: "ConfigHeader2",
            size: "ConfigHeader3",
        }
    },
    data: {
        points: [
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            { "PointsHeader1": ..., "PointsHeader2": ..., ... },
            ...
        ],
        config: [
            { "ConfigHeader1": ..., "ConfigHeader2": ..., ... },
            { "ConfigHeader1": ..., "ConfigHeader2": ..., ... },
            { "ConfigHeader1": ..., "ConfigHeader2": ..., ... },
            ...
        ]
    }
}

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

3. 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: "_84",
    version: "_1",
    data: {
    points: [
        {
            set: ...,
            x: ...,
            y: ...,
            z: ...
        },
        ...
    ],
    config: [
        {
            name: ...,
            col: ...,
            size: ...
        },
        ...
    ]
},
    ...
}

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

{
    template: "_84",
    version: "_1",
    data: {
    points: [
        {
            set: ...,
            x: ...,
            y: ...,
            z: ...
        },
        ...
    ],
    config: [
        {
            name: ...,
            col: ...,
            size: ...
        },
        ...
    ]
},
    ...
}

Meanings of the template data keys:

  • points.set: set
  • points.x: x
  • points.y: y
  • points.z: z
  • config.name: name
  • config.col: col
  • config.size: size

Template settings

Options for opts.state.

Layout

title text

Chart title.

xTitle string

x-axis title.

yTitle string

y-axis title.

zTitle string

z-axis title.

axisCol color

Colour of axes.

gridCol color

Colour of grid.

layoutBgCol color

Colour of background.

Projections

showProjections boolean

Show data projections.

projectionScale number

Scale of projected points (%).

Max: 100

projectionOpacity number

Opacity of projected points (%).

Max: 100