ProSchedulerSign in

Timeline · Configuring the view

Zoom

zoomLevels lists the steps, from weeks down to 15 minutes; the header's zoom control (or zoomIn, zoomOut and setZoom on the instance) moves between them.

Live demo

Scroll to a date, then zoom in · Zoom back out

Fullscreen
import { ProScheduler, type PschZoomLevel } from "@andreisaac/pro-scheduler"
import { studioAssignments, studioResources } from "./data/studio"
import { useEvents } from "./kit"

const zoomLevels: PschZoomLevel[] = [
  { label: "Weeks", resolutionHorizontal: "week", unitWidthPx: 160 },
  { label: "Days", resolutionHorizontal: "day", unitWidthPx: 64 },
  { label: "6 hours", resolutionHorizontal: "hour", timeCellStep: 360, unitWidthPx: 40 },
  { label: "Hours", resolutionHorizontal: "hour", unitWidthPx: 36 },
  { label: "15 min", resolutionHorizontal: "hour", timeCellStep: 15, unitWidthPx: 36 },
]

export function TimelineZoomDemo() {
  const { events, handlers } = useEvents(() => studioAssignments())
  return (
    <ProScheduler
      data={events}
      resources={studioResources}
      view={{ timeline: { type: "month", zoomLevels, zoomLevel: 1 } }}
      styleConfig={{ fitToWidth: false }}
      height={520}
      {...handlers}
    />
  )
}

About this demo

zoomLevels lists the steps, from weeks down to 15 minutes; the header's zoom control (or zoomIn, zoomOut and setZoom on the instance) moves between them.

Zooming keeps the date in the middle of the view in place.

Things to try

  • Scroll to a date, then zoom in
  • Zoom back out

The props behind it are explained in Scales, ranges and zoom.

Use ProScheduler in your project