Published
Edited
May 14, 2022
Importers
Insert cell
Insert cell
demo = toolTipper(
html`<img src="https://picsum.photos/400/300" height=300 />`,
(x, y) => `tooltip: ${x},${y}`
)
Insert cell
function toolTipper(element, contentFunc = (x, y) => "", props = {}) {
const parent = htl.html`<div>`;
Object.assign(parent.style, {
position: "relative",
display: "inline-flex"
});
parent.append(element);
Object.assign(props, {
followCursor: true,
allowHTML: true,
content: contentFunc(0, 0)
});
const instance = tippy(parent, props);
element.onmousemove = element.onmouseenter = (e) => {
instance.setContent(contentFunc(e.offsetX, e.offsetY));
};
return parent;
}
Insert cell
tippy = require("tippy.js@6")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more