chart = Plot.plot({
marginLeft: 100,
height: 556,
width: 1152,
marginTop: 556 - chartHeight,
axis: null,
x: { axis: "bottom" },
y: { domain: [0, step] },
color: {
type: "ordinal",
range: scheme,
label: "Vehicles per hour",
tickFormat: (i) => ((i + 1) * step).toLocaleString("en"),
legend: true
},
marks: [
d3.range(bands).map((i) =>
Plot.areaY(data, {
x: (d) => d[0],
y: (d) => (i % 2 ? step - d[1] + i * step : d[1] - i * step),
y2: (d) => (i % 2 ? step : 0),
fill: i,
stroke: i % 2 ? "red" : "blue",
clip: true
})
),
Plot.axisY({ ticks: chartHeight / 40 }),
Plot.axisY({ dx: -40, tickFormat: (d) => step * 2 - d }),
Plot.axisY({ dx: -80, tickFormat: (d) => step * 2 + d })
]
})