From 455d501dd37fb528869fcbffecbd56c76db0fb3a Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Tue, 2 Jul 2024 16:40:22 +0100 Subject: [PATCH] Make the labels easier to read by using the server names Refs #28 --- src/reviews.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/reviews.md b/src/reviews.md index 86d9579..dd0eeda 100644 --- a/src/reviews.md +++ b/src/reviews.md @@ -11,6 +11,7 @@ const parseDate = d3.utcParse('%Y-%m-%d') const languageNames = new Intl.DisplayNames(['en-US'], { type: 'language' }) const languageName = code => (code ? languageNames.of(code) : 'Unknown') +const preprintServers = FileAttachment('./data/preprint-servers.json').json() const reviews = FileAttachment('./data/reviews.json') .json() .then(data => data.map(review => ({ ...review, createdAt: parseDate(review.createdAt) }))) @@ -19,6 +20,8 @@ const reviews = FileAttachment('./data/reviews.json') ```js const now = new Date() const firstReview = d3.min(reviews, review => review.createdAt) + +const preprintServerName = id => preprintServers[id] ``` ```js @@ -121,7 +124,7 @@ function reviewsByPreprintServer({ width } = {}) { y: { label: '' }, marks: [ Plot.barX( - reviewsSelected, + reviewsSelected.map(review => ({ ...review, server: preprintServerName(review.server) })), Plot.groupY( { x: 'count', @@ -140,7 +143,7 @@ function reviewsByPreprintServer({ width } = {}) { }, ), ), - Plot.axisY({ lineWidth: 15, marginLeft: 100 }), + Plot.axisY({ lineWidth: 15, marginLeft: 115 }), ], }) }