Agent-readable demo data
- Title
- Milestones (JavaScript Scheduler) | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- Read more about milestones.
Inline demo script 1
const dp = new DayPilot.Scheduler("dp", {
startDate: "2026-01-01",
days: 365,
scale: "Day",
timeHeaders: [
{groupBy: "Month", format: "MMM yyyy"},
{groupBy: "Cell", format: "d"}
],
treeEnabled: true,
treePreventParentUsage: true,
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"}
]
}
],
heightSpec: "Max",
height: 500,
eventMovingStartEndEnabled: true,
eventResizingStartEndEnabled: true,
timeRangeSelectingStartEndEnabled: true,
onTimeRangeSelected: async args => {
const modal = await DayPilot.Modal.prompt("New event name:", "New Event");
dp.clearSelection();
const name = modal.result;
if (!name) return;
dp.events.add({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: name
});
dp.message("Created");
},
});
dp.init();
dp.scrollTo("2026-03-01");
const app = {
init() {
this.loadEventData();
},
loadEventData() {
const events = [];
for (var i = 0; i < 4; i++) {
var duration = Math.floor(Math.random() * 6) + 1; // 1 to 6
var durationDays = Math.floor(Math.random() * 6) + 1; // 1 to 6
var start = Math.floor(Math.random() * 6) + 2; // 2 to 7
var e = {
start: new DayPilot.Date("2026-03-05T00:00:00").addDays(start),
end: new DayPilot.Date("2026-03-05T12:00:00").addDays(start).addDays(durationDays).addHours(duration),
id: DayPilot.guid(),
resource: String.fromCharCode(65 + i),
text: "Event " + (i + 1),
bubbleHtml: "Event " + (i + 1),
barColor: app.barColor(i),
barBackColor: app.barBackColor(i)
};
events.push(e);
}
events.push({
start: "2026-03-02T00:00:00",
resource: "A",
id: DayPilot.guid(),
type: "Milestone",
htmlRight: "Milestone 1",
});
dp.update({events});
},
barColor(i) {
var colors = ["#3c78d8", "#6aa84f", "#f1c232", "#cc0000"];
return colors[i % 4];
},
barBackColor(i) {
var colors = ["#a4c2f4", "#b6d7a8", "#ffe599", "#ea9999"];
return colors[i % 4];
}
};
app.init();