Skip to content

Commit

Permalink
Find an intelligible way to display fields of requests
Browse files Browse the repository at this point in the history
Refs: #13
  • Loading branch information
erkannt committed Jun 26, 2024
1 parent 683b752 commit 9f97eaf
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const openAlexFields = FileAttachment('./data/openalex-fields.json')
```

```js
const requestsByField = requests.flatMap(({ fields, ...request }) => fields.map(field => ({ ...request, field })))
const requestsByField = requests.flatMap(({ fields, ...request }) => fields.map(field => ({ ...request, field: openAlexFields[field] })))
```

<div class="grid grid-cols-4">
Expand Down Expand Up @@ -70,29 +70,27 @@ function requestsByLanguageTimeline({ width } = {}) {
```js
function requestsByFieldTimeline({ width } = {}) {
return Plot.plot({
title: 'Requests per week',
title: 'Fields of requests (request may have multiple fields)',
width: Math.max(width, 600),
height: 400,
color: {
legend: true,
type: 'ordinal',
},
marginLeft: 300,
color: { legend: true },
y: { grid: true, label: 'Requests' },
x: { label: '' },
marks: [
Plot.rectY(
requestsByField,
Plot.binX(
{ y: 'count' },
Plot.barX(
requestsByField,
Plot.groupY(
{
x: 'timestamp',
interval: d3.utcWeek,
fill: 'field',
tip: true,
x: 'count',
},
),
{
y: 'field',
fill: 'language',
sort: {y:'x', reverse: true}
},
)
),
Plot.ruleY([0]),
],
})
}
Expand Down

0 comments on commit 9f97eaf

Please sign in to comment.