Skip to content

Commit

Permalink
add simple "installations per year" ascii chart #7
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jun 4, 2022
1 parent 9a67786 commit 42471d2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
32 changes: 32 additions & 0 deletions js/year.js
Original file line number Diff line number Diff line change
@@ -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';
}
});
});
14 changes: 14 additions & 0 deletions year.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Dataverse Installations by Year</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<pre><div id="yearid"></div></pre>
<script src="js/year.js"></script>
</body>
</html>

0 comments on commit 42471d2

Please sign in to comment.