If you use scale: "Hour"
, which displays one hour per cell, you can hide the non-business hours using the built-in mechanism.
React example:
import React, { useState } from 'react';
import { DayPilot, DayPilotScheduler } from "daypilot-pro-react";
const Scheduler = () => {
const [config, setConfig] = useState({
startDate: DayPilot.Date.today().firstDayOfMonth(),
days: DayPilot.Date.today().daysInMonth(),
scale: "Hour",
businessBeginsHour: 9,
businessEndsHour: 21,
showNonBusiness: false,
timeHeaders: [
{ groupBy: "Month" },
{ groupBy: "Day", format: "d" },
{ groupBy: "Cell", format: "h tt" }
],
});
return (
<DayPilotScheduler
{...config}
/>
);
};
export default Scheduler;
If you want to display one day per cell, where each day is limited to the 9 AM - 9 PM range, you can generate a custom timeline.
React example:
import React, { useState, useEffect } from 'react';
import { DayPilot, DayPilotScheduler } from "daypilot-pro-react";
const Scheduler = () => {
const createTimeline = () => {
const days = DayPilot.Date.today().daysInMonth();
const start = DayPilot.Date.today().firstDayOfMonth();
const result = [];
for (let i = 0; i < days; i++) {
const day = start.addDays(i);
result.push({
start: day.addHours(9),
end: day.addHours(21) // 9 PM is represented as 21 in 24-hour time
});
}
return result;
}
const [config, setConfig] = useState({
timeline: createTimeline(),
scale: "Manual",
timeHeaders: [
{ groupBy: "Month" },
{ groupBy: "Day", format: "d" },
],
});
return (
<DayPilotScheduler
{...config}
/>
);
};
export default Scheduler;
The timeline
property replaces the startDate
, days
, scale
, and showNonBusiness
properties which are otherwise used to generate the timeline automatically.
This approach can be used to create custom time units (such as shifts, which you can see in the React Shift Scheduling tutorial).