scttcper / ngx-chartjs

Functional Chart.js wrapper for Angular
https://ngx-chartjs.vercel.app
MIT License
56 stars 12 forks source link

Dynamic data not updating #70

Closed Ross-Rawlins closed 4 years ago

Ross-Rawlins commented 5 years ago

I have a dynamic data set but no matter what I do the graph doesnt redraw it. It works fine when I update the labels but how can I set the data for individual data sets in the data sets array.

this.data.datasets[0].data = tempArray I use that for the data. this.data = { ...this.data, labels: this.dateArray, }; and this for the labels

scttcper commented 5 years ago

Change detection doesn’t fire when you update properties of an object. Only when you replace the object with another object

Ross-Rawlins commented 5 years ago

I tried that aswell, using a behavour subject and the async pipe but nothing happens. Do oyu have a short hand to combine the new data sets into the exisitng object?

scttcper commented 5 years ago

not really. i tend to do whats in the dynamic doughnut example you can see in the library demo.

https://github.com/TypeCtrl/ngx-chartjs/blob/master/src/app/dynamic-doughnut-example/dynamic-doughnut-example.component.ts

Ross-Rawlins commented 5 years ago

so it has to be a whole new object and subjects with the async pipe wont trigger it either. Just want to confirm

On Wed, 28 Nov 2018 at 19:31, Scott Cooper notifications@github.com wrote:

not really. i tend to do whats in the dynamic doughnut example you can see in the library demo.

https://github.com/TypeCtrl/ngx-chartjs/blob/master/src/app/dynamic-doughnut-example/dynamic-doughnut-example.component.ts

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/TypeCtrl/ngx-chartjs/issues/70#issuecomment-442534472, or mute the thread https://github.com/notifications/unsubscribe-auth/ADMeUDrbGMm82kMhbESqWViyZUbGdUoaks5uzshogaJpZM4Y3shK .

-- Ross Rawlins Tel: 021 531 7087 Cell: 072 424 9480 Skype: ross.rawlins Email: ross@duovili.co.za

http://www.duovili.co.za https://plus.google.com/113781084234234096576/posts https://www.facebook.com/Duovili http://www.linkedin.com/company/duovili/ https://twitter.com/Duovili

This e-mail message and all attachments contain the CONFIDENTIAL AND PROPRIETARY information of DUOVILI DEVELOPMENTS. and may contain LEGALLY PRIVILEGED information. If you are not the intended recipient, you are hereby notified that any disclosure, distribution, or use of this e-mail, its attachments or any information contained therein is unauthorised and prohibited. If you have received this in error, please contact the sender immediately and delete this e-mail and any attachments.