Published
Edited
Nov 29, 2020
Insert cell
Insert cell
Insert cell
Insert cell
songData = d3.csvParse(await FileAttachment("avg_registers.csv").text())
Insert cell
minRegister = Math.min(...songData.map(d => parseFloat(d.avg_register)))
Insert cell
yDomain = [7.5, 5]
Insert cell
minYear = Math.min(...songData.map(d => parseInt(d.year)))
Insert cell
maxYear = Math.max(...songData.map(d => parseInt(d.year)))
Insert cell
xDomain = [minYear, maxYear]
Insert cell
config = { return {
padLeft: 50,
width: width,
height: 300,
padTop: 10,
padBottom: 50,
padRight: 10,
audioRoot: 50,
rectWidth: 13,
rectHeight: 4
}
}
Insert cell
xScale = d3.scaleLinear()
.domain(xDomain)
.range([config.padLeft, config.width - config.padRight - config.rectWidth])
Insert cell
yScale = d3.scaleLinear()
.domain(yDomain)
.range([config.padTop, config.height - config.padBottom])
Insert cell
xAxis = d3.axisBottom(xScale)
.tickFormat(d3.format("d"))
Insert cell
yAxis = d3.axisLeft(yScale)
Insert cell
md`## Imports, etc`
Insert cell
d3 = require("d3@6")
Insert cell
html`
<style>
#chart-container {
position: relative;
height: ${config.height}px;
}
#chart-container svg, #chart-container canvas {
position: absolute;
}
</style>
`
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