2017-08-24 09:36:41 +00:00
|
|
|
<template>
|
|
|
|
<div class="bar-chart">
|
2018-11-24 18:49:19 +00:00
|
|
|
<BarChart :data="barChartData" :options="{ maintainAspectRatio: false }" />
|
2017-08-24 09:36:41 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import moment from 'moment'
|
2019-06-25 10:01:58 +00:00
|
|
|
import BarChart from '~/components/bar-chart'
|
2017-08-24 09:36:41 +00:00
|
|
|
|
|
|
|
export default {
|
2019-02-26 09:41:30 +00:00
|
|
|
components: {
|
|
|
|
BarChart
|
|
|
|
},
|
2020-04-13 18:41:34 +00:00
|
|
|
async asyncData ({ env, $http, $dayjs }) {
|
|
|
|
const stats = await $http.$get('https://api.github.com/repos/nuxt/nuxt.js/stats/commit_activity', {
|
|
|
|
headers: {
|
|
|
|
Authorization: `token ${env.githubToken}`
|
|
|
|
}
|
|
|
|
})
|
2017-08-24 09:36:41 +00:00
|
|
|
return {
|
|
|
|
barChartData: {
|
2020-04-13 18:41:34 +00:00
|
|
|
labels: stats.map(stat => moment(stat.week * 1000).format('GGGG[-W]WW')),
|
2017-08-24 09:36:41 +00:00
|
|
|
datasets: [
|
|
|
|
{
|
|
|
|
label: 'Nuxt.js Commit Activity',
|
2020-04-13 18:41:34 +00:00
|
|
|
backgroundColor: '#41B38A',
|
|
|
|
data: stats.map(stat => stat.total)
|
2017-08-24 09:36:41 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2017-08-24 10:16:12 +00:00
|
|
|
<style scoped>
|
2017-08-24 09:36:41 +00:00
|
|
|
.bar-chart {
|
|
|
|
width: 80%;
|
|
|
|
height: 80%;
|
2020-04-13 18:41:34 +00:00
|
|
|
margin: auto;
|
|
|
|
margin-top: 30px;
|
2017-08-24 09:36:41 +00:00
|
|
|
}
|
|
|
|
</style>
|