Published
Edited
Dec 31, 2019
Insert cell
Insert cell
{
const boxHeight = 200;
const circleX = 100;
const circleY = boxHeight / 2;
const radius = 40;
const lineLength = 200;
const lineStart = [circleX + radius, circleY];
const lineEnd = [lineStart[0] + lineLength, circleY];

const svg = d3.create('svg').attr('viewBox', [0, 0, width, boxHeight]);

svg
.append('circle')
.attr('cx', circleX)
.attr('cy', circleY)
.attr('r', radius)
.style('fill', 'green');

svg
.append('path')
.attr('d', d3.line()([lineStart, lineEnd]))
.attr('stroke', 'black')
.attr('fill', 'none');

return svg.node();
}
Insert cell
d3 = require('d3')
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