gimm260-data-visualization/testingStuff.html

53 lines
1.4 KiB
HTML
Raw Normal View History

2022-12-13 01:08:09 -07:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Testing</title>
<script type="module">
import * as d3 from "https://cdn.jsdelivr.net/npm/d3@7/+esm";
//const jsonData = d3.json("http://localhost:8888");
const jsonData = d3.json("gamedata.json");
jsonData.then(function (data){
//let dataset = data.reports;
processData(data);
});
function processData(data) {
let reportsPerMonth = [["2019-10",0]];
let index = 0;
let prevMonth = 10;
for(let i = 0; i < data.length; i++) {
let currentValue = new Date(data[i].timestamp * 1000);
let currentYear = currentValue.getFullYear();
let currentMonth = currentValue.getMonth() + 1;
if(currentMonth != prevMonth) {
prevMonth = currentMonth;
index++;
reportsPerMonth[index] = ["",0];
reportsPerMonth[index][0] = (currentYear.toString() + "-" + currentMonth.toString());
reportsPerMonth[index][1] = 0;
}
reportsPerMonth[index][1]++;
}
console.log(reportsPerMonth);
}
</script>
</head>
<body>
<div id="dataViz">
<svg width="1000" height="500"></svg>
</div>
</body>
</html>