vue-chartjs
Advanced tools
Comparing version 4.0.3 to 4.0.4
@@ -78,2 +78,3 @@ import { Chart, BarController, DoughnutController, LineController, PieController, PolarAreaController, RadarController, BubbleController, ScatterController } from 'chart.js'; | ||
function generateChart(chartId, chartType, chartController) { | ||
let _chart = null; | ||
return { | ||
@@ -118,7 +119,2 @@ props: { | ||
}, | ||
data () { | ||
return { | ||
_chart: null | ||
}; | ||
}, | ||
created () { | ||
@@ -140,4 +136,4 @@ Chart.register(chartController); | ||
renderChart (data, options) { | ||
if (this.$data._chart !== null) { | ||
chartDestroy(this.$data._chart); | ||
if (_chart !== null) { | ||
chartDestroy(_chart); | ||
this.$emit(ChartEmits.ChartDestroyed); | ||
@@ -151,3 +147,3 @@ } | ||
if (canvasEl2DContext !== null) { | ||
this.$data._chart = new Chart(canvasEl2DContext, { | ||
_chart = new Chart(canvasEl2DContext, { | ||
type: chartType, | ||
@@ -169,15 +165,14 @@ data: chartData, | ||
if (Object.keys(oldData).length > 0) { | ||
const chart = this.$data._chart; | ||
const isEqualLabelsAndDatasetsLength = compareData(newData, oldData); | ||
if (isEqualLabelsAndDatasetsLength && chart !== null) { | ||
setChartDatasets(chart.data, newData, this.datasetIdKey); | ||
if (isEqualLabelsAndDatasetsLength && _chart !== null) { | ||
setChartDatasets(_chart.data, newData, this.datasetIdKey); | ||
if (newData.labels !== undefined) { | ||
setChartLabels(chart, newData.labels); | ||
setChartLabels(_chart, newData.labels); | ||
this.$emit(ChartEmits.LabelsUpdated); | ||
} | ||
chartUpdate(chart); | ||
chartUpdate(_chart); | ||
this.$emit(ChartEmits.ChartUpdated); | ||
} else { | ||
if (chart !== null) { | ||
chartDestroy(chart); | ||
if (_chart !== null) { | ||
chartDestroy(_chart); | ||
this.$emit(ChartEmits.ChartDestroyed); | ||
@@ -189,4 +184,4 @@ } | ||
} else { | ||
if (this.$data._chart !== null) { | ||
chartDestroy(this.$data._chart); | ||
if (_chart !== null) { | ||
chartDestroy(_chart); | ||
this.$emit(ChartEmits.ChartDestroyed); | ||
@@ -200,4 +195,4 @@ } | ||
beforeDestroy () { | ||
if (this.$data._chart !== null) { | ||
chartDestroy(this.$data._chart); | ||
if (_chart !== null) { | ||
chartDestroy(_chart); | ||
this.$emit(ChartEmits.ChartDestroyed); | ||
@@ -204,0 +199,0 @@ } |
{ | ||
"name": "vue-chartjs", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"packageManager": "pnpm@6.32.2", | ||
@@ -5,0 +5,0 @@ "description": "Vue.js wrapper for chart.js for creating beautiful charts.", |
@@ -62,3 +62,3 @@ # vue-chartjs | ||
- 📖 [v3 Docs](http://vue-chartjs.org/) | ||
- 📖 [Docs](http://vue-chartjs.org/) | ||
@@ -322,3 +322,3 @@ ## How to use | ||
} | ||
<script> | ||
</script> | ||
``` | ||
@@ -325,0 +325,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
128550
944