ProSchedulerSign in

Timeline · Configuring the view

Event buffer

Loading before and unloading after each route, as hatched buffers that other routes on the same vehicle can't use.

Live demo

Push a route into the one before it · Pull it back into the gap

Fullscreen
import { ProScheduler, type PschValidationFailure } from "@andreisaac/pro-scheduler"
import { deliveries, fleet } from "./data/operations"
import { Log, useEvents, useLog } from "./kit"

function reason(failure: PschValidationFailure) {
  return failure.reason === "invalid"
    ? `blocked (${failure.invalid?.title ?? "unavailable"})`
    : `overlaps "${failure.overlapping?.title}"`
}

const day = (base: Date, n: number) => new Date(base.getFullYear(), base.getMonth(), base.getDate() + n)

export function TimelineBufferDemo() {
  const { events, handlers } = useEvents(() =>
    // Loading and unloading around each route.
    deliveries().map((route) => ({ ...route, bufferBefore: 30, bufferAfter: 20 }))
  )
  const { lines, log } = useLog()

  return (
    <div className="docs-demo__stack">
      <ProScheduler
        data={events}
        resources={fleet}
        view={{ timeline: { type: "day", dragTimeStep: 15 } }}
        styleConfig={{ unitWidthPx: 64, fitToWidth: false }}
        eventOverlap={false}
        onEventUpdateFailed={(f) => log(`${f.event.title} ${reason(f)}, loading time included`)}
        height={440}
        {...handlers}
      />
      <Log lines={lines} empty="Push a route into another's loading time…" />
    </div>
  )
}

About this demo

Loading before and unloading after each route, as hatched buffers that other routes on the same vehicle can't use.

Things to try

  • Push a route into the one before it
  • Pull it back into the gap

The props behind it are explained in Rules and backgrounds.

Use ProScheduler in your project