Gantt Chart API

Complete API reference for the RSL Gantt Chart component

Quick Start

Add data-rsl-gantt to any container with a table inside:

Basic Usage
<div data-rsl-gantt data-gantt-zoom="week">
    <table>
        <tbody>
            <tr data-task-id="1">
                <td>Task Name</td>
                <td>2024-12-01</td>
                <td>2024-12-10</td>
                <td>50</td>
            </tr>
        </tbody>
    </table>
</div>

Data Attributes - Container

AttributeValuesDefaultDescription
data-rsl-gantt--Required. Enables Gantt chart
data-gantt-zoomday|week|month|quarter|yearweekInitial zoom level
data-gantt-editabletrue|falsetrueAllow drag/resize
data-gantt-show-progresstrue|falsetrueShow progress bars
data-gantt-show-todaytrue|falsetrueShow today line
data-gantt-show-dependenciestrue|falsetrueShow dependency arrows
data-gantt-show-task-listtrue|falsetrueShow left panel
data-gantt-exportabletrue|falsetrueShow export button
data-gantt-row-heightNumber (px)40Height of each row

Data Attributes - Tasks (Table Rows)

AttributeValuesDescription
data-task-idStringUnique task identifier
data-task-typetask|milestone|groupTask type (default: task)
data-task-parentTask IDParent task for hierarchy
data-task-dependsComma-separated IDsDependency relationships
data-task-colorblue|green|purple|orange|teal|pink|redBar color
data-task-progress0-100Completion percentage
data-task-assigneeStringPerson assigned

JavaScript API

Creating a Gantt Chart

RSL.Gantt.create()
const gantt = RSL.Gantt.create('#container', {
    zoom: 'week',
    editable: true,
    showProgress: true,
    tasks: [
        { id: '1', name: 'Task 1', start: '2024-12-01', end: '2024-12-10', progress: 50 },
        { id: '2', name: 'Milestone', start: '2024-12-15', type: 'milestone', depends: ['1'] }
    ],
    onTaskUpdate: (task) => console.log('Updated:', task),
    onTaskClick: (task) => console.log('Clicked:', task)
});

Instance Methods

MethodParametersReturnsDescription
setZoom(level)day|week|month|quarter|year-Change zoom level
getZoom()-StringGet current zoom
scrollToToday()--Scroll to today's date
scrollToTask(id)Task ID-Scroll to a task
addTask(data)Task objectTaskAdd a new task
updateTask(id, data)ID, updatesTaskUpdate a task
deleteTask(id)Task IDBooleanDelete a task
getTasks()-ArrayGet all tasks
getTask(id)Task IDTaskGet single task
getSelectedTasks()-ArrayGet selected tasks
expandAll()--Expand all groups
collapseAll()--Collapse all groups
refresh()--Re-render chart
destroy()--Remove instance

Events

EventDetailDescription
rsl-gantt:init{ instance }Chart initialized
rsl-gantt:taskCreate{ task }Task added
rsl-gantt:taskUpdate{ task }Task modified
rsl-gantt:taskDelete{ task }Task removed
rsl-gantt:zoomChange{ zoom }Zoom level changed

Next Steps

See Examples

View demos

Playground

Try it out

Components

All components