timeline = {
const scale = 0.7;
let svg = d3.create("svg")
.attr("width", scale * 1200)
.attr("height", scale * 3000)
.style("background","#7F1431")
const images = await Promise.all(countryList.map(el => el.flag));
const xScale = d3.scaleBand()
.domain([0,1,2,3,4])
.range([0, scale * 400])
.paddingInner(0.1);
const yScale = d3.scaleLinear()
.domain([0, 50000])
.range([scale * 225, 0]);
let tickLabels = ["Rd. 16","Quart.","Semi","Final","WIN!"]
svg.append("text")
.attr("x", scale*600)
.attr("y", scale*100)
.classed("main-title-1",true)
.text("World Cup 2022")
svg.append("text")
.attr("x", scale*600)
.attr("y", scale*180)
.classed("main-title-2",true)
.text("Knockout Stage Results from 50,000 Simulations")
countryList.map( (country, index) => {
svg.append("rect")
.classed("blackRect",true)
.attr("transform", `translate(${scale*(index%2===0 ? 40 : 1200 - 400 - 40)}, ${scale*(index * 160 + 250)})`)
.attr("width", scale * 400)
.attr("height", scale * 225)
.attr("fill","black")
svg.append("image")
.classed("clipFlags",true)
.attr("transform", `translate(${scale*(index%2===0 ? 40 : 1200 - 400 - 40)}, ${scale*(index * 160 + 250)})`)
.attr("href", images[index].src)
.attr("width", scale * 400)
.attr("height", scale * 225)
.attr('clip-path', `url(#${country.team.replaceAll(" ","-")}-clip)`)
svg.append("g")
.attr("transform", `translate(${scale*(index%2===0 ? 40 : 1200 - 400 - 40)}, ${scale*(index * 160 + 250)})`)
.append("clipPath")
.attr("id", `${country.team.replaceAll(" ","-")}-clip`)
.selectAll(`.${country.team}-bar`)
.data(Object.values(results_tally.find(item => item.Country === country.team)).slice(1))
.join("rect")
.classed("bar",true)
.attr("stroke","white")
.attr("x", (d,i) => xScale(i))
.attr("y", d => yScale(d))
.attr("width", xScale.bandwidth())
.attr("height", d => scale*225 - yScale(d));
svg.append("g")
.attr("transform", `translate(${scale*(index%2===0 ? 40 : 1200 - 400 - 40)}, ${scale*(index * 160 + 250)})`)
.selectAll(`.${country.team}-bar-label`)
.data(Object.values(results_tally.find(item => item.Country === country.team)).slice(1))
.join("text")
.text((d,i) => (i===0 ? "" : Math.round(100 * d/50000)+"%" ))
.classed("bar-label",true)
.attr("fill","white")
.attr("x", (d,i) => xScale(i) + xScale.bandwidth() / 2)
.attr("y", d => yScale(d) - scale*5);
svg.append("image")
.classed("backgroundFlag",true)
.style("opacity",0.25)
.attr("transform", (d,i) => `translate(${scale*(index%2===0 ? 40 : 1200 - 400 - 40)}, ${scale*(index * 160 + 250)})`)
.attr("href", images[index].src)
.attr("width", scale * 400)
.attr("height", scale * 225)
svg.append("g")
.classed("xAxis",true)
.attr("transform", `translate(${scale*(index%2===0 ? 40 : 1200 - 400 - 40)}, ${scale*(index * 160 + 250 + 225)} )`)
.call(d3.axisBottom(xScale).tickSize(0).tickSizeOuter(0).tickFormat((d,i) => tickLabels[i]));
svg.append("text")
.attr("x", scale*(index%2===0 ? 600 - 150 : 600 + 150))
.attr("y", scale*(index * 160 + 350))
.classed("countryNames",true)
.text(d => country.team)
.style("text-anchor", index%2===0 ? "start" : "end")
.attr("fill", "white")
})
return svg.node();
}