{
const svg = d3.create('svg').attr('viewBox', [0,0,width, height]).style('background', "black")
const wrapper = svg.append('g').attr("transform", `translate(${margin.left},${margin.top})`)
let nodes = wrapper.selectAll('g').data(covid_ph).join('g').attr('transform', d => `translate(${x(d.date)}, ${innerHeight})`)
let lines = nodes.append('line').attr('fill', 'whitesmoke').attr('x1', 0).attr('y1', 0).attr('x2', 0).attr('y2',0).attr('stroke-width', 2).attr('stroke', 'whitesmoke').attr('stroke-linecap', 'round').attr('stroke-dasharray', '1,30').attr('opacity', 0.7)
nodes.append('circle').attr('r', parseInt(x.step())/2).attr('fill', 'white').attr('stroke-width', 1).attr('stroke', 'white').attr('class', 'main-circle')
nodes.transition().delay((d, i) => i*200).duration(500).ease(d3.easeLinear).attr('transform', d => `translate(${x(d.date)}, ${y(d.new_cases)})`)
lines.transition().delay((d, i) => i*200).duration(500).ease(d3.easeLinear).attr('x2', 0).attr('y2',d => innerHeight - y(d.new_cases))
// .attr('fill', 'white')
// .attr('x1', x(0.5))
// .attr('y1', 0)
// .attr('x2', x(0.5))
// .attr('y2', innerHeight)
// wrapper.append('text').attr('transform', `translate(${x(0.5)}, ${40})`).text('50% pickrate').attr('fill', 'white').attr('align-text', 'center')
// // simulation force
// simulation.force("charge", d3.forceManyBody())
// .force('y', d3.forceY().y(y('All')).strength(0.1))
// .force('x', d3.forceX().x(d => x(parseFloat(d.data[curr_region].red_weight))).strength(1))
// .force('collide',d3.forceCollide().radius(function(d) { return r(d.data[curr_region].totalpickrate) + 15}))
// simulation.alpha(1).alphaDecay(0.01).velocityDecay(0.36)
// simulation.on('tick', () => {
// node.transition().duration(700).ease(d3.easeLinear).attr('transform', function(d) {
// return `translate(${d.x},${ d.y})`})
// })
// innerHeight = height-margin.top-margin.bottom
// innerWidth = width-margin.left-margin.right
// x = d3.scaleLinear()
// .domain([0,1])
// .range([0, innerWidth])
// y = d3.scaleBand().domain(["All"]).range([0, innerHeight]).padding(1)
// xAxis = g => g
// .call(d3.axisTop(x).ticks(0))
// .call(g => g.select('.text').remove())
// .call(g => g.selectAll('.tick line').remove())
// .call(g => g.select('.domain').remove())
// .call(g => g.append('text')
// .attr('x', -10)
// .attr('y', 0)
// .attr('font-weight', 'bold')
// .attr('font-size', "0.65rem")
// .attr('fill', 'white')
// .attr('text-anchor', 'end')
// .text('← Blue Pick Rate'))
// .call(g => g.append('text')
// .attr('x', x(1)+10)
// .attr('y', 0)
// .attr('font-weight', 'bold')
// .attr('font-size', "0.65rem")
// .attr('fill', 'white')
// .attr('text-anchor', 'start')
// .text('Red Pick Rate →'))
// yAxis = g => g
// .call(d3.axisLeft(y) .tickFormat(d => `${d} `).ticks(0))
// .call(g => g.select('.text').remove())
// .call(g => g.append('text')
// .attr('x', 0)
// .attr('y', 0)
// .attr('font-weight', 'bold')
// .attr('font-size', "0.87rem")
// .attr('fill', 'white')
// .attr('text-anchor', 'start')
// .text('50% Pick Rate'))
return svg.node()
}