Plot.plot({
width: Math.min(800, width),
height: 400,
marginTop: 40,
style: {
fontSize: 12
},
caption: "Uitgifte: 2020-07-06 17:20:00",
x: {
insetLeft: 16,
type: 'time',
grid: true,
domain: [ new Date("2020-07-04T17:10Z"), new Date("2020-07-07T17:10Z")],
nice: false,
ticks: 5,
tickFormat: timeFormat,
},
y: {
grid: true,
label: "↑Windsnelheid (m/s)",
domain: [0, 25],
insetBottom: 40
},
marks: [
Plot.rect(beaufort, {insetRight: Math.min(800, width) - 16 - 60 , y1: "l", y2: "u", fill: "c", clip: true }),
Plot.line(timeseries, {x: "time", y: "forecast", stroke: "rgb(185, 1, 1)", strokeDasharray: "2, 2" } ),
Plot.line(timeseries, {x: "time", y: "speed", stroke: "rgb(1, 120, 202)"}),
Plot.line(timeseries, {x: "time", y: "squall", stroke: "rgb(82, 184, 254)"}),
Plot.vector(timeseries, {filter: d => (d.time.getHours() % 2) === 0 && d.time.getMinutes() === 0 && d.time > new Date("2020-07-06T15:20:00Z") , x: "time", dy: (400 -30 -40)/ 2 - 20, rotate: d => d.forecastDirection + 180, stroke: "rgb(185, 1, 1)"}),
Plot.vector(timeseries, {filter: d => (d.time.getHours() % 2) === 0 && d.time.getMinutes() === 0 && d.time <= new Date("2020-07-06T15:20:00Z"), x: "time", dy: (400 -30 -40)/ 2 - 20,rotate: d => 180 + d.direction, stroke: "rgb(1, 120, 202)"}),
Plot.text(beaufort, { y: "m", dx: - ( Math.min(800, width) - 60) / 2 + 8, clip: true, fontSize: 11 }),
Plot.ruleX([ new Date("2020-07-06T15:20:00Z")], { stroke: 'purple', dashArray: "2 2" }),
Plot.ruleY([0]),
]
})