{
const svg = d3.create('svg').attr('viewBox', [0,0,width, height]).style('background', "#463152")
const wrapper = svg.append('g').attr("transform", `translate(${margin.left},${margin.top})`)
const node = wrapper.selectAll('g').data(lol_dataset.nodes).join('g').attr('transform', function(d) { return `translate(${d.x},${ d.y})`}).call(create_node)
const simulation = d3.forceSimulation();
simulation.nodes(lol_dataset.nodes);
const desc_group = svg.append('g').attr('transform', `translate(30,30)`)
desc_group.append('text').text("Red side vs Blue Side Pick Rate, Patch(11.13 and 11.14)").attr('fill', "white")
desc_group.append('text').attr('transform', `translate(${0}, ${30})`).text(`Region ${curr_region}`).attr('fill', "white").attr('font-size', 30)
wrapper.append("g").attr('transform', `translate(${0},${margin.top})`).call(xAxis)
wrapper.append('line')
.attr('stroke', 'white')
.attr('opacity', 0.8)
.style('stroke-dasharray', '5,5')
.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("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})`})
})
return Object.assign(svg.node(), {
update(curr_region) {
simulation.alpha(1).alphaDecay(0.01).velocityDecay(0.36 ).restart()
}
});
}