Public
Edited
Jan 22, 2024
3 forks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data
Insert cell
Insert cell
isBadCereal = d => d['rating'] < 50
Insert cell
data[1].rating
Insert cell
data[3].rating
Insert cell
isBadCereal(data[1]) // should be true
Insert cell
isBadCereal(data[3]) // should be false
Insert cell
Insert cell
Insert cell
data.sort( (d1, d2) => d1.calories - d2.calories)
Insert cell
Insert cell
Insert cell
data
Insert cell
viewof aq_data = aq.from(data).view(5)
Insert cell
Insert cell
aq_data.filter(currentElement => currentElement.type === 'H').view()
Insert cell
Insert cell
aq_data.filter(currentElement => currentElement.type === 'H').objects()
Insert cell
Insert cell
aq_data.filter(d => favoriteBrands.has(d.mfr)).objects()
Insert cell
aq_data.filter(aq.escape(d => favoriteBrands.has(d.mfr))).objects()
Insert cell
Insert cell
aq_data.array('sodium')
Insert cell
Insert cell
viewof aq_cleaned = aq_data
.derive({type: currentElement => currentElement.type === "H" ? "hot" : "cold",
brand: aq.escape(currentElement => abbreviationToBrandName[currentElement.mfr])})
.select('name', 'rating', 'type', 'shelf', 'brand')
.view({height:150})
Insert cell
Insert cell
Insert cell
Insert cell
aq_cleaned
.filter(d => d.brand === 'Kelloggs' || d.brand === 'General Mills')
.orderby('rating')
.slice(0,3)
.array('name')
Insert cell
Insert cell
aq_cleaned.view(5)
Insert cell
Insert cell
Insert cell
d3.extent(data, d => d.calories)
Insert cell
Insert cell
Insert cell
d3.median(data, d => d.rating)
Insert cell
Insert cell
Insert cell
Insert cell
// write answer here
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
visualizeTicks(d3.scaleLinear().domain([0, 10]))
Insert cell
visualizeTicks(d3.scaleLinear().domain([32, 212]))
Insert cell
visualizeTicks(d3.scaleLinear().domain([32, 212]).nice())
Insert cell
import {x, y, scores} from "@nyuvis/d3-introduction"
Insert cell
Insert cell
// scores.map(d => write answer here)
Insert cell
Insert cell
Insert cell
// scores.map(d => write answer here)
Insert cell
Insert cell
Insert cell
// write answer here
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require("d3@7")
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