Rerendering doughtnut chart not working
See original GitHub issueExpected 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:
import { Doughnut, mixins } from 'vue-chartjs'
export default Doughnut.extend({
mixins: [mixins.reactiveProp],
props: ["chartData", "options"],
mounted () {
this.renderChart(this.chartData, this.options)
},
methods: {},
events: {},
})
Then I’m just changing the data:
this.chart.datasets[0] = newData
Environment
- OS: Ubuntu
- NPM Version: 4.1.2
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Chart.js pie chart not rendering after update - Stack Overflow
After a lot of testing and researching, I found the solution. First, the chart must be initialised and then the data must be...
Read more >Render Piechart - Microsoft Community Hub
Hi All,. I want to create a pie chart that can populate the count of two types VMs that has either security or...
Read more >Reusable react component with Canvas doesn't render ...
Coding example for the question Reusable react component with Canvas doesn't render canvas with its props-Chart.js.
Read more >Using Chart.js in React - LogRocket Blog
If you're working from the terminal, you can install these ... can then be passed to a PieChart component, which will render a...
Read more >Visualization: Pie Chart - Google Developers
A pie chart that is rendered within the browser using SVG or VML. ... The format for id isn't yet documented (they're the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bertobc
Oh I guess I know whats wrong with your code. However I can only speculate.
What is
this.chart.datasets[0]
in your case? The chartjs instance should be a private var and only accessible overthis._chart
However, it seems that you’re changing the chart dataset in the chartjs instance object. Thats wrong, and does not make sense, since chartjs does not have an automatic detection for data changes.
Thats why I made the mixins.
You only need to change the prop!
So, I don’t know your environment but then you have in your main vue instance or antoher vue file something like this:
If you change your data with
this.chart.datasets[0] = newData
the mixin can’t work. Because the mixin is watching the chartData prop.So you only need to change the data you passing in the
:chart-data=<your data here>
prop.webpack with the latest version