Closed samba439 closed 3 years ago
I want to update Bar Chart data dynamically when user clicks on Submit button. I tried to push the data to array but Bar chart is not updating with data
Thank you in advance
usually it works, would be helpful if you provide stackblitz example
did you try:
this.data = [...this.data];
The above works for me.
this.data = [...this.data];
this worked for me as well
it doesn't refresh graph, even if I change results data
i have the same issue like @mfatihkc. Data is being changed via subscription
Verified you are creating a new array not just mutating the array. As point above you need something like this.data = [...this.data];
... this.data.push
will not work.
I am aware that the change detector may not be able to detect updates on the array so you may need to return a new one, However, this approach mentioned by @Hypercubed is not working for me (I am using a line chart)
The problem with the spread operator solution is that, if you try to go back to a smaller value, you will break the result. For ex. say you have an array that is generated using a slider (say: from 0-----50), whenever move the slider you generate a new array times(X) slider-value. If you move the slider towards right first and then later on towards left, you will see that it won't update accordingly, it will only overwrite the previous index of the value. I did this and I dont know how to fix this. Anyone knows?
I'm submitting a ... (check one with "x")
ngx-charts
tag) or the gitter chat for support questionsCurrent behavior
Expected behavior
Reproduction of the problem
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
ngx-charts version: x.x.x
Angular version: x.x.x
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
Language: [all | TypeScript X.X | ES6/7 | ES5]