plotter =
({text = "name", scale = 1} = {}) =>
({tones, links}) =>
Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.text(
toner(tones),
{
y: 0,
x: "id",
text,
dy: +12
}),
Plot.text(
links,
{
x: ({source, target}) => (source + target) / 2,
y: ({source, target}) => .71 * Math.abs(source - target) / (tones.length - 1),
dy: 10,
text: ({source, target}) => Math.abs(source - target) * scale,
}
),
Plot.arrow(links, {y: 0, x1: "source", x2: "target", sweep: "-x", bend: 90, headLength: 0, reverse: true})
],
marginLeft: 18,
marginRight: 18,
marginBottom: 72,
height: 500,
axis: null,
y: {domain: [0, 1]},
})