Published
Edited
Apr 9, 2020
Insert cell
Insert cell
{
const src = `svg = DOM.svg(width, 200);
let text = d3.select(svg).selectAll("text")
.data([src])
.enter()
.append("text");
text.selectAll("tspan.text")
.data(d => d.split("\\n"))
.enter()
.append("tspan")
.attr("style", "font-size:12px")
.text(d => d)
.attr("xml:space", "preserve")
.attr("x", 0)
.attr("dy", 12);
`;

svg, DOM, d3, width; // make variables global so eval can read/write them

eval(src);

return svg;
}
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