Published
Edited
Jun 21, 2018
Insert cell
Insert cell
Insert cell
Insert cell
x = d3.scaleLinear()
.domain(d3.extent(data, d => d.cos))
.range([margin.left, width - margin.right])
Insert cell
y = d3.scaleLinear()
.domain(d3.extent(data, d => d.cos))
.range([height - margin.bottom, margin.top])
Insert cell
xAxis = g => g
.attr("transform", `translate(0,${(height - margin.bottom)})`)
.call(d3.axisBottom(x)
.ticks(width / 80)
.tickSizeOuter(0))
Insert cell
yAxis = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
.call(g => g.select(".domain").remove())
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = [...Array(sides).keys()].map((step) => {
return {
cos: Math.cos(stepAngle*step),
sin: Math.sin(stepAngle*step),
cosSqSinSq: Math.cos(stepAngle*step)**2 + Math.sin(stepAngle*step)**2,
}
})
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