Public
Edited
Mar 10, 2023
Insert cell
Insert cell
numbers = [5,8,3,6,9,10]
Insert cell
names = ["Eric", "Michelle", "Tina"]
Insert cell
Insert cell
viz = d3.select(mySVG)
Insert cell
boxes = viz.selectAll("rect") //select all things inside viz and find any rectangles
.data(numbers) //binds the visual to numbers (the data)
.join("rect") // above 3 lines create 3 rectangles
.attr("width", d => d*10) // d => data; for loop
.attr("height", d=> d*10)
.attr("x", (d,i) => i*100) // i => index; spaces the elements 50 pixels apart
.attr("y", 20)
.style("opacity", 0.5)

Insert cell
label = viz.selectAll("text") //creates text objects from dataset
.data(names)
.join("text")
.text(d => d)
.attr("x", (d,i) => i*100)
.attr("y", 15)

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