I want to implement this code from d3.js into an angular 2 component, but I don't know how to call the js file in the ts file of the component. I found code for a line chart, with index.html and lineChart.js. How can I call javascript in ngAfterViewInitor afterViewInit.
An example of what the diagram looks like http://plnkr.co/edit/Jijnm8W4sRzAAsLMTvgV?p=preview
So I want to call it in the ts component of ngAfterViewInit.
Here is the code for the component:
import {Component, Directive, ViewChild, ElementRef, Renderer} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
declare var d3: any;
declare var jQuery: any;
@Directive({
})
class H3 {}
@Component({
selector: 'my-app',
})
export class D3 {
constructor(public renderer: Renderer, public el: ElementRef){ }
ngOnInit() {
}
ngAfterViewInit() {
}
}
source
share