Created
January 29, 2021 20:45
-
-
Save kirkshoop/722aac04d5b9c4152c2bd65954e91818 to your computer and use it in GitHub Desktop.
distribution of executive orders across days of the year
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
{ | |
"$schema": "https://vega.github.io/schema/vega-lite/v4.json", | |
"data": { "url": "https://www.federalregister.gov/api/v1/documents.json?conditions%5Bcorrection%5D=0&conditions%5Bpresidential_document_type%5D=executive_order&conditions%5Btype%5D%5B%5D=PRESDOCU&fields%5B%5D=citation&fields%5B%5D=document_number&fields%5B%5D=president&fields%5B%5D=type&fields%5B%5D=subtype&fields%5B%5D=publication_date&fields%5B%5D=signing_date&fields%5B%5D=title&fields%5B%5D=effective_on&fields%5B%5D=executive_order_number&per_page=1200", "format": { "type": "json", "property": "results"}}, | |
"transform": [ | |
{ "filter": "year(datum.publication_date) > 1996"}, | |
{ | |
"joinaggregate": [{ | |
"op": "min", | |
"field": "publication_date", | |
"as": "firstYear" | |
}], | |
"groupby": [ | |
"president.name" | |
] | |
}, | |
{ | |
"calculate": "dayofyear(datum.publication_date)", | |
"as": "dayInYear" | |
}, | |
{ | |
"calculate": "year(datum.publication_date)-year(datum.firstYear) + 1", | |
"as": "yearInOffice" | |
}, | |
{ | |
"calculate": "ceil(datum.yearInOffice/4) + (month(datum.publication_date) == 0 && datum.yearInOffice > 4 ? -1 : 0)", | |
"as": "term" | |
}, | |
{ | |
"calculate": "((datum.term - 1) * 4) + year(datum.firstYear)", | |
"as": "firstYearInTerm" | |
}, | |
{ | |
"calculate": "datum.president.name + ' (' + datum.firstYearInTerm + '-' + (datum.firstYearInTerm + 3) + ')'", | |
"as": "president_term" | |
}], | |
"width": {"step": 20}, | |
"mark": "tick", | |
"encoding": { | |
"x": { | |
"field": "dayInYear", | |
"type": "quantitative", | |
"title": "day in year" | |
}, | |
"y": { | |
"sort": {"field": "firstYear", "order": "descending"}, | |
"field": "president_term", | |
"type": "ordinal", | |
"title": "" | |
}, | |
"color": { | |
"field": "president.name", | |
"title": "" | |
} | |
}, | |
"config": { | |
"view": {"stroke": "transparent"}, | |
"axis": {"domainWidth": 1} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment