1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import { Component, AfterViewInit } from '@angular/core';
export class AppComponent implements AfterViewInit {
ngAfterViewInit() {
const canvas = <HTMLCanvasElement>document.getElementById('myChart');
const ctx = canvas.getContext('2d');
new Chart(ctx, {
type: 'bar',
data: {
labels: ['Label 1', 'Label 2', 'Label 3'],
datasets: [{
label: 'Data',
data: [10, 20, 30],
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1
}]
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true
}
}
}
});
}
}
|