Added Charts
This commit is contained in:
@@ -19,12 +19,18 @@ const props = defineProps<{
|
||||
upcomingFlights: Flight[]
|
||||
}>()
|
||||
|
||||
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
||||
const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
||||
|
||||
const monthIndex = (f: Flight): number => {
|
||||
const date = new Date(f.departure_date)
|
||||
return Number(new Intl.DateTimeFormat('en', {
|
||||
timeZone: f.departure_airport.timezone,
|
||||
month: 'numeric',
|
||||
}).format(date)) - 1 // numeric returns 1-12, convert to 0-indexed
|
||||
}
|
||||
|
||||
const countByMonth = (list: Flight[]) =>
|
||||
MONTHS.map((_, i) =>
|
||||
list.filter(f => new Date(f.departure_date).getMonth() === i).length
|
||||
)
|
||||
MONTHS.map((_, i) => list.filter(f => monthIndex(f) === i).length)
|
||||
|
||||
const series = computed(() => [
|
||||
{ name: 'Flown', data: countByMonth(props.flights) },
|
||||
|
||||
Reference in New Issue
Block a user