chart = {
const svg = d3.create('svg')
.attr('viewBox', [0, 0, width, height])
svg.append('g')
.call(xAxis)
svg.append('g')
.call(yAxis)
const seriesG = svg.append('g')
.selectAll('g')
.data(series)
.join('g')
seriesG.append('path')
.attr('fill', 'none')
.attr('stroke', d => z(d[0].key))
.attr('stroke-width', 1.5)
.attr('d', d3.line()
.x(d => x(d.date))
.y(d => y(d.value)))
seriesG.append('g')
.attr('font-family', 'sans-serif')
.attr('font-size', 10)
.attr('stroke-linecap', 'round')
.attr('stroke-linejoin', 'round')
.attr('text-anchor', 'middle')
.selectAll('text')
.data(d => d)
.join('text')
.text(d => d.value)
.attr('dy', '0.35em')
.attr('x', d => x(d.date))
.attr('y', d => y(d.value))
.call(text => text.filter((d, i, data) => i === data.length - 1)
.append('tspan')
.attr('font-weight', 'bold')
.text(d => ` ${d.key}`))
.clone(true).lower()
.attr('fill', 'none')
.attr('stroke', 'white')
.attr('stroke-width', 6)
return svg.node()
}