Published unlisted
Edited
Oct 4, 2022
Insert cell
Insert cell
Insert cell
scatter_plot_with_image_tooltips = {
let plot = Plot.plot({
marks: [
Plot.dot(favorability, {
fill: "black",
x: "First Inauguration Date",
y: (d) => metric.value(d) / 100,
title: (d, i) => i
})
]
});

d3.select(plot)
.selectAll("circle")
.nodes()
.forEach(function (c) {
let idx = parseInt(d3.select(c).select("title").text());
let p = favorability[idx];
let content = `<div><h2>${p.Name}</h2><img src="${p["Portrait URL"]}"></div>`;
console.log(content);
tippy(c, {
content: content,
theme: "light",
allowHTML: true
});
d3.select(c).select("title").remove();
});

return plot;
}
Insert cell
tippy = require("tippy.js@6")
Insert cell
tippy_style = html`<div style="display: none"><link rel="stylesheet" href="${await require.resolve(
`tippy.js/themes/light.css`
)}"></div>`
Insert cell
favorability = FileAttachment("us-president-favorability.csv").csv({
typed: true
})
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more