Added Charts
This commit is contained in:
@@ -19,10 +19,16 @@ const props = defineProps<{
|
||||
upcomingFlights: Flight[]
|
||||
}>()
|
||||
|
||||
const flightYear = (f: Flight): number =>
|
||||
Number(new Intl.DateTimeFormat('en', {
|
||||
timeZone: f.departure_airport.timezone,
|
||||
year: 'numeric',
|
||||
}).format(new Date(f.departure_date)))
|
||||
|
||||
const years = computed(() => {
|
||||
const allYears = new Set<number>()
|
||||
;[...props.flights, ...props.upcomingFlights].forEach(f =>
|
||||
allYears.add(new Date(f.departure_date).getFullYear())
|
||||
allYears.add(flightYear(f))
|
||||
)
|
||||
const sorted = [...allYears].sort((a, b) => a - b)
|
||||
|
||||
@@ -36,10 +42,9 @@ const years = computed(() => {
|
||||
|
||||
return Array.from({ length: max - min + 1 }, (_, i) => min + i)
|
||||
})
|
||||
|
||||
const countByYear = (list: Flight[]) =>
|
||||
years.value.map(year =>
|
||||
list.filter(f => new Date(f.departure_date).getFullYear() === year).length
|
||||
)
|
||||
years.value.map(year => list.filter(f => flightYear(f) === year).length)
|
||||
|
||||
const series = computed(() => [
|
||||
{ name: 'Flown', data: countByYear(props.flights) },
|
||||
|
||||
Reference in New Issue
Block a user