SwarmPlot

@nivo/swarmplot

A swarm plot component which can also be used to make a beeswarm plot when using a single group.

This chart can display 2 data dimensions, a categorical one: groups, and a quantitative one: values.

You can optionally add a third quantitative dimension if you enable dynamic node size, please have a look at the size property for further information.

You can also enable a voronoi mesh to capture user's interactions, using the useMesh property.

This example uses 3 dimensions, the grouping is done by the group property while the value is determined by the price property, node size is dynamic and depends on the volume property.

Under the hood, this chart uses d3-force with a simulation involving collisions and x/y forces, the quality of the simulation can be adjusted, the strength of the value force too.

The responsive alternative of this component is ResponsiveSwarmPlot.

roll the dice
188 nodes
Actions Logs
Start interacting with the chart to log actions
Base
object[]required

Chart data.

string | Functionoptionaldefault:'id'

Property used to retrieve the node's unique identifier.

string | Functionoptionaldefault:'value'

Property used to retrieve the node's value.

string | (value: number) => string | numberoptional
open editor

Optional formatter for values.

string[]required

Available groups.

string | Functionoptionaldefault:'group'

Propety used to group nodes, must return a group which is available in the groups property.

number | object | Functionoptionaldefault:6

How to compute node size, static or dynamic.

numberoptionaldefault:2
px

Spacing between nodes.

numberrequired

Chart width for non-responsive component.

numberoptional

Chart default width for responsive component.

numberrequired

Chart height for non-responsive component.

numberoptional

Chart default height for responsive component.

number (ms)optional

Debounce width/height updates for responsive component.

(dimensions: { width: number; height: number }) => voidoptional

A callback for when responsive component is resized.

numberoptionaldefault:'Depends on device'

Adjust pixel ratio, useful for HiDPI screens.

supportsvgcanvas
objectoptional
px
px
px
px

Chart margin.

Ref<SVGSVGElement | HTMLCanvasElement>optional

Ref to the chart's container. Used on this page to generate/download the chart's image via html-to-image.

Simulation
Layout
Style
Customization
Grid & Axes
Interactivity
Motion