Skip to content

Commit

Permalink
feat: reactive doughnut chart
Browse files Browse the repository at this point in the history
  • Loading branch information
lbwa committed Sep 29, 2018
1 parent 1ed9a52 commit 55eaa82
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions src/components/ChartDoughnut.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,39 @@ export default {
},

mounted () {
this.renderChart({
labels: this.labels,
datasets: [
{
backgroundColor: this.colorSets,
data: this.datasets
}
]
}, {
legend: {
display: false,
position: 'right',
labels: {
usePointStyle: true
}
},
cutoutPercentage: 80, // inner round radius
...this.options
})
this.renderer()
},

methods: {
handleUpdate (newValue, oldValue) {
this.$data._chart.destroy()
this.renderer()
},

renderer () {
this.renderChart({
labels: this.labels,
datasets: [
{
backgroundColor: this.colorSets,
data: this.datasets
}
]
}, {
legend: {
display: false,
position: 'right',
labels: {
usePointStyle: true
}
},
cutoutPercentage: 80, // inner round radius
...this.options
})
}
},

watch: {
datasets: 'handleUpdate'
}
}

0 comments on commit 55eaa82

Please sign in to comment.