chart = {
const svg = d3
.create("svg")
.attr("viewBox", [0, 0, width, height])
.style("background-color", "#E5E5E3");
svg
.append('rect')
.attr('class', 'frame')
.attr('fill', 'none')
.attr('stroke', 'black')
.attr('width', width)
.attr('height', height)
.attr('stroke-width', 6);
svg
.selectAll('path')
.data(data)
.enter()
.append("path")
.attr("fill", "none")
.attr("stroke", "black")
.attr("stroke-width", 1.1)
.attr("d", line)
.attr('transform', (d, i) => {
var row = Math.floor(i / cols);
var col = i % cols;
return `translate(${(col + 1) * 25},${row * 30 + 90})`;
});
svg
.selectAll('text')
.data(credit)
.enter()
.append('text')
.attr('text-anchor', 'start')
.attr('transform', (d, i) => {
var row = Math.floor(data.length / cols);
var col = cols - credit.length + 1 + i;
return `translate(${col * 25},${(row + 1) * 30})`;
})
.text(d => d);
return svg.node();
}