Public
Edited
Feb 2, 2023
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
getPointsForDates = {
const {width, height, margin } = sizes;
const scaleAngle = d3.scaleTime().domain(extentDays).range(extentAngles);
const scaleXByAngle = d3.scaleLinear().domain(extentAngles).range([margin, width - margin]);
const scaleYBySin = d3.scaleLinear().domain([-1,1]).range([height - margin, margin]);
return function(start, stop){
return d3.timeDay.range(start, d3.timeDay.offset(stop,1)).map(day => {
const angle = scaleAngle(day);
const x = scaleXByAngle(angle);
const y = scaleYBySin(Math.sin(angle));
const deltaX = -Math.sin(angle*2) * width / 40;
return [x + deltaX,y];
});
}
}
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