commit da1f23c853a5bf6d8824abe29f393a9793533561 Author: Matt Huntington Date: Wed Jan 25 19:19:30 2017 -0500 basic app diff --git a/app.js b/app.js new file mode 100644 index 0000000..94ce420 --- /dev/null +++ b/app.js @@ -0,0 +1,41 @@ +window.onload = function(){ + var ctx = document.querySelector('#runs'); + + var chartData = { + labels: [], + datasets: [] + }; + + fetch('http://localhost:3000/users/').then(function(response){ + response.json().then(function(data){ + data.forEach(function(user, index){ + var newUserObj = { + label: "Runs for " + user.name, + data: [] + }; + user.runs.forEach(function(run){ + var date = new Date(run.date); + newUserObj.data.push({ + // x: date.toLocaleString(), + x: date, + y: run.distance + }); + }) + chartData.datasets.push(newUserObj); + }); + + var runsChart = new Chart(ctx, { + type: 'line', + data: chartData, + options: { + scales: { + xAxes: [{ + type: 'time', + position: 'bottom' + }] + } + } + }); + }); + }) +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..a4aeb2d --- /dev/null +++ b/index.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + +