{
let plt1, plt2, plt3;
let theory = option.startGap,
real = d3.mean(passengers, (d) => d.waits);
plt1 = Plot.plot({
title: `Waits shorter than theory, ${real.toFixed(2)} | ${theory.toFixed(
2
)}`,
width: 600,
height: 300,
x: { nice: true },
y: { nice: true },
color: { legend: true, scheme: "Reds" },
grid: true,
marks: [
Plot.barY(
passengers,
Plot.binX({ y: "count", fill: "count" }, { x: "waits" })
),
Plot.ruleX([theory], { stroke: "blue" }),
Plot.ruleX([real], { stroke: "red" })
]
});
plt2 = Plot.plot({
title: "Latter station takes longer waiting",
marginTop: 32,
marginBottom: 28,
width: 600,
height: 340,
x: { nice: true },
y: { nice: true },
color: { legend: true },
grid: true,
marks: [
Plot.boxY(passengers, { x: "station", y: "waits" }),
Plot.ruleY([d3.mean(passengers, (d) => d.waits)], { stroke: "blue" }),
Plot.linearRegressionY(passengers, {
x: "station",
y: "waits",
stroke: "red",
fill: "red",
tip: true
})
]
});
plt3 = Plot.plot({
title: "Slower bus takes more",
width: 1200,
height: 400,
x: { nice: true },
y: { nice: true },
grid: true,
marks: [
Plot.dot(summary, { x: "costs", y: "count" }),
Plot.linearRegressionY(summary, {
x: "costs",
y: "count",
stroke: "red",
fill: "red",
tip: true
}),
Plot.ruleY([d3.mean(summary, (d) => d.count)], { stroke: "blue" })
]
});
return htl.html`
<div style="display:flex">
${plt1}
${plt2}
</div>
${plt3}
`;
}