Public
Edited
Jun 5, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = d3.csvParse(
await FileAttachment("data_by_artist.csv").text(),
d3.autoType
)
Insert cell
Insert cell
Insert cell
scale = {
const x = d3
.scaleLinear()
.domain(d3.extent(data, (d) => d.danceability))
.nice()
.range([margin.left, width - margin.right]);

const y = d3
.scaleLinear()
.domain(d3.extent(data, (d) => d[Channel]))
.nice()
.range([height - margin.bottom, margin.top]);

const c = d3
.scaleLinear()
.domain(d3.extent(data, (d) => d.danceability))
.nice()
.range(["#F20505", "#024059"]);

return { x: x, y: y, c: c };
}
Insert cell
Insert cell
xAxis = (g) =>
g
.attr("class", "x-axis")
.attr("transform", `translate(0, ${margin.top})`)
.call(
d3
.axisTop(scale.x)
.tickValues([0.2, 0.4, 0.6, 0.8])
.tickFormat(formatNumber)
)
Insert cell
yAxis = (g) =>
g
.attr("class", "y-axis")
.attr("transform", `translate(${width - margin.right},0)`)
.call(d3.axisLeft(scale.y).ticks(4).tickFormat(formatNumber))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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