I am relatively new to web applications and therefore just starting to use Angular2 (NOT using angularJS) and Typescript. I am trying to use Zingchart to plot. I went through 5 minutes of quick start, as well as a tutorial on the Angular2 page, and got a decent idea of ββhow this works. I followed the instructions on the Zingchart page to create a chart on a web page using two tools ( https://blog.zingchart.com/2016/03/16/angular-2-example-zingchart/ ). However, it looks like I'm having problems. 1) I can not import AfterView from @ angular / core. Although the page says that I should use angular2 / core, I use @ angular / core as the source folder for importing modules. angular2 / core is not recognized. 2) When there are functions associated with the zingchart object (for example, zingchart.render (), zingchart.exec ()), an error occurs that says that zingchart cannot be found. I'm also not sure what is going on here.
import { Component, NgZone, AfterViewInit, OnDestroy } from '@angular/core'; class Chart { id: String; data: Object; height: any; width: any; constructor(config: Object) { this.id = config['id']; this.data = config['data']; this.height = config['height'] || 300; this.width = config['width'] || 600; } } @Component({ selector : 'zingchart', inputs : ['chart'], template : ` <div id='{{chart.id}}'></div> ` }) class ZingChart implements AfterViewInit, OnDestroy { chart : Chart; constructor(private zone:NgZone) { } ngAfterViewInit() { this.zone.runOutsideAngular(() => { zingchart.render({ id : this.chart['id'], data : this.chart['data'], width : this.chart['width'], height: this.chart['height'] }); }); } ngOnDestroy() { zingchart.exec(this.chart['id'], 'destroy'); } }
source share