Thursday, 20 December 2018

Error: Container is not defined at gvjs_dp GeoChart in Angular

Here is my HTML code:

<div id="geochart" #geochart> </div>

Here is my TS code:

ngOnInit()

{

  google.charts.load('current', {'packages':['corechart','geochart'], mapsApiKey: 'XXXXmyAPIKEYXXXX'});

this.http.post(url,data,{responseType: 'text'})
 .subscribe(
         data =>
         {
                 this.geoChartArray = JSON.parse(data).data;
                 this.drawGeoChart();

         },
         error =>
         {

                console.log(error);

         }
    );

 }


drawGeoChart() {



   var geo_1_options = { is3D: true };   
   var geo_1_data = google.visualization.arrayToDataTable(this.geoChartArray);
   var domElement = document.getElementById('geochart');
   var geo_1_chart = new google.visualization.GeoChart(domElement);
   geo_1_chart.draw(geo_1_data, geo_1_options);


}

Sometimes the GeoChart loads and sometimes I get this error. I'm unable to figure out what exactly is causing the error.



from Error: Container is not defined at gvjs_dp GeoChart in Angular

No comments:

Post a Comment