Added Charts

This commit is contained in:
2026-04-11 20:49:01 +10:00
parent e83fd3bdca
commit 95624f345c
16 changed files with 979 additions and 386 deletions
@@ -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) },