chart = Plot.plot({
width,
height: 700,
y: {type: "linear",
label: "Gender Discrepency",
grid: true,
domain: [-65,80]},
x: {grid: true},
r: {domain: rDomain, range: [2, 50]},
margin: 40,
paddingOuter: 300,
marks: [
Plot.ruleY([0], { stroke: "#d3d3d3" }),
Plot.dot(medal_data, {
x: "GDP per capita (2023)",
y: (d) => d[radioMapping[SelectedMedal]],
r: "Total Medals",
stroke: "#333",
fill: "Gender Diff",
fillOpacity: d => SelectedCountry.includes(d.Country) ? 1: 0.2,
strokeOpacity: d => SelectedCountry.includes(d.Country) ? 1: 0.2,
channels: {Country: "Country",
["Gender Diff"]:
{value: (d) => d[radioMapping[SelectedMedal]],
label: "Gender Difference"},
["GDP per capita (2023)"]:
{value: "GDP per capita (2023)",
label: "GDP"}},
tip: {
format: {
Country: true,
r: true,
["Gender Diff"]: true,
["GDP per capita (2023)"]: (d) => `$${d}`,
y: false,
x: false,
fill: false,
fillOpacity: false,
strokeOpacity: false
}
}
}),
Plot.crosshair(medal_data, {x: "GDP per capita (2023)", y: (d) => d[radioMapping[SelectedMedal]]})
],
color: {
type: "diverging-symlog",
scheme: "RdYlGn",
legend: true,
label: "More Male Medals More Female Medals",
pivot: 0,
symmetric: true
}
})