Trying to adjust the position of text based on where it would be placed… is it not possible to do this?
Plot.text(data, Plot.selectMaxY({
x: "time", y: "value",
text: d => `Observed Max: ${d.value}`,
dy: d => d.time < x_axis_midpoint ? -2 : 2,
dx: d => d.time < x_axis_midpoint ? 2 : -2,
textAnchor: d => d.time < x_axis_midpoint ? "start" : "end",
frameAnchor: "bottom",
fill: "red",
fontSize: label_size,
})),
When I try this, I literally get d => d.time < x_axis_midpoint ? "start" : "end", as the value of the text-anchor attribute.