Agent-readable demo data

Title
Time Scale: Custom (JavaScript Scheduler) | DayPilot Pro for JavaScript Demo
Tree
DayPilot JavaScript Demo
Catalog root
Default
Description
This example uses a custom timeline defined using individual cells. Note that the timeline is not linear - the first month displays one day per cell, while the last three cells show a month each. Read more about the scheduler timeline customization [doc.daypilot.org].

Inline demo script 1

const dp = new DayPilot.Scheduler("dp", {
            // view
            timeHeaders: [
                {groupBy: "Year"},
                {groupBy: "Month"},
                {groupBy: "Cell", format: "d"}
            ],
            scale: "Manual",
            timeline: createTimeline(),
            treeEnabled: true,
            resources: [
                {name: "Room A", id: "A"},
                {name: "Room B", id: "B"},
                {name: "Room C", id: "C"},
                {name: "Room D", id: "D"},
                {name: "Room E", id: "E"},
                {name: "Room F", id: "F"},
                {name: "Room G", id: "G"},
                {name: "Room H", id: "H"},
                {name: "Room I", id: "I"},
                {name: "Room J", id: "J"},
                {name: "Room K", id: "K"},
            ],
            onTimeRangeSelected: async args => {
                const modal = await DayPilot.Modal.prompt("New event name:", "Event");
                dp.clearSelection();
                if (modal.canceled) {
                    return;
                }
                dp.events.add({
                    start: args.start,
                    end: args.end,
                    id: DayPilot.guid(),
                    resource: args.resource,
                    text: modal.result
                });
                dp.message("Created");
            },
            onBeforeTimeHeaderRender: args => {
                if (args.header.level === 2) {
                    var duration = new DayPilot.Duration(args.header.start, args.header.end);
                    if (duration.totalDays() > 1) {
                        args.header.html = "";
                    }
                }
            },
            height: 350
        });
        dp.init();

        function createTimeline() {
            const timeline = [];
            const start = new DayPilot.Date("2026-03-01");
            for (let i = 0; i < 31; i++) {
                const day = {};
                day.start = start.addDays(i);
                day.end = day.start.addDays(1);
                timeline.push(day);
            }

            for (let i = 0; i < 3; i++) {
                const month = {};
                month.start = start.addDays(31).addMonths(i);
                month.end = month.start.addMonths(1);
                month.width = 100;
                timeline.push(month);
            }
            return timeline;
        }