swimlane / ngx-charts

:bar_chart: Declarative Charting Framework for Angular
https://swimlane.github.io/ngx-charts/
MIT License
4.3k stars 1.15k forks source link

ngx-charts bar chart is not refreshing results array updated #ngx-charts #1097

Closed samba439 closed 3 years ago

samba439 commented 5 years ago

I'm submitting a ... (check one with "x")

Current behavior

Expected behavior

Reproduction of the problem

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

samba439 commented 5 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

galvakojis commented 5 years ago

usually it works, would be helpful if you provide stackblitz example

mrmijus commented 4 years ago

did you try: this.data = [...this.data]; The above works for me.

AnthonyNahas commented 4 years ago

this.data = [...this.data]; this worked for me as well

mfatihkc commented 3 years ago

it doesn't refresh graph, even if I change results data

D0mc3k commented 3 years ago

i have the same issue like @mfatihkc. Data is being changed via subscription

Hypercubed commented 3 years ago

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.

BlacKnight-RH commented 2 years ago

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)

shagat commented 2 years ago

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?