{
const paddingTop = 100
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.style("font", "10px sans-serif");
const g = svg.append("g")
.attr("transform",`translate(0,${paddingTop})`)
const simulation = d3.forceSimulation(circles)
.force("x", d3.forceX(d => d.x))
.force("y", d3.forceY(d => d.y))
.force("collide", d3.forceCollide(d => d.r).strength(0.3));
const bar = g.append("g")
.selectAll("g")
.data(agendas)
.join("g")
.attr("class",(d,i) => `agenda-group-${i}`)
.on("mouseover",(evt,d,i)=>mouseOver(evt,d,i))
.on("mouseout",mouseOut)
bar.append("rect")
.attr("width",15)
.attr("height",(d,i) => -yScaleBar(dialogs.filter(d => d.agenda === i).length) )
.attr("y", (d,i) => yScaleBar(dialogs.filter(d => d.agenda === i).length))
.attr("x",(d,i) => 50 * i)
.attr("fill","grey")
.attr("opacity",0.5)
g.append("g")
.call(axisRight)
g.append("g")
.call(axisBottom)
const storyBoard = g.append("g")
.attr("class","storyBoard")
const nodes = storyBoard.selectAll("g")
.data(circles)
.join("g")
.attr("class",d => `node ${d.topic == undefined ? "":"node-topic-"+d.topic} ${d.agenda == undefined ? "":"node-agenda-"+d.agenda}`)
.attr("transform",d=>`translate(${d.x},${d.y})`)
nodes.selectAll("path")
.data(d=>d.arcs)
.join("path")
.attr("d",d=>arc(d))
.attr("fill-opacity", d=>{
if(d.value === 2)
return 0.3
else
return 0.85
})
.attr("fill",d=>{
if(d.value === 2)
return "grey"
else
return color[d.index]
})
simulation.on("tick", () => {
nodes
.transition()
.delay((d, i) => d.x)
.ease(d3.easeLinear)
.attr("transform",d=>`translate(${d.x},${d.y})`)
});
simulation.on("end",()=>{
bar.append("g")
.selectAll("path")
.data((d,i) => circles.filter(d=>d.agenda != undefined && d.agenda === i))
.join("path")
.attr("class",d=>`link link-${d.index}`)
.transition()
.duration(2000)
.attr("d",d => lineCurveTo ([d.agenda * 50 + 7.5,0],[d.x,d.y]))
.attr("stroke","grey")
.attr("stroke-opacity",0.3)
.attr("fill","none")
})
return svg.node()
}