sourcesChart = () => {
const svg = d3.create("svg")
.attr("width", chartwidth + margin.left + margin.right)
.attr("height", chartheight + margin.top + margin.bottom);
svg.append("style").html(css);
const g = svg.append("g")
.attr("transform", `translate(${[margin.left, margin.top]})`);
g.append("g")
.call(xAxisGenerator);
g.append("g")
.call(yAxisGenerator);
const lineG = g.selectAll(".line-g")
.data(lineData)
.join("g")
.attr("class", "line-g");
lineG.append("path")
.attr("d", d => line(d[1]))
.attr("fill", "none")
.attr("stroke", d => colors[d[0]])
.attr("stroke-width", 2);
const labelG = g.selectAll(".label-g")
.data(labelData)
.join("g")
.attr("class", "label-g")
.attr("transform", d => `translate(${[chartwidth, d.y]})`);
labelG.append("text")
.attr("fill", d => colors[d.variable])
.attr("x", 4)
.attr("y", 4)
.text(d => d.label)
return svg.node();
}