Hover over a time header to see a bubble with the date. The contents of the
time header bubble can be defined statically or generated dynamically in the
onLoad handler.
Agent-readable demo data
- Title
- Time Header Bubble (JavaScript Scheduler) | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- Hover over a time header to see a bubble with the date. The contents of the time header bubble can be defined statically or generated dynamically in the onLoad handler.
Inline demo script 1
const dp = new DayPilot.Scheduler("dp", {
startDate: "2026-04-01",
days: 365,
scale: "Day",
timeHeaders: [
{groupBy: "Month", format: "MMMM yyyy"},
{groupBy: "Day", format: "d"}
],
treeEnabled: true,
heightSpec: "Max",
height: 400,
onTimeRangeSelected: async (args) => {
const modal = await DayPilot.Modal.prompt("New event name:", "New Event")
dp.clearSelection();
if (modal.canceled) {
return;
}
const name = modal.result;
dp.events.add({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: name
});
dp.message("Created");
},
timeHeaderBubble: new DayPilot.Bubble({
onLoad: (args) => {
const p = args.source;
const date = p.start.toString("M/d/yyyy");
args.html = `<div>${date}</div>`;
}
})
});
dp.init();
dp.scrollTo("2026-04-01");
const app = {
barColor(i) {
const colors = ["#3c78d8", "#6aa84f", "#f1c232", "#cc0000"];
return colors[i % 4];
},
barBackColor(i) {
const colors = ["#a4c2f4", "#b6d7a8", "#ffe599", "#ea9999"];
return colors[i % 4];
},
loadData() {
const resources = [
{
name: "Locations", id: "G1", expanded: true, children: [
{name: "Room 1", id: "A"},
{name: "Room 2", id: "B"},
{name: "Room 3", id: "C"},
{name: "Room 4", id: "D"},
]
},
{
name: "People", id: "G2", expanded: true, children: [
{name: "Person 1", id: "E"},
{name: "Person 2", id: "F"},
{name: "Person 3", id: "G"},
{name: "Person 4", id: "H"}
]
},
{
name: "Tools", id: "G3", expanded: true, children: [
{name: "Tool 1", id: "I"},
{name: "Tool 2", id: "J"},
{name: "Tool 3", id: "K"},
{name: "Tool 4", id: "L"}
]
},
{
name: "Other Resources", id: "G4", expanded: true, children: [
{name: "Resource 1", id: "R1"},
{name: "Resource 2", id: "R2"},
{name: "Resource 3", id: "R3"},
{name: "Resource 4", id: "R4"}
]
},
];
const events = [];
for (let i = 0; i < 12; i++) {
const duration = Math.floor(Math.random() * 6) + 1; // 1 to 6
const durationDays = Math.floor(Math.random() * 6) + 1; // 1 to 6
const start = Math.floor(Math.random() * 6) + 2; // 2 to 7
const e = {
start: new DayPilot.Date("2026-04-05T12:00:00").addDays(start),
end: new DayPilot.Date("2026-04-05T12:00:00").addDays(start).addDays(durationDays).addHours(duration),
id: i + 1,
resource: String.fromCharCode(65 + i),
text: "Event " + (i + 1),
bubbleHtml: "Event " + (i + 1),
barColor: app.barColor(i),
barBackColor: app.barBackColor(i)
};
events.push(e);
}
dp.update({resources, events});
},
};
app.loadData();