Timeline · Use cases
Monthly timetable
A school month at a glance: weekdays only (startDay/endDay), each day column covering just the school hours (startTime/endTime), with a row of week numbers.
Live demo
Move a lesson to another day · Page to next month
Fullscreenimport { ProScheduler, type SchedulerEvent } from "@andreisaac/pro-scheduler"
import { classes, rooms } from "./data/bookings"
import { useEvents } from "./kit"
export function MonthlyTimetableDemo() {
// The school's weekly lessons, repeated on every weekday of the month.
const { events, handlers } = useEvents<SchedulerEvent>(() => {
const now = new Date()
const last = new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate()
const all: SchedulerEvent[] = []
for (let day = 1; day <= last; day++) {
const date = new Date(now.getFullYear(), now.getMonth(), day)
if (date.getDay() === 0 || date.getDay() === 6) continue
for (const lesson of classes(date)) all.push({ ...lesson, id: `${lesson.id}-${day}` })
}
return all
})
return (
<ProScheduler
data={events}
resources={rooms}
view={{
timeline: {
type: "month",
startDay: 1,
endDay: 5,
startTime: "08:00",
endTime: "17:00",
weekNumbers: true,
},
}}
styleConfig={{ unitWidthPx: 90, fitToWidth: true }}
height={520}
{...handlers}
/>
)
}// data/bookings.ts — sample data, relative to the current week or month.
import type { SchedulerEvent, SchedulerResource } from "@andreisaac/pro-scheduler"
const at = (base: Date, day: number, hour: number, minute = 0) =>
new Date(base.getFullYear(), base.getMonth(), base.getDate() + day, hour, minute)
export const rooms: SchedulerResource[] = [
{ id: "lab-1", name: "Science lab", capacity: 24, color: "#0891b2" },
{ id: "room-12", name: "Room 12", capacity: 30, color: "#2563eb" },
{ id: "room-14", name: "Room 14", capacity: 30, color: "#7c3aed" },
{ id: "hall", name: "Assembly hall", capacity: 200, color: "#d97706" },
{ id: "gym", name: "Gym", capacity: 60, color: "#059669" },
{ id: "music", name: "Music room", capacity: 20, color: "#db2777" },
]
const lessons: [string, string, number, number][] = [
["lab-1", "Chemistry 10A", 8, 2],
["lab-1", "Biology 9C", 13, 2],
["room-12", "Maths 11B", 8, 1],
["room-12", "History 10A", 10, 1],
["room-12", "English 9A", 14, 1],
["room-14", "French 8B", 9, 1],
["room-14", "Geography 10C", 11, 1],
["room-14", "Maths 9A", 15, 1],
["hall", "Assembly", 8, 1],
["hall", "Exam: Physics", 13, 3],
["gym", "PE 8A", 9, 2],
["gym", "PE 11C", 14, 1],
["music", "Choir", 10, 1],
["music", "Band practice", 15, 2],
]
/** Today's lessons, one class per room at a time. */
export function classes(today = new Date()): SchedulerEvent[] {
return lessons.map(([room, title, hour, hours], i) => {
const start = new Date(today.getFullYear(), today.getMonth(), today.getDate(), hour)
return {
id: `class-${i + 1}`,
title,
resource: room,
start,
end: new Date(start.getTime() + hours * 3_600_000),
}
})
}About this demo
A school month at a glance: weekdays only (startDay/endDay), each day column covering just the school hours (startTime/endTime), with a row of week numbers.
Lessons sit inside their day in proportion to the hours shown.
Things to try
- Move a lesson to another day
- Page to next month
The props behind it are explained in Scales, ranges and zoom.