1๐
โ
You can use npm module:
Then you can use it like this in your module:
import { ChartModule } from 'angular2-chartjs';
@NgModule({
imports: [ ChartModule ]
// ...
})
export class AppModule {
}
And in html template:
<chart [type]="type" [data]="data" [options]="options"></chart>
Donโt forget to fill it with data ๐
1๐
Something like:
@Component({
selector: 'my-component',
template: `
<canvas #myChart" width="400" height="400"></canvas>
<script>
`)}
export class MyComponent {
@ViewChild('myChart') myChart;
ngAfterViewInit() {
var myChart = new Chart(this.target.nativeElement, {[...]});
}
}
Source:stackexchange.com