ProSchedulerSign in

Timeline · Configuring the view

Multiple scales

resolutionHorizontal picks the column unit — hour, day, week, month, quarter or year — independently of the span. The header shows the unit above it, and weekNumbers adds a tier of week numbers.

Live demo

Try each scale · Turn week numbers off

Fullscreen
import { useState } from "react"
import { ProScheduler, type HorizontalResolution } from "@andreisaac/pro-scheduler"
import { studioAssignments, studioResources } from "./data/studio"
import { Choice, Toolbar, useEvents } from "./kit"

const scales: { label: string; type: "day" | "week" | "month" | "year"; unit: HorizontalResolution; width: number }[] = [
  { label: "Week × hours", type: "week", unit: "hour", width: 26 },
  { label: "Month × days", type: "month", unit: "day", width: 56 },
  { label: "Quarter × weeks", type: "month", unit: "week", width: 120 },
  { label: "Year × months", type: "year", unit: "month", width: 110 },
  { label: "Year × quarters", type: "year", unit: "quarter", width: 260 },
]

export function MultipleScalesDemo() {
  const { events, handlers } = useEvents(() => studioAssignments())
  const [scale, setScale] = useState(1)
  const [weekNumbers, setWeekNumbers] = useState(true)
  const s = scales[scale]
  return (
    <>
      <Toolbar label="Scale">
        {scales.map((option, i) => (
          <Choice key={option.label} active={scale === i} onClick={() => setScale(i)}>
            {option.label}
          </Choice>
        ))}
        <Choice active={weekNumbers} onClick={() => setWeekNumbers((on) => !on)}>
          Week numbers
        </Choice>
      </Toolbar>
      <ProScheduler
        data={events}
        resources={studioResources}
        view={{
          timeline: {
            type: s.type,
            // three months of weeks
            size: s.unit === "week" ? 3 : 1,
            resolutionHorizontal: s.unit,
            unitWidthPx: s.width,
            weekNumbers,
          },
        }}
        styleConfig={{ fitToWidth: false }}
        height={520}
        {...handlers}
      />
    </>
  )
}

About this demo

resolutionHorizontal picks the column unit — hour, day, week, month, quarter or year — independently of the span. The header shows the unit above it, and weekNumbers adds a tier of week numbers.

Things to try

  • Try each scale
  • Turn week numbers off

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

Use ProScheduler in your project