Published unlisted
Edited
Sep 30, 2021
7 forks
Insert cell
Insert cell
{
// Create a square <svg> 128px by 128px.
const svg = d3.create("svg").attr("width", 128).attr("height", 128);
// Add a circle
const circle = svg.append("circle")
.attr("r", 128);
// Return the SVG to the notebook so it gets added to the DOM
return svg.node();
}
Insert cell
Insert cell
{
// Create a square <svg> width-by-height px.
const svg = d3.create("svg").attr("width", width).attr("height", height);

// Add a light gray rect as background so we can see the size of the SVG
svg.append("rect").attr("width", width).attr("height", height).attr("fill", "#f0f0f0");

// Add a circle with position attributes cx and cy
const circle = svg.append("circle")
.attr("r", height / 2);

// Position the circle
circle.attr("cx", dx + height / 2)
.attr("cy", height / 2);
// Return the SVG to the notebook so it gets added to the DOM
return svg.node();
}
Insert cell
viewof dx = Inputs.range([0, width - height])
Insert cell
height = 128;
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