저는 웹 응용 프로그램에 비교적 익숙하지 않기 때문에 Angular2 (angularJS를 사용하지 않았습니다)와 Typescript를 사용하기 시작했습니다. Zingchart를 사용하여 그래프를 그려 봅니다. 나는 angular2 페이지의 튜토리얼뿐만 아니라 5 분 빠른 시작을 통해 어떻게 작동하는지에 대한 괜찮은 아이디어를 얻었습니다. Zingchart 페이지의 지침에 따라 두 도구 (https://blog.zingchart.com/2016/03/16/angular-2-example-zingchart/)를 사용하여 웹 페이지에서 차트를 만들었습니다. 그러나, 나는 문제가있는 것 같습니다. 1) @ Anger/Core에서 AfterView를 가져올 수 없습니다. 페이지에 angular2/core를 사용해야한다고 나와 있지만 모듈을 가져올 소스 폴더로 @ angular/core를 사용하고 있습니다. angular2/core가 인식되지 않습니다. 2) zingchart 객체 (예 - zingchart.render(), zingchart.exec())에 바인드 된 함수가있을 때 zingchart를 찾을 수 없다는 오류가 있습니다. 나는 여기서 어떤 일이 잘못되고 있는지 확신하지 못한다.Graphing tools - Angular2
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');
}
}
//Root Component
@Component({
selector: 'my-app',
directives: [ZingChart],
template: `
<zingchart *ngFor="#chartObj of charts" [chart]='chartObj'></zingchart>
`,
})
export class App {
charts : Chart[];
constructor() {
this.charts = [{
id : 'chart-1',
data : {
type : 'line',
series : [{
values :[2,3,4,5,3,3,2]
}],
},
height : 400,
width : 600
}]
}
}
시도한 것을 나타내는 코드를 게시하십시오. –
'angular2/...'는 RC.x 버전의 베타 버전'@angular/...'에 사용됩니다. –