Plot.plot({
title: "How many gold medals won by the top 10 nations in 2020 Olympics",
width: width,
height: 700,
y: {
label: null,
domain: d3.sort(olympics2020, d => -d.gold).map(d => d.nation)
},
x: {
domain: [0.5, 1],
axis: null
},
marks: [
Plot.text(olympics2020, {
text: d => medals["gold"].repeat(d.gold),
y: "nation",
fontSize: 15,
frameAnchor: "left"
}),
Plot.text(olympics2020, Plot.stackX({
text: d => medals["silver"].repeat(d.silver),
y: "nation",
fontSize: 15,
frameAnchor: "left",
dx: 0,
dy: 20
})),
Plot.text(olympics2020, Plot.stackX({
text: d => medals["bronze"].repeat(d.bronze),
y: "nation",
fontSize: 15,
frameAnchor: "left",
dx: 0,
dy: 40
}))
]
})