chart = {
const svg = d3.create('svg')
.attr('width', width)
.attr('height', height);
svg.append('g')
.call(xAxis);
svg.append('g')
.call(yAxis);
svg.selectAll('.line')
.data(dataGroup)
.join('path')
.attr('class', 'line')
.attr('d', d => line(d[1]))
.attr('stroke', d => colorScale(d[0]))
.attr('stroke-width', 1)
.attr('fill', 'none');
let legend = svg.selectAll(".legend")
.data(dataGroup)
.enter();
legend
.append('text')
.text(d => d[0])
.attr('x', legendOrigin[0] + labelHeight * 1.2)
.attr('y', (d,i) => legendOrigin[1] + labelHeight + labelHeight * 1.2 *i)
.style('font-family', 'sans-serif')
.style('font-size', `${labelHeight-3}px`);
legend
.append('rect')
.attr('x', legendOrigin[0])
.attr('y', (d,i) => legendOrigin[1] + labelHeight * 1.2 * i)
.attr('width', labelHeight)
.attr('height', labelHeight)
.attr('fill', d => colorScale(d[0]))
.attr('stroke', 'none');
return svg.node();
}