aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_elements/_charts/doughnut-chart/doughnut-chart.component.ts
diff options
context:
space:
mode:
authorNevena Bojovic <nenabojov@gmail.com>2022-04-24 18:43:14 +0200
committerNevena Bojovic <nenabojov@gmail.com>2022-04-24 18:43:14 +0200
commitdbc6d56f495b2238ed1e8b6bc036b23a6067b051 (patch)
treea7365c441b87de06ee0281efc92f17a8546fba88 /frontend/src/app/_elements/_charts/doughnut-chart/doughnut-chart.component.ts
parent0b38d83378e3ea03893eb60729e8bebbf9942949 (diff)
Doughnut Chart (Varijanta Pie Chart).
Diffstat (limited to 'frontend/src/app/_elements/_charts/doughnut-chart/doughnut-chart.component.ts')
-rw-r--r--frontend/src/app/_elements/_charts/doughnut-chart/doughnut-chart.component.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/frontend/src/app/_elements/_charts/doughnut-chart/doughnut-chart.component.ts b/frontend/src/app/_elements/_charts/doughnut-chart/doughnut-chart.component.ts
new file mode 100644
index 00000000..4c7508fe
--- /dev/null
+++ b/frontend/src/app/_elements/_charts/doughnut-chart/doughnut-chart.component.ts
@@ -0,0 +1,34 @@
+import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
+import {Chart} from 'node_modules/chart.js';
+
+@Component({
+ selector: 'app-doughnut-chart',
+ templateUrl: './doughnut-chart.component.html',
+ styleUrls: ['./doughnut-chart.component.css']
+})
+export class DoughnutChartComponent implements AfterViewInit {
+
+ @ViewChild('doughnut') chartRef!: ElementRef;
+ constructor() { }
+
+ ngAfterViewInit(): void {
+ const myChart = new Chart(this.chartRef.nativeElement, {
+ type: 'doughnut',
+ data: {
+ labels: ["Africa", "Asia", "Europe", "Latin America", "North America"],
+ datasets: [{
+ label: "Population (millions)",
+ backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"],
+ data: [2478,5267,734,784,433]
+ }]
+ },
+ /*options: {
+ title: {
+ display: true,
+ text: 'Predicted world population (millions) in 2050'
+ }
+ }*/
+ });
+ }
+
+}