Plot.plot({
width,
height: 400,
label: null,
x: {
domain: [start, end],
axis: "top",
round: true,
ticks: {
range(start, end) {
return d3.utcWeek
.range(start, end)
.map((d) => d3.utcHour.offset(d, 12));
}
},
tickFormat: "%b %-d"
},
y: {
domain: byCountry.map((d) => d[1]),
grid: true
},
opacity: { type: "identity" },
marks: [
Plot.barX(d3.utcDay.range(start, end), {
interval: d3.utcDay,
fillOpacity: (d) => ((1 + d.getUTCDay()) % 7 < 2 ? 0.15 : 0.05)
}),
Plot.barX([today], {
interval: d3.utcDay,
fill: "yellow",
fillOpacity: 0.5
}),
Plot.barX(vacations, {
x1: "date_start",
x2: "date_end",
y: "name",
fill: "name",
inset: 0.5,
clip: true,
opacity: 0.75
}),
Plot.textX(holidaysPerPerson, {
y: "name",
x: "date_start",
interval: d3.utcDay,
text: (d) => {
switch (d.country) {
case 'IND':
return '🇮🇳';
case 'FRA':
return '🇫🇷';
case 'UK':
return '🇬🇧';
case 'USA':
return '🇺🇲';
default:
return '🇺🇳';
}
},
fontSize: 20,
title: (d) => `${d.holidayName}\n${d.country}`
}),
],
tooltip: {
fill: "red",
stroke: "blue",
r: 8
}
})