Published
Edited
Feb 16, 2021
1 fork
Importers
3 stars
Insert cell
Insert cell
FileAttachment("furniture@1.csv")
Insert cell
Insert cell
Insert cell
Insert cell
image = FileAttachment("original-plate-25.jpg").image()
Insert cell
color = d3.scaleOrdinal(d3.schemeCategory10)
Insert cell
ticks = scale.ticks(numTicks).slice(0, -1)
Insert cell
keys = data.map((d, i) => d.year)
Insert cell
numArcs = keys.length
Insert cell
// arcWidth=80

arcWidth = (chartRadius - arcMinRadius - numArcs * arcPadding) / numArcs
Insert cell
scale = d3.scaleLinear()
.domain([0, d3.max(data, d => d.value) * 1.1])
.range([0, 2 * PI])
Insert cell
arc = d3.arc()
.innerRadius((d, i) => getInnerRadius(i))
.outerRadius((d, i) => getOuterRadius(i))
.startAngle(0)
.endAngle((d, i) => scale(d))
Insert cell
function getInnerRadius(index) {
return arcMinRadius + (numArcs - (index + 1)) * (arcWidth + arcPadding);
}
Insert cell
function getOuterRadius(index) {
return getInnerRadius(index) + arcWidth;
}
Insert cell
function rad2deg(angle) {
return angle * 180 / PI;
}
Insert cell
function arcTween(d, i) {
let interpolate = d3.interpolate(0, d.value);
return t => arc(interpolate(t), i);
}
Insert cell
PI = Math.PI
Insert cell
arcMinRadius = 40
Insert cell
arcPadding = 10
Insert cell
labelPadding = -5
Insert cell
numTicks = 10
Insert cell
chartRadius = height/2
Insert cell
import {margin} from '@kellytall/day-one-a-line-chart'
Insert cell
height = 500
Insert cell
d3 = require("d3@6")
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