Published
Edited
Feb 22, 2021
2 forks
2 stars
Insert cell
Insert cell
Insert cell
commits = FileAttachment("vega-lite.json").json()
Insert cell
authors = d3.group(commits, d => d.author)
Insert cell
authorArray = Array.from(authors.keys())
Insert cell
chart = {
let height = 600;
let canvas = DOM.canvas(width, height);
let ctx = canvas.getContext("2d");

let radius = 2.5;

let xscale = d3
.scaleTime()
.domain(dateExtent)
.range([10, width - 10]);
commits.forEach(d => {
ctx.beginPath();
ctx.fillStyle = color(d.author);
ctx.arc(xscale(date(d)), yscale(d.author), radius, 0, Math.PI * 2);
ctx.fill();
});
return canvas;
}
Insert cell
color = d3
.scaleOrdinal()
.domain(authors.keys())
.range(d3.schemeCategory10)
Insert cell
yscale = d3
.scaleBand()
.domain(authorArray)
.range([10, 550])
Insert cell
yscale(authorArray[0])
Insert cell
dateExtent = d3.extent(commits, d => date(d))
Insert cell
date = d => timeParser(d.date)
Insert cell
timeParser = d3.timeParse("%Y-%m-%d %H:%M:%S %Z")
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