Skip to content

Commit

Permalink
Merge pull request #3 from LinusBorg/properly_destroy_chartsjs_objects
Browse files Browse the repository at this point in the history
Properly destroy chartjs objects
  • Loading branch information
apertureless authored Aug 19, 2016
2 parents d1bd9ef + 90d9d87 commit ad7cabe
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/BaseCharts/Bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ export default Vue.extend({

methods: {
render (data, options = this.options) {
const chart = new Chart(
this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'bar',
data: data,
options: options
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})
7 changes: 5 additions & 2 deletions src/BaseCharts/Doughnut.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ export default Vue.extend({

methods: {
render (data, options = this.options) {
const chart = new Chart(
this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'doughnut',
data: data,
options: options
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})
7 changes: 5 additions & 2 deletions src/BaseCharts/Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ export default Vue.extend({

methods: {
render (data, options = this.options) {
const chart = new Chart(
this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'line',
data: data,
options: options
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})
7 changes: 5 additions & 2 deletions src/BaseCharts/Pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ export default Vue.extend({

methods: {
render (data, options = this.options) {
const chart = new Chart(
this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'pie',
data: data,
options: options
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})
7 changes: 5 additions & 2 deletions src/BaseCharts/PolarArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ export default Vue.extend({

methods: {
render (data, options = this.options) {
const chart = new Chart(
this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'polarArea',
data: data,
options: options
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})
7 changes: 5 additions & 2 deletions src/BaseCharts/Radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ export default Vue.extend({

methods: {
render (data, options = this.options) {
const chart = new Chart(
this._chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'radar',
data: data,
options: options
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})

0 comments on commit ad7cabe

Please sign in to comment.