From 42471d297685fc357266d96fa8b07aa53c2ac758 Mon Sep 17 00:00:00 2001 From: Philip Durbin Date: Sat, 4 Jun 2022 08:56:47 -0400 Subject: [PATCH] add simple "installations per year" ascii chart #7 --- js/year.js | 32 ++++++++++++++++++++++++++++++++ year.html | 14 ++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 js/year.js create mode 100644 year.html diff --git a/js/year.js b/js/year.js new file mode 100644 index 0000000..edad669 --- /dev/null +++ b/js/year.js @@ -0,0 +1,32 @@ +let url = 'data/data.json'; +let byYear = {}; +let years = []; +fetch(url).then(function(response) { + response.text().then(function(text) { + obj = JSON.parse(text); + installations = obj.installations; + https: for (const installation of installations) { + let launch_year = installation.launch_year; + if (launch_year == undefined) { + launch_year = '????'; + } + if (byYear[launch_year] == undefined) { + byYear[launch_year] = []; + } + byYear[launch_year].push(installation.name); + } + var div = document.getElementById('yearid'); + div.innerHTML += 'Dataverse Installations by Year\n'; + for (const [key, value] of Object.entries(byYear)) { + let stars = ''; + for (installation of value) { + stars += '*'; + } + div.innerHTML += `${key} ` + stars + ` ${value.length}` + '\n'; + } + div.innerHTML += '\nInstallations with Unknown Launch Year\n'; + for (const unknown of byYear['????']) { + div.innerHTML += unknown + '\n'; + } + }); +}); diff --git a/year.html b/year.html new file mode 100644 index 0000000..4d8ea0e --- /dev/null +++ b/year.html @@ -0,0 +1,14 @@ + + + + Dataverse Installations by Year + + + + + + +
+ + +