chart = {
const svg = d3
.create('svg')
.attr('width', chartWidth + margin.right + margin.left)
.attr('height', height + margin.top + margin.bottom);
const g = svg
.append('g')
.attr('transform', `translate(${margin.left}, ${margin.top})`);
g.append('g')
.attr('class', 'x axis')
.attr('transform', `translate(0,${height})`)
.call(xAxis)
.call(g => g.select(".domain").remove());
g.append('g')
.attr('class', 'y axis')
.call(yAxis)
.call(g => g.select(".domain").remove())
.selectAll('.tick line')
.attr('stroke', '#eee');
g.append('g')
.attr('class', 'points')
.selectAll('circle')
.data(data)
.join('circle')
.attr('fill', 'steelblue')
.attr('r', 4)
.attr('cx', d => x(d.date))
.attr('cy', d => y(d.price_gb));
g.append('circle')
.attr('opacity', hover ? 1 : 0)
.attr('r', 4)
.attr('stroke-width', 2)
.attr('fill', 'none')
.attr('stroke', 'black')
.attr('cx', hover ? x(hover.date) : null)
.attr('cy', hover ? y(hover.price_gb) : null);
g.append('g').call(rect);
return svg.node();
}