-
-
Notifications
You must be signed in to change notification settings - Fork 838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rerendering doughtnut chart not working #33
Comments
Can you provide a minimal repo for reproduction? However you don't need to define the chartData prop, as it's created by the mixin itself. |
Oh I guess I know whats wrong with your code. What is However, it seems that you're changing the chart dataset in the chartjs instance object. Thats why I made the mixins. You only need to change the prop! // BasicChart.js
import {Bar} from 'vue-chartjs'
import reactiveProp from './mixin.js'
export default Bar.extend({
mixins: [reactiveProp],
mounted () {
this.renderChart(this.chartData)
}
}) So, I don't know your environment but then you have in your main vue instance or antoher vue file something like this: <template>
<div class="small">
<bug :chart-data="datacollection"></bug>
<button @click="fillData()">Randomize</button>
</div>
</template>
<script>
import Bug from './Bug.js'
export default {
components: {
Bug
},
data () {
return {
datacollection: {}
}
},
mounted () {
this.fillData()
},
methods: {
fillData () {
this.datacollection = {
labels: ['January' + this.getRandomInt(), 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt()]
}
]
}
},
getRandomInt () {
return Math.floor(Math.random() * (50 - 5 + 1)) + 5
}
}
}
</script> If you change your data with So you only need to change the data you passing in the |
@apertureless I get the following vue warning when I use your approach. Any workwaround?
|
Are you using the umd browser build or with webpack? |
webpack with the latest version |
Expected Behavior
When datasets[0].data is changed, the doughnut should rerender.
Actual Behavior
It isn't rerendering the doughnut. If you put your mouse over, you can see that data is changed, but still there is no visual change.
Component:
Then I'm just changing the data:
this.chart.datasets[0] = newData
Environment
The text was updated successfully, but these errors were encountered: