Published
Edited
Jan 20, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
data = await FileAttachment("courses.csv").csv()
Insert cell
Insert cell
// Detect the minmum course number for a slider
minCourseNum = d3.min(data, d => +d.number.substring(5))
Insert cell
// Detect the maximum course number for a slider
maxCourseNum = d3.max(data, d => +d.number.substring(5))
Insert cell
Insert cell
Insert cell
chart_data = data.filter(d => {
const num = +d.number.substring(5);
return num >= minValue && d.description.includes(search);
})
Insert cell
Insert cell
Insert cell
Insert cell
chart = {
let course_list;
// If this is the first time rendering the cell, create and position the svg, axes, and title
if (!this) {
course_list = d3.create('ul');
} else {
course_list = d3.select(this);
}

// Performa a data join
const courses = course_list
.selectAll('li')
.data(chart_data, d => d.number) // identify each observation by course number
.join(
enter => enter.append('li').style('color', 'steelblue'), // append, set starting color
update =>
update
.transition() // transition to black for updated elements
.duration(1500)
.style("color", "black"),
exit =>
exit
.style("color", "red")
.transition()
.duration(500)
.style('opacity', 0)
.remove()
)
.text(d => d.number + ": " + d.description);

return course_list.node();
}
Insert cell
Insert cell
d3 = require('d3@5')
Insert cell
import { slider, text } from "@jashkenas/inputs"
Insert cell
import { displayCaution } from "@info474/utilities"
Insert cell
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