aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_elements/_charts/pie-chart
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/app/_elements/_charts/pie-chart')
-rw-r--r--frontend/src/app/_elements/_charts/pie-chart/pie-chart.component.ts39
1 files changed, 25 insertions, 14 deletions
diff --git a/frontend/src/app/_elements/_charts/pie-chart/pie-chart.component.ts b/frontend/src/app/_elements/_charts/pie-chart/pie-chart.component.ts
index 932ed963..c2bd3262 100644
--- a/frontend/src/app/_elements/_charts/pie-chart/pie-chart.component.ts
+++ b/frontend/src/app/_elements/_charts/pie-chart/pie-chart.component.ts
@@ -12,21 +12,34 @@ export class PieChartComponent implements AfterViewInit {
@Input()height?: number;
@Input()uniqueValues?: string[] = [];
@Input()uniqueValuesPercent?: number[] = [];
+
+ updatePieChart(uniqueValues: string[], uniqueValuesPercent: number[]){
+ console.log(this.uniqueValues, this.uniqueValuesPercent);
+ const newPieChartData = {
+ datasets: [{
+ label: "Population (millions)",
+ backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"],
+ data: [2478,5267,734,784,433],
+ }]
+
+ }
+ };
@ViewChild('piechart') chartRef!: ElementRef;
constructor() { }
+ pieChartData = {
+ datasets: [{
+ label: "Population (millions)",
+ backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"],
+ data: [2478,5267,734,784,433]
+ }]
+}
+
ngAfterViewInit(): void {
const myChart = new Chart(this.chartRef.nativeElement, {
type: 'pie',
- 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],
- }]
- },
+ data: this.pieChartData,
options: {
/*title: {
display: true,
@@ -38,11 +51,9 @@ export class PieChartComponent implements AfterViewInit {
},
},
layout: {
- padding: 15}
+ padding: 15
+ }
}
-});
-
- }
+ });}
-
-}
+} \ No newline at end of file