-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show the number of new users over time
Refs #31
- Loading branch information
1 parent
77ed715
commit fdeef4e
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
theme: dashboard | ||
title: PREreviewers | ||
toc: false | ||
--- | ||
|
||
# PREreviewers 🫅 | ||
|
||
```js | ||
const parseTimestamp = d3.utcParse('%Y-%m-%dT%H:%M:%SZ') | ||
|
||
const users = FileAttachment('./data/users.json') | ||
.json() | ||
.then(data => data.map(user => ({ ...user, timestamp: parseTimestamp(user.timestamp) }))) | ||
``` | ||
|
||
```js | ||
const now = new Date() | ||
const firstUser = d3.min(users, user => user.timestamp) | ||
``` | ||
|
||
<div class="grid grid-cols-4"> | ||
<div class="card"> | ||
<h2>PREreviewers</h2> | ||
<span class="big">${users.length.toLocaleString("en-US")}</span> | ||
</div> | ||
</div> | ||
|
||
```js | ||
console.log(users) | ||
function usersTimeline({ width } = {}) { | ||
return Plot.plot({ | ||
title: 'PREreviewers joining per month', | ||
width: Math.max(width, 600), | ||
height: 400, | ||
y: { grid: true, label: 'PREreviewers', tickFormat: Math.floor, interval: 1 }, | ||
x: { | ||
label: '', | ||
domain: [d3.utcMonth.floor(firstUser), d3.utcMonth.ceil(now)], | ||
}, | ||
marks: [ | ||
Plot.rectY( | ||
users, | ||
Plot.binX( | ||
{ y: 'count' }, | ||
{ | ||
x: 'timestamp', | ||
interval: d3.utcMonth, | ||
tip: true, | ||
}, | ||
), | ||
), | ||
], | ||
}) | ||
} | ||
``` | ||
|
||
<div class="grid grid-cols-1"> | ||
<div class="card"> | ||
${resize((width) => usersTimeline({width}))} | ||
</div> | ||
</div> |