Début pour avoir un graphique avec les types
de vol en tunnel
This commit is contained in:
@@ -146,7 +146,8 @@ export class ListOfTunnelFlightsComponent implements OnInit {
|
|||||||
this.barChartData = {
|
this.barChartData = {
|
||||||
labels: allMonths,
|
labels: allMonths,
|
||||||
datasets: [
|
datasets: [
|
||||||
{ data: cumulatedTime, label: 'Time in tunnel' }
|
{ data: cumulatedTime, label: 'Time in tunnel' },
|
||||||
|
{ data: cumulatedTime, label: 'Time in tunnel 2' }
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -168,21 +169,49 @@ export class ListOfTunnelFlightsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getCumulatedTimeByMonth(stats: TunnelFlightByMonth[], allMonths: string[]): Array<number> {
|
private getCumulatedTimeByMonth(stats: TunnelFlightByMonth[], allMonths: string[]): Array<number> {
|
||||||
let results: Array<number> = [];
|
// type GraphModel = {
|
||||||
|
// data: number[];
|
||||||
|
// label: string;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// let results: Array<number> = [];
|
||||||
|
|
||||||
|
// for (let i = 0; i < allMonths.length; i++) {
|
||||||
|
// const month = allMonths[i];
|
||||||
|
// let tmp = stats.filter((d) => d.month == month);
|
||||||
|
|
||||||
|
// let sum: number = 0;
|
||||||
|
// if (tmp.length > 0){
|
||||||
|
// tmp.forEach(a => sum += a.nb);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// results.push(sum);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return results;
|
||||||
|
|
||||||
|
let arr3 = Array.from({length: allMonths.length + 1}, (v, k) => 0);
|
||||||
|
let disctintType = stats.map(item => item.type).filter((value, index, self) => self.indexOf(value) === index);
|
||||||
|
let disctintType2 = Array.from(new Set(stats.map((item) => item.type)))
|
||||||
|
|
||||||
|
let results = new Map<string, number[]>();
|
||||||
|
|
||||||
for (let i = 0; i < allMonths.length; i++) {
|
for (let i = 0; i < allMonths.length; i++) {
|
||||||
const month = allMonths[i];
|
const month = allMonths[i];
|
||||||
let tmp = stats.filter((d) => d.month == month);
|
let tmp = stats.filter((d) => d.month == month);
|
||||||
|
|
||||||
let sum = 0;
|
if (tmp.length > 0){
|
||||||
if (tmp.length == 1){
|
tmp.forEach(a => {
|
||||||
sum = tmp[0].nb;
|
if (!results.has(a.type)) {
|
||||||
|
results.set(a.type, [a.nb])
|
||||||
|
} else {
|
||||||
|
results[a.type].push(a.nb);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
results.push(sum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return new Array<number>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private footer = (tooltipItems) => {
|
private footer = (tooltipItems) => {
|
||||||
|
|||||||
@@ -48,10 +48,12 @@ export class TunnelFlight {
|
|||||||
export class TunnelFlightByMonth {
|
export class TunnelFlightByMonth {
|
||||||
constructor(data: any) {
|
constructor(data: any) {
|
||||||
this.month = data.label;
|
this.month = data.label;
|
||||||
|
this.type = data.label2;
|
||||||
this.nb = data.nb;
|
this.nb = data.nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public month: string;
|
public month: string;
|
||||||
|
public type: string;
|
||||||
public nb: number;
|
public nb: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,5 +63,6 @@ export class TunnelFlightByMonthResp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public label: string;
|
public label: string;
|
||||||
|
public label2: string;
|
||||||
public nb: number;
|
public nb: number;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user