ng2-charts: Dynamically change generated labels not worked
Version: ng2-charts v1.5.0
Reproduction of the problem http://plnkr.co/edit/Ggp7hasnGBsKTlq8hu1R?p=preview
Probably dynamically change generated labels feature was removed by this PR #563 .
related task to this feature #445
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (2 by maintainers)
Yeah, this library stinks. Docs stink, you have to fiddle around with everything to make it work. Extremely hard to get it to work with async/changing data. Overall terrible experience and leaves a bad taste in my mouth for valor-software.
For those looking for a walk around, for now you can put your labels and data in an object and put that object in an array and just loop through the array in your html. This will redraw the element every time your array changes.
in your type script every time there’s a change.
data = [...]; labels = [...]; chartArray = [{data , labels }]in your html
<canvas *ngFor="let chartData of chartArray " [data]="chartData.data" [labels]="chartData.labels" > </canvas>this works… chart.js@2.6.0 ng2-charts@1.6.0
ng2-charts/charts/charts.js
In the mean time, in case you need it, here’s a plkr that updates the labels ‘manually’. http://plnkr.co/edit/Ra6cfYkctsq3ZnqxTHYf?p=preview
hey, @jerkly, I made a PR fixing your issue.