Public
Edited
Jan 27, 2023
4 forks
34 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// recenters and resizes the original image
im = {
// loads the original image from File Attachments (alternatively, from the Museum’s resources)
// d3.image("https://ids.si.edu/ids/download?id=CHSDM-63710F2EF8B52-000001.jpg")
const im0 = await FileAttachment("CHSDM-63710F2EF8B52-000001.jpg").image();

const context = DOM.context2d(width, width);
const w2 = width * 1.015;
context.drawImage(
im0,
-width * 0.0055 - (w2 - width) / 2,
-width * 0.005,
w2,
width
);

if (control) {
context.strokeStyle = "red";
for (const r of [0.01, 0.26, 0.41, 0.465]) {
context.beginPath();
context.arc(width / 2, width / 2, width * r, 0, 2 * Math.PI);
context.stroke();
}
}
return Object.assign(context.canvas, {
style: `max-width: ${control ? width : 250}px`
});
}
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