Skip to content

Commit 677c53d

Browse files
authored
Merge pull request #139 from ZhangYiJiang/patch-beforeDestroy
Fix beforeDestory when renderChart was not called
2 parents 362639c + 3e423fd commit 677c53d

File tree

9 files changed

+27
-9
lines changed

9 files changed

+27
-9
lines changed

src/BaseCharts/Bar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export default Vue.extend({
7979
}
8080
},
8181
beforeDestroy () {
82-
this._chart.destroy()
82+
if (this._chart) {
83+
this._chart.destroy()
84+
}
8385
}
8486
})

src/BaseCharts/Bubble.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ export default Vue.extend({
8080
}
8181
},
8282
beforeDestroy () {
83-
this._chart.destroy()
83+
if (this._chart) {
84+
this._chart.destroy()
85+
}
8486
}
8587
})

src/BaseCharts/Doughnut.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export default Vue.extend({
6363
}
6464
},
6565
beforeDestroy () {
66-
this._chart.destroy()
66+
if (this._chart) {
67+
this._chart.destroy()
68+
}
6769
}
6870
})

src/BaseCharts/HorizontalBar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export default Vue.extend({
7979
}
8080
},
8181
beforeDestroy () {
82-
this._chart.destroy()
82+
if (this._chart) {
83+
this._chart.destroy()
84+
}
8385
}
8486
})

src/BaseCharts/Line.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ export default Vue.extend({
7878
}
7979
},
8080
beforeDestroy () {
81-
this._chart.destroy()
81+
if (this._chart) {
82+
this._chart.destroy()
83+
}
8284
}
8385
})

src/BaseCharts/Pie.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export default Vue.extend({
6363
}
6464
},
6565
beforeDestroy () {
66-
this._chart.destroy()
66+
if (this._chart) {
67+
this._chart.destroy()
68+
}
6769
}
6870
})

src/BaseCharts/PolarArea.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export default Vue.extend({
6363
}
6464
},
6565
beforeDestroy () {
66-
this._chart.destroy()
66+
if (this._chart) {
67+
this._chart.destroy()
68+
}
6769
}
6870
})

src/BaseCharts/Radar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export default Vue.extend({
6363
}
6464
},
6565
beforeDestroy () {
66-
this._chart.destroy()
66+
if (this._chart) {
67+
this._chart.destroy()
68+
}
6769
}
6870
})

src/BaseCharts/Scatter.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export default Vue.extend({
6464
}
6565
},
6666
beforeDestroy () {
67-
this._chart.destroy()
67+
if (this._chart) {
68+
this._chart.destroy()
69+
}
6870
}
6971
})

0 commit comments

Comments
 (0)