Ng2-charts: Can't update labels on a Pie chart

Created on 26 Jan 2018  Â·  5Comments  Â·  Source: valor-software/ng2-charts

I have a Angular 5 page that is trying to use your package to draw a simple Pie chart. The data is all set after rendering, and the data seems to update just fine, but when I try to generate and set the labels array, every label shows up as undefined. I have debugged to check the array is getting loaded correctly, but it seems like with labels on Pie / Donut charts, only a statically set array of labels at declaration works. Changing the label array (even creating a new array and resetting the class member) fails to render any labels on the standard mouseover / hover tooltip.

Any suggestions appreciated.

Most helpful comment

The post below on that page worked for me. It's a work around, but it
worked.

John K.

On Wed, Jan 31, 2018 at 12:36 PM, Nacho notifications@github.com wrote:

Any news?. I have the same problem.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/valor-software/ng2-charts/issues/951#issuecomment-362009998,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFYx0OhQy3do9o6ITHfi7SGF2wLiI_y4ks5tQKSSgaJpZM4Rt2DX
.

All 5 comments

I noticed this is an issue on #774. When can we expect a fix?

Any news?. I have the same problem.

The post below on that page worked for me. It's a work around, but it
worked.

John K.

On Wed, Jan 31, 2018 at 12:36 PM, Nacho notifications@github.com wrote:

Any news?. I have the same problem.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/valor-software/ng2-charts/issues/951#issuecomment-362009998,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFYx0OhQy3do9o6ITHfi7SGF2wLiI_y4ks5tQKSSgaJpZM4Rt2DX
.

Closed by ef5d2f4

try this i have try it with bar chat but process is same just customize according to your code.

[datasets]="ChartData"
//...other stuff >

and in the component I have a function which update the chart with new data, and then I clone the datasets and re-assign it

drawChart(){
this.ChartData=[{data: this.dataX, label: 'X'}]; // this.dataX has new values from some place in my code
//nothing happened with my chart yet, until I add this lines:
let clone = JSON.parse(JSON.stringify(this.ChartData));
this.ChartData=clone;
//other stuff like labels etc.
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RKornu picture RKornu  Â·  3Comments

grahammutter picture grahammutter  Â·  4Comments

SteeledSlagle13 picture SteeledSlagle13  Â·  3Comments

egervari picture egervari  Â·  4Comments

raychenfj picture raychenfj  Â·  3Comments