viz = {
now;
const end = (endTime || performance.now()) - timeDelay * 1000;
const start = Math.max(end - windowSecs * 1000);
return Plot.plot({
width,
marginLeft: 300,
y: {
axis: null,
domain: [
...events.reduce((acc, e) => (acc.add(e.name), acc), new Set())
].sort()
},
x: {
domain: [start, end],
type: "time"
},
color: {
domain: ["pending", "fulfilled", "rejected", "idle"],
range: ["#BBF", "#0F0", "#F44", "#EEE"]
},
marks: [
Plot.ruleY(
events,
Plot.selectLast({
z: "name",
y: "name",
stroke: "#EEE",
strokeDasharray: [2, 3]
})
),
Plot.barX(
events,
Plot.selectLast({
x1: start,
x2: start - 60 * 60 * 1000,
y: "name",
z: "name",
text: "name",
textAnchor: "end",
dx: -10,
fill: (d) =>
d.type === "pending" ? "pending" : end - d.t < 500 ? d.type : "idle"
})
),
Plot.tickX(events, {
x: "t",
y: "name",
stroke: "type",
strokeWidth: 2
}),
Plot.text(
events,
Plot.selectLast({
x: start,
y: "name",
z: "name",
text: (d) => d.name,
textAnchor: "end",
dx: -10,
fill: "black"
})
)
]
});
}