Chord diagram layout for visualizing relationships between groups.
Chord diagrams display flows or connections between entities arranged in a circle. The outer arcs represent groups, and the chords connecting them represent relationships.
Examples
# Matrix where matrix[i][j] is the flow from group i to group j
matrix = [
[11975, 5871, 8916, 2868],
[ 1951, 10048, 2060, 6171],
[ 8010, 16145, 8090, 8045],
[ 1013, 990, 940, 6907]
]
chord = Visualize.Layout.Chord.new()
|> Visualize.Layout.Chord.pad_angle(0.05)
result = Visualize.Layout.Chord.generate(chord, matrix)
# result.groups - list of group arcs with start_angle, end_angle, value, index
# result.chords - list of chords with source/target containing start_angle, end_angle, index
Summary
Functions
Generates an SVG path for a group arc.
Generates the chord layout from a matrix.
Creates a new chord layout
Sets the padding angle between groups in radians
Generates an SVG path for a chord ribbon.
Sets the comparator for sorting chords
Sets the comparator for sorting groups
Sets the comparator for sorting subgroups within each group
Types
@type chord_end() :: %{ index: non_neg_integer(), start_angle: float(), end_angle: float(), value: number() }
@type group() :: %{ index: non_neg_integer(), start_angle: float(), end_angle: float(), value: number() }
Functions
Generates an SVG path for a group arc.
Generates the chord layout from a matrix.
The matrix should be a list of lists where matrix[i][j] represents the flow from group i to group j.
Returns a map with :groups and :chords.
@spec new() :: t()
Creates a new chord layout
Sets the padding angle between groups in radians
Generates an SVG path for a chord ribbon.
The ribbon connects the source and target arcs with bezier curves.
Sets the comparator for sorting chords
Sets the comparator for sorting groups
Sets the comparator for sorting subgroups within each group