Published
Edited
Feb 16, 2018
1 star
Insert cell
Insert cell
svg = {
var svg = d3.select(DOM.svg(width, height));

svg.append("text")
.text("Hello World");

return svg.node();
}
Insert cell
function scaleTextToFit(text, width, height) {
var bbox = text.node().getBBox(),
widthScale = width / bbox.width,
heightScale = height / bbox.height,
scale = widthScale < heightScale ? widthScale : heightScale;
text.attr("transform", `translate(0, ${height}) scale(${scale})`);
}
Insert cell
d3.select(svg).selectAll("text").call(scaleTextToFit, width, height)
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