Created
June 6, 2019 23:13
-
-
Save arturovt/ed519ca9b9e7c28867c795d9c5c3dce5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; | |
import * as Chart from 'chart.js'; | |
@Component({ | |
selector: 'app-line-chart', | |
template: ` | |
<canvas #canvas></canvas> | |
` | |
}) | |
export class LineChartComponent implements OnInit { | |
@ViewChild('canvas') | |
public canvas: ElementRef<HTMLCanvasElement> = null; | |
private options = { | |
... | |
}; | |
public ngOnInit(): void { | |
const ctx = this.canvas.nativeElement.getContext('2d'); | |
new Chart(ctx, this.options); // BAD! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment