title: How to implement D3 in Angular 2
body: <p>I want to implement this code from d3.js to angular 2 component, but i don't know how to call js file into component ts file. I have found some code for line chart, with index.html and lineChart.js. How can I call javascript in <code>ngAfterViewInit</code> or <code>afterViewInit</code>. </p>
  
  <p>Example how chart looks like <a href="http://plnkr.co/edit/Jijnm8W4sRzAAsLMTvgV?p=preview" rel="noreferrer">http://plnkr.co/edit/Jijnm8W4sRzAAsLMTvgV?p=preview</a></p>
  
  <p>So I want to call this in component ts in ngAfterViewInit.</p>
  
  <p>Here is code for component:</p>
  
  <pre><code>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() {
  
  
  
    }
  
  }
  </code></pre>