{
const raw = d3.csvParse(
`arrival_time,EMME,EROAD
1_2,0.009517403732974609,0.00498960498960499
2_3,0.017655960988733815,0.0067235811916662985
3_4,0.02522280141247688,0.01012075905692927
4_5,0.032974609046578104,0.014101826867784314
5_6,0.04338321842946023,0.03199009156455965
6_7,0.053371447788801075,0.06418365992834078
7_8,0.058802757692954434,0.08530985977794489
8_9,0.06332604674625862,0.07890476401114699
9_10,0.06182949386245166,0.08016985889326315
10_11,0.06167815705397679,0.08411553943468837
11_12,0.06014797376828653,0.08218693325076304
12_13,0.060854212207835885,0.0830539213517937
13_14,0.06169497225491845,0.07768390321581811
14_15,0.06203127627375147,0.07590569292696953
15_16,0.06196401546998487,0.0683505109037024
16_17,0.05004203800235413,0.05243508647763967
17_18,0.05022700521271229,0.034520281328791966
18_19,0.049335799562804775,0.019560313177334455
19_20,0.04175214393812006,0.012589021099659398
20_21,0.03226837060702875,0.00952802229397974
21_22,0.021506642004371954,0.006856283452028133
22_23,0.013838910374978981,0.006254699871721148
23_24,0.0036825290062216243,0.00539655858804795
`,
d3.autoType
);
const data = aq
.from(raw)
.fold(["EMME", "EROAD"], { as: ["source", "value"] })
.derive({ arrival_time: (d) => aq.op.replace(d.arrival_time, "_", ":") })
.objects();
return Plot.plot({
style: {
fontSize: "12px",
color:"white",
background:"black"
},
marginTop: 30,
marginBottom: 50,
color: {
domain: ["EMME", "EROAD"],
legend: true
},
x: {
label: "Freight Departure Time",
transform: (time) => d3.timeParse("%H:%M %Z")(time + " +24"),
tickFormat: "%H:%M"
},
y: {
label: "↑ Proportion",
tickFormat: "p",
ticks: 6
},
marks: [
Plot.line(data, {
x: "arrival_time",
y: "value",
curve: "monotone-x",
stroke: "source"
}),
Plot.ruleY([0])
]
});
return data;
}