Public
Edited
Feb 16, 2024
Paused
2 forks
Importers
9 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
f = d3.utcFormat("%B %d")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = {
const S = [];
yield S;
let pages = await fetch(`https://api.github.com/repos/${repo}/stargazers?per_page=100`, {
headers: {
...token && { Authorization: `token ${token}` },
accept: "application/vnd.github.v3.star+json" // necessary to get the starred_at field
}
}).then(d => [...d.headers].find(d => d[0] === "link")?.[1].split(/,/).pop().match(/&page=(\d+)/)?.[1] || 1);

mutable msg = `${pages} pages to load…`

for (const page of new Set([1, +pages].concat(d3.shuffle(d3.range(2, +pages))))) {
const s = await fetch(`https://api.github.com/repos/${repo}/stargazers?per_page=100&page=${page}`, {
headers: {
...token && { Authorization: `token ${token}` },
accept: "application/vnd.github.v3.star+json" // necessary to get the starred_at field
}
})
.catch(() => false) // network error, API limit
.then(d => d.json ? d.json() : false);

// error?
if (!s) return;
if (s.message) return mutable msg = s.message;
mutable msg = `${--pages} pages to load…`

s.forEach((u, i) => {
S.push({
login: u.user.login,
id: u.user.id,
date: new Date(u.starred_at),
count: 100 * (page - 1) + i + 1,
repo
});
});
S.sort((a, b) => a.count - b.count);
yield S;
await Promises.delay(150);
}
yield S;
}
Insert cell
events = repo === "observablehq/plot"
? [
{
date: new Date("2021-05-04"),
text: "Plot 0.1\nreleased",
count: 1300
},
{
date: new Date("2021-08-20"),
text: "Plot 0.2",
count: 1450
},
{
date: new Date("2021-12-04"),
text: "Plot 0.3",
count: 1650
},
{
date: new Date("2022-01-20"),
text: "Plot 0.4",
count: 1750
},
{
date: new Date("2022-06-07"),
text: "Plot 0.5",
count: 2050
},
{
date: new Date("2022-09-07"),
text: "Plot 0.6",
count: 2180
},
{
date: new Date("2022-12-12"),
text: "Plot 0.6.1",
count: 2450
},
{
date: new Date("2023-03-01"),
text: "Plot 0.6.4",
count: 2700
},
{
date: new Date("2023-04-26"),
text: "Plot 0.6.6",
count: 2950
},
{
date: new Date("2023-12-13"),
text: "Plot 0.6.13",
count: 3600
},
{
date: new Date("2024-02-15"),
text: "Framework 1.0\nreleased",
count: 3870
}
]
: []
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