The grid cells display peak resource utilization calculated from a custom
"percentage" event field. Read more about calculating
resource utilization [doc.daypilot.org].
Agent-readable demo data
- Title
- Resource Utilization (JavaScript Scheduler) | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- The grid cells display peak resource utilization calculated from a custom
"percentage" event field. Read more about calculating resource utilization [doc.daypilot.org].
Inline demo script 1
const dp = new DayPilot.Scheduler("dp", {
startDate: "2026-01-01",
days: 365,
scale: "Day",
timeHeaders: [
{groupBy: "Month", format: "MMMM yyyy"},
{groupBy: "Cell", format: "d"}
],
cellWidth: 80,
eventHeight: 40,
rowMarginTop: 26,
beforeCellRenderCaching: false,
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"},
],
onBeforeCellRender: args => {
const moreThan = app.moreThan;
const utilization = args.cell.utilization("percentage");
const visible = utilization > moreThan;
if (visible) {
const opacity = (utilization / 100) * 0.7 + 0.3;
args.cell.areas = [
{
left: 2,
top: 2,
right: 2,
height: 20,
// dark orange
backColor: "#6aa84f",
fontColor: "white",
padding: 2,
html: utilization + "%",
horizontalAlignment: "center",
style: `opacity: ${opacity}; border-radius: 10px;`
}
];
}
},
onBeforeEventRender: args => {
args.e.bubbleHtml = `<div><b>${args.e.text}</b></div><div>Start: ${new DayPilot.Date(args.e.start).toString("M/d/yyyy")}</div>`;
},
onEventMoved: args => {
dp.message(`Moved: ${args.e.text()}`);
},
onEventResized: args => {
dp.message(`Resized: ${args.e.text()}`);
},
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");
},
onEventClicked: args => {
alert(`clicked: ${args.e.id()}`);
},
onTimeHeaderClick: args => {
console.log(args.header);
alert(`clicked: ${args.header.start}`);
},
height: 300
});
const app = {
moreThan: 0,
init() {
dp.init();
dp.scrollTo("2026-03-25");
this.addEventHandlers();
this.loadEventData();
},
loadEventData() {
const events = [];
for (let i = 0; i < 15; i++) {
const durationDays = Math.floor(Math.random() * 6 + 2); //2 to 7
const start = Math.floor(Math.random() * 6) + 2; // 2 to 7
const res = Math.floor(Math.random() * 6); // 0 to 5
const event = {
start: new DayPilot.Date("2026-03-25T00:00:00").addDays(start),
end: new DayPilot.Date("2026-03-25T00:00:00").addDays(start).addDays(durationDays),
id: DayPilot.guid(),
resource: String.fromCharCode(65 + res),
percentage: 10 + i,
text: (10 + i) + "%",
bubbleHtml: "Utilization: " + (10 + i) + "%"
};
events.push(event);
}
dp.update({events});
},
addEventHandlers() {
document.querySelector("#all").addEventListener("click", (ev) => {
ev.preventDefault();
this.moreThan = 0;
dp.update();
});
document.querySelector("#over30").addEventListener("click", (ev) => {
ev.preventDefault();
this.moreThan = 30;
dp.update();
});
document.querySelector("#over50").addEventListener("click", (ev) => {
ev.preventDefault();
this.moreThan = 50;
dp.update();
});
}
};
app.init();