So i get this error
[Vue warn]: Avoid muting prop directly, as the value will be overwritten whenever the parent component re-displays. Instead, use data or a computed property based on the value of prop. Prop mutated: "chartData" (found)
now this seems to be a common mistake, but I'm not sure how to get around this in this case
im using Vue with Vue-chartjs and ive got the following
bar_chart.vue
<script>
import { Bar, mixins } from 'vue-chartjs'
export default Bar.extend({
name:"bar_chart",
mixins: [mixins.reactiveProp],
props: ["width","height","options"],
mounted () {
this.renderChart(this.chartData, {responsive: true, maintainAspectRatio: false});
}
})
</script>
module_content.vue
<template>
<div id="module_content">
<div class="container-fluid">
<div class="row">
<div class="col-md-6 bar_chart_test">
<bar_chart
:chartData="DataSet"
:width="400"
:height="200">
</bar_chart>
<button v-on:click="getBarDate">Hey there!</button>
</div>
</div>
</div>
</div>
</template>
<script>
import bar_chart from 'components/controls/bar_chart.vue'
export default {
name: 'module_content',
components: {
bar_chart
},
data: function () {
return {
data_source: {}
}
},
methods: {
getBarDate: function()
{
this.DataSet = ({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label: 'GitHub Commits',
backgroundColor: '#f87979',
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
}
]
});
}
},
computed: {
DataSet: {
cached: false,
get: function () {
return this.data_source
},
set: function (newValue) {
this.data_source = newValue;
}
}
}
}
</script>
Basically, I want this getBarDate function to be able to set ChartData (replaced with an ajax call later on the line), be through hundreds of permutations and documents and still don't understand.
, , , , , vue-chart?
bar_chart.vue .
-