Skip to content

Commit

Permalink
Show a map of user locations
Browse files Browse the repository at this point in the history
Refs #31
  • Loading branch information
thewilkybarkid committed Jul 11, 2024
1 parent d3a886f commit c9d0f50
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"@effect/platform": "^0.58.20",
"@effect/platform-node": "^0.53.19",
"@effect/schema": "^0.68.1",
"@geo-maps/countries-land-10km": "^0.6.0",
"@js-temporal/polyfill": "^0.4.4",
"@observablehq/framework": "^1.9.0",
"@vvo/tzdb": "^6.141.0",
Expand Down
33 changes: 30 additions & 3 deletions src/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ toc: false

# PREreviewers 🫅

```js
import countries from 'npm:@geo-maps/countries-land-10km'

Check failure on line 10 in src/users.md

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module 'npm:@geo-maps/countries-land-10km'
import i18nIsoCountries from 'npm:i18n-iso-countries'

Check failure on line 11 in src/users.md

View workflow job for this annotation

GitHub Actions / Lint

Unable to resolve path to module 'npm:i18n-iso-countries'
```

```js
const parseTimestamp = d3.utcParse('%Y-%m-%dT%H:%M:%SZ')

Expand Down Expand Up @@ -147,10 +152,32 @@ function usersByCareerStage({ width } = {}) {
```js
function usersByLocation() {
return Inputs.table(
usersInTimePeriod.flatMap(user => (user.location ? { location: user.location, country: user.country } : [])),
{ format: { country: regionNameWithFlag }, header: { country: 'Country', location: 'Location' }, sort: 'location' },
const colors = d3.rollup(
usersInTimePeriod.filter(user => user.country),
users => users.length,
user => user.country,
)

return Plot.plot({
projection: 'equal-earth',
width,
height: d3.min([700, width / 2]),
color: {
scheme: 'reds',
domain: [0, d3.max(colors.values())],
unknown: 'var(--theme-background-alt)',
type: 'linear',
label: 'PREreviewers',
legend: true,
},
marks: [
Plot.geo(countries(), {
fill: d => colors.get(i18nIsoCountries.alpha3ToAlpha2(d.properties.A3)),
stroke: 'var(--theme-foreground-muted)',
strokeWidth: 0.2,
}),
],
})
}
```
Expand Down

0 comments on commit c9d0f50

Please sign in to comment.