GAPARROWSLAST = Plot.plot({
y: { label: null,
tickFormat: (d) => (`${tableAlias[0][d]}`),
tickSize: 0},
x: {
axis: "top",
grid: true,
label: `▬ Bars show DLS → Arrow shows gap | Ticks show regional avg.`,
domain: [0, 115],
ticks: 2,
tickFormat: (d) => (d === 100 ? `${d}%` : `${d}`),
tickSize: 10
},
axis: "right",
marginLeft: 10,
marginRight: 120,
marginTop: 50,
width : 700,
style: {fontSize: "14px"},
color: {
type: "categorical",
scheme: "Set2"
},
marks: [
Plot.text(countries_map.get(selected ? selected.ISO_3 : "AFG"), {x: 100, y: "gap_cat", fill: "black", text: d => parseFloat(d.gap_val).toFixed(1), dx: 40, textAnchor: "end"}),
Plot.arrow(countries_map.get(selected ? selected.ISO_3 : "AFG"), {
x1: d => 100 - (parseFloat(d.gap_val)).toFixed(1),
x2: 100,
y1: "gap_cat",
y2: "gap_cat",
bend: false,
stroke: d => d,
srokeWidth: 1.5
}),
Plot.barX(countries_map.get(selected ? selected.ISO_3 : "AFG"),{
x1: 0,
x2: d => 100 - (parseFloat(d.gap_val)).toFixed(1),
y: "gap_cat",
fill: d => d,
fillOpacity: 0.2,
insetTop: 1.25,
insetBottom: 1.25
}),
Plot.tickX(regions_map.get(selected ? selected.DLS_REGION_A3 : "SAS"), {
x: d => 100 - d.gap_val,
y: "gap_cat",
stroke: "red",
strokeWidth: 1,
insetTop: 0,
insetBottom: 0
}),
],
})