mirror of
https://github.com/KevinMidboe/vue-chartjs.git
synced 2026-01-28 04:15:32 +00:00
Revert "wip: Refactor mixin in seperate functions"
This reverts commit 8669452651.
This commit is contained in:
@@ -1,14 +1,7 @@
|
|||||||
/* eslint-disable */
|
|
||||||
|
|
||||||
function dataHandler (newData, oldData) {
|
function dataHandler (newData, oldData) {
|
||||||
if (oldData) {
|
if (oldData) {
|
||||||
const chart = this.$data._chart
|
let chart = this.$data._chart
|
||||||
_checkChanges(newData, oldData, chart)
|
|
||||||
} else {
|
|
||||||
_destroyAndRenderChart(chart)
|
|
||||||
}
|
|
||||||
|
|
||||||
function _checkChanges (newData, oldData, chart) {
|
|
||||||
// Get new and old DataSet Labels
|
// Get new and old DataSet Labels
|
||||||
let newDatasetLabels = newData.datasets.map((dataset) => {
|
let newDatasetLabels = newData.datasets.map((dataset) => {
|
||||||
return dataset.label
|
return dataset.label
|
||||||
@@ -58,16 +51,16 @@ function _checkChanges (newData, oldData, chart) {
|
|||||||
}
|
}
|
||||||
chart.update()
|
chart.update()
|
||||||
} else {
|
} else {
|
||||||
_destroyAndRenderChart(chart)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _destroyAndRenderChart (chart) {
|
|
||||||
if (chart) {
|
|
||||||
chart.destroy()
|
chart.destroy()
|
||||||
|
this.renderChart(this.chartData, this.options)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.$data._chart) {
|
||||||
|
this.$data._chart.destroy()
|
||||||
}
|
}
|
||||||
this.renderChart(this.chartData, this.options)
|
this.renderChart(this.chartData, this.options)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const reactiveData = {
|
export const reactiveData = {
|
||||||
data () {
|
data () {
|
||||||
@@ -84,6 +77,7 @@ export const reactiveData = {
|
|||||||
export const reactiveProp = {
|
export const reactiveProp = {
|
||||||
props: {
|
props: {
|
||||||
chartData: {
|
chartData: {
|
||||||
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
default: () => {}
|
default: () => {}
|
||||||
}
|
}
|
||||||
@@ -97,4 +91,3 @@ export default {
|
|||||||
reactiveData,
|
reactiveData,
|
||||||
reactiveProp
|
reactiveProp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user