Nuxt/examples/vue-chartjs/pages/index.vue
Clark Du b11e9c0e51
feat: upgrade eslint to 5.x (#3494)
- [ ] babel-eslint https://github.com/babel/babel-eslint/issues/664
- [x] eslint-config-standard-jsx https://github.com/standard/eslint-config-standard-jsx/issues/32
- [x] eslint-config-standard to be stable release https://github.com/standard/eslint-config-standard/issues/123
- [x] eslint-plugin-html
- [x] eslint-plugin-import
- [x] eslint-plugin-jest
- [x] eslint-plugin-node
- [x] eslint-plugin-promise
- [x] eslint-plugin-standard https://github.com/standard/eslint-plugin-standard/issues/29
- [x] eslint-plugin-vue https://github.com/vuejs/eslint-plugin-vue/pull/504
- [x] eslint-plugin-react https://github.com/yannickcr/eslint-plugin-react/releases/tag/v7.10.0
2018-08-31 21:34:12 +01:00

43 lines
915 B
Vue
Executable File

<template>
<div class="bar-chart">
<bar-chart :data="barChartData" :options="{ maintainAspectRatio: false }" />
</div>
</template>
<script>
import BarChart from '~/components/bar-chart'
import axios from 'axios'
import moment from 'moment'
export default {
async asyncData({ env }) {
const res = await axios.get(`https://api.github.com/repos/nuxt/nuxt.js/stats/commit_activity?access_token=${env.githubToken}`)
return {
barChartData: {
labels: res.data.map(stat => moment(stat.week * 1000).format('GGGG[-W]WW')),
datasets: [
{
label: 'Nuxt.js Commit Activity',
backgroundColor: '#41b883',
data: res.data.map(stat => stat.total)
}
]
}
}
},
components: {
BarChart
}
}
</script>
<style scoped>
.bar-chart {
position: fixed;
left: 10%;
top: 10%;
width: 80%;
height: 80%;
}
</style>