Fix le graph
This commit is contained in:
@@ -62,7 +62,7 @@ export class SummaryComponent implements OnInit {
|
||||
constructor(
|
||||
private serviceApi: StatsService,
|
||||
private serviceComm: ServiceComm,
|
||||
private translateService: TranslateService
|
||||
private translateService: TranslateService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -80,7 +80,7 @@ export class SummaryComponent implements OnInit {
|
||||
const datepipe: DatePipe = new DatePipe("en-US");
|
||||
let formattedDate = datepipe.transform(
|
||||
data.lastJump.jumpDate,
|
||||
"EEEE dd MMMM YYYY"
|
||||
"EEEE dd MMMM YYYY",
|
||||
);
|
||||
this.lastJump = formattedDate + " (" + data.lastJump.dropZone.name + ")";
|
||||
});
|
||||
@@ -90,7 +90,7 @@ export class SummaryComponent implements OnInit {
|
||||
this.dsJumpForLastMonthByDz = new MatTableDataSource(data.byDz);
|
||||
data.byJumpType.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastMonthByJumpType = new MatTableDataSource(
|
||||
data.byJumpType
|
||||
data.byJumpType,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -105,56 +105,87 @@ export class SummaryComponent implements OnInit {
|
||||
public onTabChanged(event: MatTabChangeEvent) {
|
||||
switch (event.index) {
|
||||
case 0:
|
||||
this.serviceApi.getStatsOfLastMonth().subscribe((data) => {
|
||||
data.byDz.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastMonthByDz = new MatTableDataSource(data.byDz);
|
||||
data.byJumpType.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastMonthByJumpType = new MatTableDataSource(
|
||||
data.byJumpType
|
||||
);
|
||||
});
|
||||
this.statsLastMonth();
|
||||
break;
|
||||
case 1:
|
||||
this.serviceApi.getStatsOfLastYear().subscribe((data) => {
|
||||
data.byDz.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastYearByDz = new MatTableDataSource(data.byDz);
|
||||
data.byJumpType.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastYearByJumpType = new MatTableDataSource(
|
||||
data.byJumpType
|
||||
);
|
||||
});
|
||||
this.statsLastYear();
|
||||
break;
|
||||
case 2:
|
||||
this.serviceApi.getStatsByDz().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByDz = new MatTableDataSource(data);
|
||||
});
|
||||
this.statsByDz();
|
||||
break;
|
||||
case 3:
|
||||
this.serviceApi.getStatsByAircraft().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByAircraft = new MatTableDataSource(data);
|
||||
});
|
||||
this.statsByAircraft();
|
||||
break;
|
||||
case 4:
|
||||
this.serviceApi.getStatsByGear().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByGear = new MatTableDataSource(data);
|
||||
});
|
||||
this.statsByGear();
|
||||
break;
|
||||
case 5:
|
||||
this.serviceApi.getStatsByJumpType().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByType = new MatTableDataSource(data);
|
||||
});
|
||||
this.statsByJumpType();
|
||||
break;
|
||||
case 6:
|
||||
this.serviceApi.getStatsByYear().subscribe((data) => {
|
||||
data.sort((a, b) => b.label.localeCompare(a.label));
|
||||
this.dsNbJumpByYear = new MatTableDataSource(data);
|
||||
});
|
||||
this.statsByYear();
|
||||
break;
|
||||
case 7:
|
||||
this.statsByYearByJumpType();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private updateTitle() {
|
||||
this.translateService.get("Summary_Title").subscribe((data) => {
|
||||
this.serviceComm.updatedComponentTitle(data);
|
||||
});
|
||||
}
|
||||
|
||||
private chartConfig() {
|
||||
this.barChartType = "line";
|
||||
this.barChartOptions = {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: {
|
||||
legend: {
|
||||
display: true,
|
||||
},
|
||||
colors: {
|
||||
forceOverride: false,
|
||||
},
|
||||
},
|
||||
interaction: {
|
||||
intersect: false,
|
||||
mode: "nearest",
|
||||
axis: "x",
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
stacked: false,
|
||||
},
|
||||
y: {
|
||||
stacked: false,
|
||||
beginAtZero: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
this.jumpTypeToColor = new Map<string, string>([
|
||||
["PAC", "#FFD700"],
|
||||
["Solo", "#FFA500"],
|
||||
["RW 3", "#40E0D0"],
|
||||
["RW 4", "#008080"],
|
||||
["RW 8", "#7FFFD4"],
|
||||
["RW X", "#114556"],
|
||||
["FreeFly", "#FFC0CB"],
|
||||
["FreeStyle", "#FF91A4"],
|
||||
["Track/Trace", "#87CEEB"],
|
||||
["Canopy", "#228B22"],
|
||||
["Landing accuracy", "#FF6347"],
|
||||
["Wingsuit 1", "#E6E6FA"],
|
||||
["Wingsuit 2", "#E0B0FF"],
|
||||
["Wingsuit 3", "#9400D3"],
|
||||
]);
|
||||
}
|
||||
|
||||
// #region Private methods to get stats
|
||||
private statsByYearByJumpType() {
|
||||
this.serviceApi.getStatsByYearByJumpType().subscribe((data) => {
|
||||
data.sort((a, b) => a.label.localeCompare(b.label));
|
||||
|
||||
@@ -162,9 +193,7 @@ export class SummaryComponent implements OnInit {
|
||||
const now = new Date();
|
||||
const currentYear = now.getFullYear();
|
||||
const nbYears = currentYear - firstYear;
|
||||
let listOfYears = new Array(nbYears)
|
||||
.fill(null)
|
||||
.map(() => firstYear++);
|
||||
let listOfYears = new Array(nbYears).fill(null).map(() => firstYear++);
|
||||
|
||||
// Prepare the list of jump type with am empty array
|
||||
let tmpResults = new Map<string, number[]>();
|
||||
@@ -213,60 +242,63 @@ export class SummaryComponent implements OnInit {
|
||||
datasets: results,
|
||||
};
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private updateTitle() {
|
||||
this.translateService.get("Summary_Title").subscribe((data) => {
|
||||
this.serviceComm.updatedComponentTitle(data);
|
||||
private statsByYear() {
|
||||
this.serviceApi.getStatsByYear().subscribe((data) => {
|
||||
data.sort((a, b) => b.label.localeCompare(a.label));
|
||||
this.dsNbJumpByYear = new MatTableDataSource(data);
|
||||
});
|
||||
}
|
||||
|
||||
private chartConfig() {
|
||||
this.barChartType = "line";
|
||||
this.barChartOptions = {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: {
|
||||
legend: {
|
||||
display: true,
|
||||
},
|
||||
colors: {
|
||||
forceOverride: true,
|
||||
},
|
||||
},
|
||||
interaction: {
|
||||
intersect: false,
|
||||
mode: "nearest",
|
||||
axis: "x",
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
stacked: false,
|
||||
},
|
||||
y: {
|
||||
stacked: false,
|
||||
beginAtZero: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
private statsByJumpType() {
|
||||
this.serviceApi.getStatsByJumpType().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByType = new MatTableDataSource(data);
|
||||
});
|
||||
}
|
||||
|
||||
this.jumpTypeToColor = new Map<string, string>([
|
||||
["PAC", "#FFD700"],
|
||||
["Solo", "#FFA500"],
|
||||
["RW 3", "#40E0D0"],
|
||||
["RW 4", "#008080"],
|
||||
["RW 8", "#7FFFD4"],
|
||||
["RW X", "#114556"],
|
||||
["FreeFly", "#FFC0CB"],
|
||||
["FreeStyle", "#FF91A4"],
|
||||
["Track/Trace", "#87CEEB"],
|
||||
["Canopy", "#228B22"],
|
||||
["Landing accuracy", "#FF6347"],
|
||||
["Wingsuit 1", "#E6E6FA"],
|
||||
["Wingsuit 2", "#E0B0FF"],
|
||||
["Wingsuit 3", "#9400D3"],
|
||||
]);
|
||||
private statsByGear() {
|
||||
this.serviceApi.getStatsByGear().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByGear = new MatTableDataSource(data);
|
||||
});
|
||||
}
|
||||
|
||||
private statsByAircraft() {
|
||||
this.serviceApi.getStatsByAircraft().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByAircraft = new MatTableDataSource(data);
|
||||
});
|
||||
}
|
||||
|
||||
private statsByDz() {
|
||||
this.serviceApi.getStatsByDz().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByDz = new MatTableDataSource(data);
|
||||
});
|
||||
}
|
||||
|
||||
private statsLastYear() {
|
||||
this.serviceApi.getStatsOfLastYear().subscribe((data) => {
|
||||
data.byDz.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastYearByDz = new MatTableDataSource(data.byDz);
|
||||
data.byJumpType.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastYearByJumpType = new MatTableDataSource(
|
||||
data.byJumpType,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private statsLastMonth() {
|
||||
this.serviceApi.getStatsOfLastMonth().subscribe((data) => {
|
||||
data.byDz.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastMonthByDz = new MatTableDataSource(data.byDz);
|
||||
data.byJumpType.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastMonthByJumpType = new MatTableDataSource(
|
||||
data.byJumpType,
|
||||
);
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user