plot = Plot.plot({
inset: 10,
margin: 10,
marginLeft: 40,
marginTop: 100,
grid: true,
width: 1152,
height: 1800,
x: {
axis: null
},
y: {
label: null,
ticks: d3.range(3, 24).map(h => h * 60),
tickFormat: asTime,
transform: asMinutes,
reverse: true
},
color: {
legend: true,
domain: ["normal", "limited", "bullet"],
range: ["rgb(34, 34, 34)", "rgb(183, 116, 9)", "rgb(192, 62, 29)"]
},
marks: [
Plot.ruleX(trains, Plot.groupX({}, {x: "distance", strokeOpacity: 0.1, strokeDasharray: 2})),
Plot.text(trains, Plot.groupX({text: "first", y: () => "4:30am"}, {x: "distance", text: "station", rotate: -90, frameAnchor: "left", dy: -12})),
Plot.line(trains, {filter: d => d.schedule === schedule, x: "distance", y: "time", z: "train", stroke: "speed", marker: "circle", title: (d) => `${d.train}${d.direction}\n${d.station}\n${d.time}`, tip: true})
]
})