40 lines
843 B
JavaScript
40 lines
843 B
JavaScript
$(document).ready(function() {
|
|
const data = [
|
|
{ year: 2010, count: 10 },
|
|
{ year: 2011, count: 20 },
|
|
{ year: 2012, count: 15 },
|
|
{ year: 2013, count: 25 },
|
|
{ year: 2014, count: 22 },
|
|
{ year: 2015, count: 30 },
|
|
{ year: 2016, count: 28 },
|
|
];
|
|
|
|
fetch('/api/stats/graph')
|
|
.then(response => response.json())
|
|
.then(response => {
|
|
console.log(response.datasets);
|
|
new Chart(
|
|
document.getElementById('graph_canvas'),
|
|
{
|
|
type: 'line',
|
|
data: {
|
|
datasets: response.datasets
|
|
},
|
|
options: {
|
|
scales: {
|
|
x: {
|
|
type: 'time'
|
|
}
|
|
},
|
|
parsing: {
|
|
xAxisKey: 'date',
|
|
yAxisKey: 'score'
|
|
}
|
|
}
|
|
|
|
}
|
|
);
|
|
});
|
|
|
|
});
|