Timeline · Use cases
Transport management
Today's delivery routes per vehicle, at hour resolution, with plate and capacity in the resource column.
Live demo
Move a route to another van · Shorten a route by 15 minutes
Fullscreenimport { ProScheduler } from "@andreisaac/pro-scheduler"
import { deliveries, fleet } from "./data/operations"
import { useEvents } from "./kit"
const hhmm = (d: Date) => d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })
export function TransportDemo() {
const { events, handlers } = useEvents(deliveries)
return (
<ProScheduler
data={events}
resources={fleet}
view={{ timeline: { type: "day", dragTimeStep: 15 } }}
styleConfig={{ unitWidthPx: 64, laneHeight: 38, resourceColWidth: 200 }}
renderResource={(vehicle) => (
<div className="min-w-0">
<div className="truncate text-sm font-medium">{vehicle.name}</div>
<div className="truncate text-xs text-muted-foreground">
{String(vehicle.plate)} · {String(vehicle.capacity)}
</div>
</div>
)}
renderEventContent={({ original, start, end }) => (
<div className="grid min-w-0 text-[11px] leading-tight">
<strong className="truncate">{original.title}</strong>
<span className="truncate opacity-85">
{hhmm(start)}–{hhmm(end)}
</span>
</div>
)}
height={440}
{...handlers}
/>
)
}// data/operations.ts — sample data, relative to the current week or month.
import type { SchedulerEvent, SchedulerResource } from "@andreisaac/pro-scheduler"
export type Delivery = SchedulerEvent & {
id: string
start: Date
end: Date
resource: string
stops: number
kind: "Delivery" | "Pickup" | "Maintenance"
}
export const fleet: SchedulerResource[] = [
{ id: "v1", name: "Van 01", plate: "AB-12-CD", capacity: "1.2 t", color: "#2563eb" },
{ id: "v2", name: "Van 02", plate: "EF-34-GH", capacity: "1.2 t", color: "#059669" },
{ id: "v3", name: "Truck 03", plate: "IJ-56-KL", capacity: "7.5 t", color: "#d97706" },
{ id: "v4", name: "Truck 04", plate: "MN-78-OP", capacity: "7.5 t", color: "#7c3aed" },
{ id: "v5", name: "Cargo bike 05", plate: "—", capacity: "150 kg", color: "#db2777" },
{ id: "v6", name: "Van 06", plate: "QR-90-ST", capacity: "1.2 t", color: "#0891b2" },
]
/** Today's routes at hour resolution. */
export function deliveries(today = new Date()): Delivery[] {
const at = (h: number, m = 0) => new Date(today.getFullYear(), today.getMonth(), today.getDate(), h, m)
const rows: [string, number, number, number, number, Delivery["kind"], number][] = [
["v1", 7, 0, 10, 30, "Delivery", 9],
["v1", 12, 0, 15, 0, "Delivery", 7],
["v2", 8, 0, 11, 0, "Pickup", 5],
["v2", 13, 30, 17, 0, "Delivery", 11],
["v3", 6, 0, 12, 0, "Delivery", 4],
["v3", 14, 0, 16, 0, "Maintenance", 0],
["v4", 9, 0, 17, 30, "Delivery", 6],
["v5", 8, 30, 11, 30, "Delivery", 14],
["v5", 12, 30, 15, 30, "Delivery", 12],
["v6", 10, 0, 13, 0, "Pickup", 3],
["v6", 15, 0, 18, 0, "Delivery", 8],
]
return rows.map(([resource, sh, sm, eh, em, kind, stops], i) => ({
id: `route-${i + 1}`,
title: kind === "Maintenance" ? "Service" : `${kind} · ${stops} stops`,
start: at(sh, sm),
end: at(eh, em),
resource,
kind,
stops,
color: kind === "Maintenance" ? "#64748b" : undefined,
}))
}About this demo
Today's delivery routes per vehicle, at hour resolution, with plate and capacity in the resource column.
Things to try
- Move a route to another van
- Shorten a route by 15 minutes
The props behind it are explained in Resources.