Chart not plotted in Angular 9

I have the problem where if I use static Data the chart is plotted.   But when I get the data from a service it is not plotted even if the static data is assigned in the subcribe.  I know that the data is coming through the webservice via the console.log.     

The Syncfusion chart is v17.4.55
   

 ngOnInit() {

   // this.chartData = [
    //   { unixDateTime: new Date(1520731920000), yvalue: 154 },
    //   { unixDateTime: new Date(1544323380000), yvalue: 144 },
    //   { unixDateTime: new Date(1545286980000), yvalue: 134 }
    // ];

   var webservice = this.httpService.get(this.SERVICE_URL);
    webservice.subscribe(
      data => {
        console.log(data)
        
        data.forEach(element => {
          element["unixDateTime"] = new Date(element["unixDateTime"] * 1000);
        });
         this.chartData = data;  
          // this.chartData = [
    //   { unixDateTime: new Date(1520731920000), yvalue: 154 },
    //   { unixDateTime: new Date(1544323380000), yvalue: 144 },
    //   { unixDateTime: new Date(1545286980000), yvalue: 134 }
    // ];

      });
}


1 Reply

DG Durga Gopalakrishnan Syncfusion Team March 18, 2020 01:05 PM UTC

Hi Albert, 

We have analysed your query. We were able to render the chart in angular 9 using static data from service. Please check with below screenshot and sample. 

Code Snippet 
 
import { ChartDataService } from './chart-data.service'; 
@Component({ 
    providers: [ChartDataService], 
}) 
export class AppComponent implements OnInit{ 
public data :Object[]; 
ngOnInit() { 
      let chartData = ChartDataService.prototype.getData(); 
      this.data = chartData.series1; 


Screenshot 
 
Sample 
 
Regards, 
Durga G

Loader.
Up arrow icon