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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more