Advanced Features
Working Calendars
GanttCraft supports different working calendars for date arithmetic. The default is AllDayCalendar (24/7). You can use StandardCalendar to automatically skip weekends (Saturday/Sunday) when dragging tasks or auto-scheduling dependencies.
import { GanttChart, StandardCalendar } from 'ganttcraft';
<GanttChart
tasks={tasks}
calendar={StandardCalendar}
/>Critical Path Analysis
Enable showCriticalPath to highlight tasks that have zero float (tasks that directly impact the project end date). These tasks will be highlighted in red (customizable via theme).
<GanttChart tasks={tasks} showCriticalPath />Resource Leveling & Allocation
Display a resource allocation histogram by enabling showResourcePanel. Enable automatic resource overallocation resolution by passing autoLevelResources.
const resources: GanttResource[] = [
{ id: 'alice', name: 'Alice', maxUnits: 1.0 }
];
<GanttChart
tasks={tasks}
resources={resources}
autoSchedule
autoLevelResources
showResourcePanel
onTasksChange={setTasks}
/>History Manager (Undo/Redo)
GanttCraft provides a HistoryManager to handle undo/redo operations. You can access it via the useGanttContext() hook for custom UI controls!
Plugins
Extend GanttCraft by passing an array of plugins to the plugins prop. Plugins can intercept task updates or render custom overlays.
const myPlugin = {
name: 'my-custom-plugin',
beforeUpdateTask: (task) => {
if (task.start < new Date()) return false;
return true;
},
renderTaskOverlay: (task) => (
task.isOverdue ? <div className="text-red-500">!</div> : null
)
};
<GanttChart tasks={tasks} plugins={[myPlugin]} />PNG Export
Export the current chart view as a PNG image. GanttCraft automatically inline custom properties to ensure your exact theme exports perfectly.
import { exportPNG } from 'ganttcraft';
const svgEl = document.querySelector('.gantt-svg') as SVGSVGElement;
await exportPNG(svgEl, 'my-project-gantt.png');