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

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