Published
Edited
Mar 1, 2022
Importers
10 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function autoBBox(rect, elt) {
const dims = getBBox(elt);
setRect(rect, dims);
}
Insert cell
function getBBox(elt) {
const clonedElt = elt.clone(true);
const svg = d3.create('svg');
svg.node().appendChild(clonedElt.node());
document.body.appendChild(svg.node());
const { x, y, width, height } = clonedElt.node().getBBox();
document.body.removeChild(svg.node());
return { x, y, width, height };
}
Insert cell
function setRect(rect, dims) {
rect
.attr('x', dims.x)
.attr('y', dims.y)
.attr('width', dims.width)
.attr('height', dims.height);
}
Insert cell
import { PINNED } from '@mootari/toolbox'
Insert cell
d3 = require('d3')
Insert cell
Insert cell
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