Skip to content

Commit 70b78d5

Browse files
committed
Added chart component
1 parent 19c92da commit 70b78d5

File tree

5 files changed

+82
-3
lines changed

5 files changed

+82
-3
lines changed

nuxt.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ module.exports = {
3737
/*
3838
** Customize the progress-bar color
3939
*/
40-
loading: '~/components/Loader/index.vue',
40+
loading: {
41+
color: '#ffa500',
42+
height: '2px'
43+
},
4144

4245
/*
4346
** Global CSS
@@ -55,6 +58,13 @@ module.exports = {
5558
'@nuxtjs/google-gtag'
5659
],
5760

61+
/*
62+
** Plugins
63+
*/
64+
plugins: [
65+
{ src: '~/plugins/vue-chartjs.js', mode: 'client' }
66+
],
67+
5868
/*
5969
** Axios configuration
6070
*/

package-lock.json

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
"@nuxtjs/pwa": "^3.0.0-beta.20",
2525
"animated-number-vue": "^1.0.0",
2626
"babel-runtime": "^6.26.0",
27+
"chart.js": "^2.9.3",
2728
"cross-env": "^5.2.0",
2829
"mapbox-gl": "^1.8.1",
2930
"mapbox-gl-vue": "^2.0.4",
30-
"nuxt": "^2.11.0"
31+
"nuxt": "^2.11.0",
32+
"vue-chartjs": "^3.5.0"
3133
},
3234
"devDependencies": {
3335
"@babel/core": "^7.8.4",

pages/index.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@ export default {
115115
})
116116
}, 800)
117117
}
118-
}
118+
},
119+
mounted() {
120+
this.$nextTick(() => {
121+
this.$nuxt.$loading.start()
122+
setTimeout(() => this.$nuxt.$loading.finish(), 500)
123+
})
124+
},
119125
}
120126
</script>
121127

plugins/vue-chartjs.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Vue from 'vue'
2+
import { Line } from 'vue-chartjs'
3+
4+
Vue.component('LineChart', {
5+
extends: Line,
6+
props: [ 'chartdata', 'options' ],
7+
mounted() {
8+
this.renderChart(this.chartdata, this.options)
9+
}
10+
})

0 commit comments

Comments
 (0)