chart = Plot.plot({
marks: [
Plot.dot(penguins, {
x: "body_mass_g",
y: "species",
tip: {
channels: { name: (_, i) => `${i}^2 = ` },
render(index, scales, values, dimensions, context, next) {
const g = next(index, scales, values, dimensions, context);
(async () => {
for (const i of index) {
values.channels.name.value[i] = await getTipAsync(i);
}
for (const tspan of g.querySelectorAll("text>tspan"))
tspan.remove();
for (const tspan of next(
index,
scales,
values,
dimensions,
context
).querySelectorAll("text>tspan")) {
g.querySelector("text").append(tspan);
}
})();
return g;
}
}
})
]
})