Chord diagrams visualise links (or flows) between a group of nodes, where each flow has a numeric value. For example, they can show migration flows between countries. (Personally I find them difficult to interpret!)
The data needs to be in the form of an n x n matrix (where n is the number of items):
The first row represents flows from the 1st item to the 1st, 2nd and 3rd items etc.
You create the layout using:
and you configure it using
.padAngle() (to set the angle between adjacent groups in radians),
.sortGroups() (to specify the order of the groups),
.sortSubgroups() (to sort within each group) and
.sortChords() to determine the z order of the chords.
Apply the layout using:
which returns an array of chords. Each element of the array is an object with
target properties. Each
endAngle properties which will define the shape of each chord.
We use the
ribbon shape generator which converts the chord properties into path data (see the Shapes chapter for more information on shape generators).