0👍
The chart itself seems fine, so I guess the problem is the way you try to fill your arrays.
You have checked the content of countriestData
and countriesLabel
?
You didn’t show what exactly chartService.getCountryGroupBy()
returns, but I guess it’s only the response body of the request, so you’ll probably have to change your code to
this.chartService.getCountryGroupBy().subscribe(data => {
data.forEach(country => {
this.countriestData.push(country.count);
this.countriesLabel.push(country.country);
});
});
0👍
Try this:
public countriesLabel: string[] = [{ data: [] }];
public countriestData: number[] = [{ data: [] }];
or
public countriesLabel: any[] = [{ data: [] }];
public countriestData: any[] = [{ data: [] }];
I could solve my similar problem by changing the definition of my data to this format.
Source:stackexchange.com