p = Plot.plot({
y: {
type: 'band',
label: null
},
marks: [
Plot.line(data, {
x: 'time',
y: 'line_id',
z: 'line_id',
stroke: 'ae'
}),
Plot.axisY({color: 'transparent'}),
Plot.dot(
data, {
x: "time",
y: "line_id",
fill: d => colorScale(d.ae),
stroke: d => colorScale(d.ae),
symbol: d => d.AESER_NEW === "Serious Event" ? starshape : 'circle'
}),
Plot.dot(
data,
{
x: "time",
y: "line_id",
fill: 'transparent',
stroke: 'none',
r: 20,
render: (index, scales, values, dimensions, context, next) => {
const g = next(index, scales, values, dimensions, context, next);
const children = d3.select(g).selectChildren();
children
.on("click", function (event, i) {
mutable datum = data[i];
})
.on('mousemove', function(event, i) {
toolTip.style("left", event.pageX + 18 + "px")
.style("top", event.pageY + 18 + "px")
.style("display", "block")
.html(
`
Tooltip for <strong>${data[i].time}</strong>
`
);
d3.select(event.target).style("cursor", "pointer");
})
.on('mouseout', function(event, d) {
toolTip.style("display", "none");
d3.select(event.target).style("cursor", "default");
})
return g;
}
}),
Plot.tip({fontSize: 20})
]
})