Hello, I am working on a URL shortener. I am using Ng2GoogleChartModule in 
my AnalyticsComponent.
I have a table where I have multiple short URL. When I choose the first URL 
and see the analytics of the first URL
first time when my component is initialized it displays the data in the geo 
chart but when I go back to my data table and 
redirect to another short URL. I am getting this error *ERROR Error: 
Uncaught (in promise): Error: Row 0 has 0 columns,*
 but must have 2* (*I am also attaching the screenshot of the error which I 
am getting in my browser console*).*



Here is my component.ts file

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { UsersLinksService } from '../../Services/users-links.service';

@Component({
selector: 'app-analytics',
templateUrl: './analytics.component.html',
styleUrls: ['./analytics.component.css'],
})
export class AnalyticsComponent implements OnInit {

constructor(private route: ActivatedRoute, private usersLinks: 
UsersLinksService, private router: Router) {}

public geoChartData = { chartType: 'GeoChart', dataTable: [['Country', 
'Click'], []] };

ngOnInit() {
const url = this.route.snapshot.paramMap.get('shortUrl');
this.usersLinks.linkCountry(url).subscribe((country: any) => {
if (country.length === 0) {
return false;
} else {
for (let index = 0; index < country.length; index++) {
this.geoChartData.dataTable[1].push(country[index]._id.TotalCountry.
countryName, country[index].clicks);
}
}
}, error => {this.errorMsg = error; });
}
}


This is my components.html

<div style="display: block">
<google-chart [data]="geoChartData"></google-chart>
</div>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to