Revert "wip: Refactor mixin in seperate functions"

This reverts commit 8669452651.
This commit is contained in:
Jakub Juszczak
2018-03-20 21:35:54 +01:00
parent 8669452651
commit bfa1fb83f9

View File

@@ -1,14 +1,7 @@
/* eslint-disable */
function dataHandler (newData, oldData) {
if (oldData) {
const chart = this.$data._chart
_checkChanges(newData, oldData, chart)
} else {
_destroyAndRenderChart(chart)
}
let chart = this.$data._chart
function _checkChanges (newData, oldData, chart) {
// Get new and old DataSet Labels
let newDatasetLabels = newData.datasets.map((dataset) => {
return dataset.label
@@ -58,15 +51,15 @@ function _checkChanges (newData, oldData, chart) {
}
chart.update()
} else {
_destroyAndRenderChart(chart)
}
}
function _destroyAndRenderChart (chart) {
if (chart) {
chart.destroy()
this.renderChart(this.chartData, this.options)
}
} else {
if (this.$data._chart) {
this.$data._chart.destroy()
}
this.renderChart(this.chartData, this.options)
}
}
export const reactiveData = {
@@ -84,6 +77,7 @@ export const reactiveData = {
export const reactiveProp = {
props: {
chartData: {
type: Object,
required: true,
default: () => {}
}
@@ -97,4 +91,3 @@ export default {
reactiveData,
reactiveProp
}