Public
Edited
Jan 29, 2024
Paused
4 forks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data
Insert cell
Insert cell
isBadCereal = // write function here
Insert cell
data[15].rating
Insert cell
isBadCereal(data[15]) // should be true
Insert cell
data[3].rating
Insert cell
isBadCereal(data[3]) // should be false
Insert cell
Insert cell
Insert cell
data.sort((a, b) => // write your answer here)
Insert cell
Insert cell
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
favoriteBrands
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
abbreviationToBrandName
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
aq_cleaned
.filter(d => d.brand === 'Kelloggs')
.orderby('rating')
.slice(0,3)
.array('name')
Insert cell
Insert cell
aq_cleaned.view(5)
Insert cell
Insert cell
Insert cell
// write answer here
Insert cell
Insert cell
Insert cell
// write answer here
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
visualizeTicks(d3.scaleLinear().domain([0, 10]))
Insert cell
Insert cell
visualizeTicks(d3.scaleLinear().domain([32, 212]))
Insert cell
visualizeTicks(d3.scaleLinear().domain([32, 212]).nice())
Insert cell
Insert cell
import {scores} from "@nyuvis/d3-introduction"
Insert cell
scores
Insert cell
x_width = 300
Insert cell
x = d3.scaleLinear()
.domain([0, d3.max(scores, d => d.score)])
.range([0, x_width])
Insert cell
visualizeTicks(x)
Insert cell
y_height = 100
Insert cell
y = d3.scaleBand()
.domain(scores.map(d => d.name))
.range([0, y_height])
.padding(0.2)
Insert cell
visualizeTicks(y)
Insert cell
Insert cell
// write code here
Insert cell
Insert cell
Insert cell
// write code here
Insert cell
Insert cell
Insert cell
// write code 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