Skip to content

Commit

Permalink
Update Chartjs.vue
Browse files Browse the repository at this point in the history
Added support for plugins
  • Loading branch information
ruimgoncalves authored and fundon committed Aug 4, 2017
1 parent 65ee0bc commit 176929c
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/Chartjs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ export default {
options: {
type: Object,
default: () => ({})
},
plugins: {
type: [Object, Array],
default: () => ({})
}
},
mounted () {
this.chart = new Chart(this.$el, {
type: this.type,
data: this.data,
options: this.options
})
this.resetChart()
},
data () {
Expand All @@ -44,33 +44,34 @@ export default {
methods: {
resetChart () {
this.$nextTick(() => {
if (this.chart)
this.chart.destroy()
this.chart = new Chart(this.$el, {
type: this.type,
data: this.data,
options: this.options
})
this.chart = new Chart(this.$el, {
type: this.type,
data: this.data,
options: this.options,
plugins: this.plugins
})
}
},
watch: {
type () {
this.resetChart()
this.$nextTick(() => this.resetChart())
},
data () {
this.chart.update()
},
options () {
this.resetChart()
this.$nextTick(() => this.resetChart())
}
}
}
</script>

<style lang="scss">
canvas.chartjs {
max-width: 100%;
}
canvas.chartjs {
max-width: 100%;
}
</style>

0 comments on commit 176929c

Please sign in to comment.