chart = {
const svg = d3
.create("svg")
.attr("viewBox", [-width / 2, -height / 2, width, height])
.attr("font-size", 10)
.attr("font-family", "sans-serif");
const chords = chord(matrix);
const max = d3.max(d3.merge(matrix));
const group = svg
.append("g")
.selectAll("g")
.data(chords.groups)
.join("g");
group
.append("path")
.attr("fill", d => color(d.index))
.attr("stroke", d => d3.rgb(color(d.index)).darker())
.attr("d", arc);
const groupTick = group
.append("g")
.selectAll("g")
.data(d => groupTicks(d, parseInt(max / 6)))
.join("g")
.attr(
"transform",
d =>
`rotate(${(d.angle * 180) / Math.PI - 90}) translate(${outerRadius},0)`
);
groupTick
.append("line")
.attr("stroke", "#000")
.attr("x2", 6);
groupTick
.append('a')
.attr(
'href',
d => `https://ln.bigsun.xyz/channel/${channels[d.source.index]}`
)
.append("text")
.attr("x", 8)
.attr("dy", ".35em")
.attr("transfox564654rm", d =>
d.angle > Math.PI ? "rotate(180) translate(-16)" : null
)
.attr("text-anchor", d => "start")
.text(d =>
d.value
? `${d.value}sat`
: channel_map.has(channels[d.source.index])
? `${channel_map.get(channels[d.source.index]).peer.name} (${
channels[d.source.index]
})`
: channels[d.source.index]
);
svg
.append("g")
.attr("fill-opacity", 0.67)
.selectAll("path")
.data(chords)
.join("path")
.attr("d", ribbon)
.attr("fill", d => color(d.target.index))
.attr("stroke", d => d3.rgb(color(d.target.index)).darker());
return svg.node();
}