gantt-task-react-v 1.5.26 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +659 -103
- package/dist/components/task-item/bar/bar-display.d.ts +1 -0
- package/dist/components/task-list/task-list-table-columns/assignees-column.d.ts +3 -0
- package/dist/components/task-list/task-list-table-columns/use-task-list-columns-builder.d.ts +6 -0
- package/dist/gantt-task-react.es.js +167 -44
- package/dist/gantt-task-react.umd.js +167 -44
- package/dist/types/public-types.d.ts +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,133 +1,689 @@
|
|
|
1
|
-
#
|
|
1
|
+
# gantt-task-react-v
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Interactive Gantt Chart for React with TypeScript.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install gantt-task-react-v
|
|
9
|
+
```
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
- Fixed sticky gantt header on drag
|
|
9
|
-
- Fixed Tooltip should show only on gantt section current view boundaries
|
|
10
|
-
- Added Tooltip for comparison bars
|
|
11
|
-
- Show Custom Data Date Line
|
|
12
|
-
- Customize Data Date Line and Today Line Color and Label
|
|
13
|
-
- Show/Hide Task Table Column
|
|
14
|
-
- Improved staggered and rounded arrows
|
|
15
|
-
- RightClick ContextMenu option for Tasklist and Gantt
|
|
16
|
-
- Custom Drawer on click taskbar and arrow, callback to get taskdata
|
|
11
|
+
## Quick Start
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
```tsx
|
|
14
|
+
import { Gantt, Task, ViewMode } from "gantt-task-react-v";
|
|
15
|
+
import "gantt-task-react-v/dist/style.css";
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
const tasks: Task[] = [
|
|
18
|
+
{
|
|
19
|
+
id: "task-1",
|
|
20
|
+
type: "task",
|
|
21
|
+
name: "Design",
|
|
22
|
+
start: new Date(2026, 0, 1),
|
|
23
|
+
end: new Date(2026, 0, 10),
|
|
24
|
+
progress: 60,
|
|
25
|
+
assignees: ["Alice"],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "task-2",
|
|
29
|
+
type: "task",
|
|
30
|
+
name: "Development",
|
|
31
|
+
start: new Date(2026, 0, 11),
|
|
32
|
+
end: new Date(2026, 1, 15),
|
|
33
|
+
progress: 20,
|
|
34
|
+
dependencies: [
|
|
35
|
+
{
|
|
36
|
+
sourceId: "task-1",
|
|
37
|
+
sourceTarget: "endOfTask",
|
|
38
|
+
ownTarget: "startOfTask",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
assignees: ["Bob", "Carol"],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "milestone-1",
|
|
45
|
+
type: "milestone",
|
|
46
|
+
name: "MVP Release",
|
|
47
|
+
start: new Date(2026, 1, 15),
|
|
48
|
+
end: new Date(2026, 1, 15),
|
|
49
|
+
progress: 0,
|
|
50
|
+
dependencies: [
|
|
51
|
+
{
|
|
52
|
+
sourceId: "task-2",
|
|
53
|
+
sourceTarget: "endOfTask",
|
|
54
|
+
ownTarget: "startOfTask",
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
];
|
|
21
59
|
|
|
60
|
+
function App() {
|
|
61
|
+
return <Gantt tasks={tasks} viewMode={ViewMode.Day} />;
|
|
62
|
+
}
|
|
22
63
|
```
|
|
23
|
-
|
|
64
|
+
|
|
65
|
+
## Core Features
|
|
66
|
+
|
|
67
|
+
### 1. Task List (WBS)
|
|
68
|
+
|
|
69
|
+
Hierarchical work breakdown structure with expand/collapse, nested numbering, drag-and-drop reordering, and resizable columns.
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
<Gantt
|
|
73
|
+
tasks={tasks}
|
|
74
|
+
taskList={{
|
|
75
|
+
isShowTaskNumbers: true,
|
|
76
|
+
canReorderTasks: true,
|
|
77
|
+
canResizeColumns: true,
|
|
78
|
+
canToggleColumns: true,
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 2. Timeline
|
|
84
|
+
|
|
85
|
+
Horizontal time scale supporting multiple view modes.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
<Gantt tasks={tasks} viewMode={ViewMode.Week} viewDate={new Date()} />
|
|
24
89
|
```
|
|
25
90
|
|
|
26
|
-
|
|
91
|
+
**ViewMode values:** `Hour`, `QuarterDay`, `HalfDay`, `Day`, `Week`, `Month`, `Year`
|
|
92
|
+
|
|
93
|
+
### 3. Task Bars
|
|
27
94
|
|
|
28
|
-
|
|
29
|
-
import { Gantt, Task, EventOption, StylingOption, ViewMode, DisplayOption } from 'gantt-task-react';
|
|
30
|
-
import "gantt-task-react/dist/index.css";
|
|
95
|
+
Bars represent duration and are drag-resizable. Hold **Ctrl** to show start/end drag handles.
|
|
31
96
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
97
|
+
Progress is displayed as a filled overlay with a percentage label on the bar. The progress drag handle allows interactive editing.
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
<Gantt
|
|
101
|
+
tasks={tasks}
|
|
102
|
+
showProgress={true}
|
|
103
|
+
progressColor="#4dabf7"
|
|
104
|
+
taskBar={{
|
|
105
|
+
isProgressChangeable: task => !task.isDisabled,
|
|
106
|
+
isDateChangeable: task => !task.isDisabled,
|
|
107
|
+
allowMoveTaskBar: (action, task) => true,
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 4. Dependencies (Arrows)
|
|
113
|
+
|
|
114
|
+
Arrows link tasks to define execution order. Supports four relation kinds.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
<Gantt
|
|
118
|
+
tasks={tasks}
|
|
119
|
+
authorizedRelations={["endToStart", "startToStart", "endToEnd", "startToEnd"]}
|
|
120
|
+
taskBar={{
|
|
121
|
+
isRelationChangeable: task => true,
|
|
122
|
+
isDeleteDependencyOnDoubleClick: true,
|
|
123
|
+
onArrowDoubleClick: (taskFrom, taskTo, event) => {
|
|
124
|
+
/* handle */
|
|
42
125
|
},
|
|
43
|
-
|
|
126
|
+
onArrowClick: (taskFrom, taskTo) => {
|
|
127
|
+
/* handle */
|
|
128
|
+
},
|
|
129
|
+
}}
|
|
130
|
+
/>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**RelationKind values:** `"startToStart"`, `"startToEnd"`, `"endToStart"`, `"endToEnd"`
|
|
134
|
+
|
|
135
|
+
### 5. Milestones
|
|
136
|
+
|
|
137
|
+
Rendered as diamonds. Set `type: "milestone"` on a task.
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
const milestone: Task = {
|
|
141
|
+
id: "m1",
|
|
142
|
+
type: "milestone",
|
|
143
|
+
name: "Go-Live",
|
|
144
|
+
start: new Date(2026, 3, 1),
|
|
145
|
+
end: new Date(2026, 3, 1),
|
|
146
|
+
progress: 0,
|
|
147
|
+
};
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### 6. Progress Tracking
|
|
151
|
+
|
|
152
|
+
Progress is shown as a filled bar overlay with a percentage label. Tasks have a `progress` field (0–100). The progress drag handle is enabled when `isProgressChangeable` returns true.
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
<Gantt
|
|
156
|
+
tasks={tasks}
|
|
157
|
+
showProgress={true}
|
|
158
|
+
taskBar={{ isProgressChangeable: task => !task.isDisabled }}
|
|
159
|
+
/>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 7. Resource Allocation (Assignees)
|
|
163
|
+
|
|
164
|
+
Tasks support an `assignees` field. Use the built-in `AssigneesColumn` via the columns builder.
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import { Gantt, useTaskListColumnsBuilder } from "gantt-task-react-v";
|
|
168
|
+
|
|
169
|
+
function App() {
|
|
170
|
+
const {
|
|
171
|
+
createNameColumn,
|
|
172
|
+
createStartDateColumn,
|
|
173
|
+
createEndDateColumn,
|
|
174
|
+
createAssigneesColumn,
|
|
175
|
+
} = useTaskListColumnsBuilder();
|
|
176
|
+
|
|
177
|
+
const columns = [
|
|
178
|
+
createNameColumn("Name", 200),
|
|
179
|
+
createStartDateColumn("Start", 100),
|
|
180
|
+
createEndDateColumn("End", 100),
|
|
181
|
+
createAssigneesColumn("Assignees", 150),
|
|
182
|
+
];
|
|
183
|
+
|
|
184
|
+
return <Gantt tasks={tasks} columns={columns} />;
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### 8. Critical Path
|
|
189
|
+
|
|
190
|
+
Highlight the longest chain of dependent tasks that determines project duration.
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
<Gantt tasks={tasks} taskBar={{ isShowCriticalPath: true }} />
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 9. Today Line & Data Date Line
|
|
197
|
+
|
|
198
|
+
Vertical markers for the current date and a custom data date.
|
|
199
|
+
|
|
200
|
+
```tsx
|
|
201
|
+
<Gantt
|
|
202
|
+
tasks={tasks}
|
|
203
|
+
showTodayLine={true}
|
|
204
|
+
todayColor="#ff6b6b"
|
|
205
|
+
todayLabel="Today"
|
|
206
|
+
showDataDateLine={true}
|
|
207
|
+
dataDate={new Date(2026, 2, 15)}
|
|
208
|
+
dataDateColor="#4dabf7"
|
|
209
|
+
dataDateLabel="Data Date"
|
|
210
|
+
/>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Drawer Panel
|
|
216
|
+
|
|
217
|
+
A slide-in panel for viewing task/arrow details with built-in "Go to" navigation.
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
<Gantt
|
|
221
|
+
tasks={tasks}
|
|
222
|
+
drawer={{
|
|
223
|
+
enableDrawer: true,
|
|
224
|
+
drawerWidth: 400,
|
|
225
|
+
renderDrawerContent: (data, goToTask) => {
|
|
226
|
+
if (data.type === "task") {
|
|
227
|
+
return (
|
|
228
|
+
<div>
|
|
229
|
+
<h3>{data.task.name}</h3>
|
|
230
|
+
<p>Progress: {data.task.progress}%</p>
|
|
231
|
+
{data.task.dependencies?.map(dep => (
|
|
232
|
+
<button key={dep.sourceId} onClick={() => goToTask(dep.sourceId)}>
|
|
233
|
+
Go to {dep.sourceId}
|
|
234
|
+
</button>
|
|
235
|
+
))}
|
|
236
|
+
</div>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
if (data.type === "arrow") {
|
|
240
|
+
return (
|
|
241
|
+
<div>
|
|
242
|
+
<button onClick={() => goToTask(data.taskFrom.id)}>
|
|
243
|
+
Go to {data.taskFrom.name}
|
|
244
|
+
</button>
|
|
245
|
+
<button onClick={() => goToTask(data.taskTo.id)}>
|
|
246
|
+
Go to {data.taskTo.name}
|
|
247
|
+
</button>
|
|
248
|
+
</div>
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
return null;
|
|
252
|
+
},
|
|
253
|
+
}}
|
|
254
|
+
/>
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The `goToTask(taskId)` function scrolls both horizontally and vertically to center the target task and selects it. Built-in "Go to" buttons also appear automatically in the drawer header for arrow-type panels and task-type panels.
|
|
258
|
+
|
|
259
|
+
## Scroll To Task
|
|
260
|
+
|
|
261
|
+
Programmatically scroll to and select any task by id.
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
const [targetId, setTargetId] = useState<string | undefined>();
|
|
265
|
+
|
|
266
|
+
<Gantt tasks={tasks} scrollToTaskId={targetId} />
|
|
267
|
+
<button onClick={() => setTargetId("task-2")}>Go to Task 2</button>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Task List Callbacks
|
|
273
|
+
|
|
274
|
+
Row click and double-click callbacks are inside the `taskList` prop.
|
|
275
|
+
|
|
276
|
+
```tsx
|
|
277
|
+
<Gantt
|
|
278
|
+
tasks={tasks}
|
|
279
|
+
taskList={{
|
|
280
|
+
onClickTaskRow: task => console.log("Clicked:", task.id),
|
|
281
|
+
onDoubleClickTaskRow: task => console.log("Double-clicked:", task.id),
|
|
282
|
+
}}
|
|
283
|
+
/>
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Custom Columns
|
|
289
|
+
|
|
290
|
+
Build columns with the hook or provide fully custom ones.
|
|
291
|
+
|
|
292
|
+
```tsx
|
|
293
|
+
import {
|
|
294
|
+
Gantt,
|
|
295
|
+
useTaskListColumnsBuilder,
|
|
296
|
+
Column,
|
|
297
|
+
ColumnProps,
|
|
298
|
+
} from "gantt-task-react-v";
|
|
299
|
+
|
|
300
|
+
// Custom column component
|
|
301
|
+
const ProgressColumn: React.FC<ColumnProps> = ({ data: { task } }) => {
|
|
302
|
+
if (task.type === "empty") return null;
|
|
303
|
+
return <>{task.progress}%</>;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
function App() {
|
|
307
|
+
const { createNameColumn, createDeleteActionColumn, createEditActionColumn } =
|
|
308
|
+
useTaskListColumnsBuilder();
|
|
309
|
+
|
|
310
|
+
const columns: Column[] = [
|
|
311
|
+
createNameColumn("Task", 200),
|
|
312
|
+
{ id: "progress", component: ProgressColumn, width: 80, title: "Progress" },
|
|
313
|
+
createEditActionColumn(40),
|
|
314
|
+
createDeleteActionColumn(40),
|
|
315
|
+
];
|
|
316
|
+
|
|
317
|
+
return <Gantt tasks={tasks} columns={columns} />;
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Column Pinning
|
|
322
|
+
|
|
323
|
+
Pin columns so they stay visible while scrolling.
|
|
324
|
+
|
|
325
|
+
```tsx
|
|
326
|
+
const columns: Column[] = [
|
|
327
|
+
{ ...createNameColumn("Task", 200), pinned: "left" },
|
|
328
|
+
createStartDateColumn("Start", 100),
|
|
329
|
+
createEndDateColumn("End", 100),
|
|
330
|
+
{ ...createDeleteActionColumn(40), pinned: "right" },
|
|
44
331
|
];
|
|
45
|
-
<Gantt tasks={tasks} />
|
|
46
332
|
```
|
|
47
333
|
|
|
48
|
-
|
|
334
|
+
### Column Visibility
|
|
49
335
|
|
|
50
|
-
|
|
336
|
+
Columns can be hidden and toggled by the user.
|
|
337
|
+
|
|
338
|
+
```tsx
|
|
51
339
|
<Gantt
|
|
52
340
|
tasks={tasks}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
341
|
+
columns={[
|
|
342
|
+
createNameColumn("Task", 200),
|
|
343
|
+
{ ...createStartDateColumn("Start"), hidden: true },
|
|
344
|
+
]}
|
|
345
|
+
taskList={{
|
|
346
|
+
canToggleColumns: true,
|
|
347
|
+
onColumnVisibilityChange: columns => console.log(columns),
|
|
348
|
+
}}
|
|
59
349
|
/>
|
|
60
350
|
```
|
|
61
351
|
|
|
62
|
-
|
|
352
|
+
### Built-in Columns Builder Methods
|
|
353
|
+
|
|
354
|
+
| Method | Description |
|
|
355
|
+
| ----------------------------------------- | ------------------------------ |
|
|
356
|
+
| `createNameColumn(title, width?)` | Task name with expand/collapse |
|
|
357
|
+
| `createStartDateColumn(title, width?)` | Start date |
|
|
358
|
+
| `createEndDateColumn(title, width?)` | End date |
|
|
359
|
+
| `createDependenciesColumn(title, width?)` | Dependency names |
|
|
360
|
+
| `createAssigneesColumn(title, width?)` | Assignees list |
|
|
361
|
+
| `createEditActionColumn(width?)` | Edit button |
|
|
362
|
+
| `createDeleteActionColumn(width?)` | Delete button |
|
|
363
|
+
| `createAddActionColumn(width?)` | Add task button |
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Context Menu
|
|
368
|
+
|
|
369
|
+
Right-click context menus for the task list and chart area.
|
|
63
370
|
|
|
64
|
-
```
|
|
65
|
-
|
|
371
|
+
```tsx
|
|
372
|
+
import {
|
|
373
|
+
Gantt,
|
|
374
|
+
createCopyOption,
|
|
375
|
+
createCutOption,
|
|
376
|
+
createPasteOption,
|
|
377
|
+
createDeleteOption,
|
|
378
|
+
createEditOption,
|
|
379
|
+
} from "gantt-task-react-v";
|
|
380
|
+
|
|
381
|
+
<Gantt
|
|
382
|
+
tasks={tasks}
|
|
383
|
+
taskList={{
|
|
384
|
+
enableTableListContextMenu: 1, // right-click trigger
|
|
385
|
+
contextMenuOptions: [
|
|
386
|
+
createEditOption(),
|
|
387
|
+
createCopyOption(),
|
|
388
|
+
createCutOption(),
|
|
389
|
+
createPasteOption(),
|
|
390
|
+
createDeleteOption(),
|
|
391
|
+
],
|
|
392
|
+
}}
|
|
393
|
+
onRowContextMenu={task => console.log("Right-clicked:", task.id)}
|
|
394
|
+
/>;
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## Theming
|
|
400
|
+
|
|
401
|
+
Customize colors, typography, shapes, distances, and date formats.
|
|
402
|
+
|
|
403
|
+
```tsx
|
|
404
|
+
<Gantt
|
|
405
|
+
tasks={tasks}
|
|
406
|
+
theme={{
|
|
407
|
+
rtl: false,
|
|
408
|
+
colors: {
|
|
409
|
+
barProgressColor: "#4dabf7",
|
|
410
|
+
barBackgroundColor: "#e3f2fd",
|
|
411
|
+
barBackgroundSelectedColor: "#bbdefb",
|
|
412
|
+
milestoneBackgroundColor: "#7c4dff",
|
|
413
|
+
arrowColor: "#90a4ae",
|
|
414
|
+
calendarTodayColor: "#ff6b6b",
|
|
415
|
+
tableSelectedTaskBackgroundColor: "#e3f2fd",
|
|
416
|
+
},
|
|
417
|
+
typography: {
|
|
418
|
+
fontFamily: "'Inter', sans-serif",
|
|
419
|
+
fontSize: "13px",
|
|
420
|
+
},
|
|
421
|
+
shape: {
|
|
422
|
+
borderRadius: "4px",
|
|
423
|
+
},
|
|
424
|
+
distances: {
|
|
425
|
+
rowHeight: 40,
|
|
426
|
+
},
|
|
427
|
+
dateFormats: {
|
|
428
|
+
dateColumnFormat: "dd/MM/yyyy",
|
|
429
|
+
},
|
|
430
|
+
}}
|
|
431
|
+
/>
|
|
66
432
|
```
|
|
67
433
|
|
|
68
|
-
|
|
434
|
+
### Color Reference
|
|
435
|
+
|
|
436
|
+
| Group | Keys |
|
|
437
|
+
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
438
|
+
| **Bar** | `barProgressColor`, `barProgressCriticalColor`, `barProgressSelectedColor`, `barProgressSelectedCriticalColor`, `barBackgroundColor`, `barBackgroundCriticalColor`, `barBackgroundSelectedColor`, `barBackgroundSelectedCriticalColor`, `barHandleColor` |
|
|
439
|
+
| **Group** | `groupProgressColor`, `groupProgressCriticalColor`, `groupProgressSelectedColor`, `groupProgressSelectedCriticalColor`, `groupBackgroundColor`, `groupBackgroundCriticalColor`, `groupBackgroundSelectedColor`, `groupBackgroundSelectedCriticalColor` |
|
|
440
|
+
| **Project** | `projectProgressColor`, `projectProgressCriticalColor`, `projectProgressSelectedColor`, `projectProgressSelectedCriticalColor`, `projectBackgroundColor`, `projectBackgroundCriticalColor`, `projectBackgroundSelectedColor`, `projectBackgroundSelectedCriticalColor` |
|
|
441
|
+
| **Milestone** | `milestoneBackgroundColor`, `milestoneBackgroundCriticalColor`, `milestoneBackgroundSelectedColor`, `milestoneBackgroundSelectedCriticalColor` |
|
|
442
|
+
| **Comparison** | `barComparisonDefaultColor`, `barComparisonPlanColor`, `barComparisonWarningColor`, `barComparisonCriticalColor` |
|
|
443
|
+
| **Arrow** | `arrowColor`, `arrowCriticalColor`, `arrowRelationColor`, `arrowHoverColor` |
|
|
444
|
+
| **Calendar** | `calendarHolidayColor`, `calendarTodayColor`, `calendarStrokeColor` |
|
|
445
|
+
| **Table** | `tableDragTaskBackgroundColor`, `tableSelectedTaskBackgroundColor`, `tableActionColor`, `tableDragIndicatorColor`, `tableHoverActionColor`, `tableEvenBackgroundColor` |
|
|
446
|
+
| **UI** | `backgroundColor`, `dividerColor`, `hoverFilter`, `loadingPrimaryColor`, `loadingSecondaryColor`, `contextMenuBoxShadow`, `contextMenuBgColor`, `contextMenuTextColor`, `tooltipBoxShadow`, `scrollbarThumbColor`, `primaryTextColor`, `secondaryTextColor` |
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
## Locale
|
|
451
|
+
|
|
452
|
+
```tsx
|
|
453
|
+
import { Gantt, GanttLocale } from "gantt-task-react-v";
|
|
454
|
+
import { enUS } from "date-fns/locale";
|
|
455
|
+
|
|
456
|
+
const locale: GanttLocale = {
|
|
457
|
+
dateLocale: enUS,
|
|
458
|
+
suffix: { days: "days" },
|
|
459
|
+
tooltip: { duration: "Duration", progress: "Progress" },
|
|
460
|
+
table: {
|
|
461
|
+
columns: {
|
|
462
|
+
name: "Task",
|
|
463
|
+
startDate: "Start",
|
|
464
|
+
endDate: "End",
|
|
465
|
+
dependencies: "Dependencies",
|
|
466
|
+
progress: "Progress",
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
context: {
|
|
470
|
+
edit: "Edit",
|
|
471
|
+
copy: "Copy",
|
|
472
|
+
cut: "Cut",
|
|
473
|
+
paste: "Paste",
|
|
474
|
+
delete: "Delete",
|
|
475
|
+
},
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
<Gantt tasks={tasks} locale={locale} />;
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
## Task Lifecycle Callbacks
|
|
484
|
+
|
|
485
|
+
```tsx
|
|
486
|
+
<Gantt
|
|
487
|
+
tasks={tasks}
|
|
488
|
+
onCommitTasks={async (nextTasks, action) => {
|
|
489
|
+
// Persist changes — return { tasks } to confirm or throw to revert
|
|
490
|
+
await saveTasks(nextTasks);
|
|
491
|
+
return {};
|
|
492
|
+
}}
|
|
493
|
+
onAddTaskAction={async parentTask => {
|
|
494
|
+
// Return new task data or null to cancel
|
|
495
|
+
return {
|
|
496
|
+
id: "new-1",
|
|
497
|
+
type: "task",
|
|
498
|
+
name: "New",
|
|
499
|
+
start: new Date(),
|
|
500
|
+
end: new Date(),
|
|
501
|
+
progress: 0,
|
|
502
|
+
};
|
|
503
|
+
}}
|
|
504
|
+
onEditTaskAction={async task => {
|
|
505
|
+
// Return edited task or null to cancel
|
|
506
|
+
return { ...task, name: "Edited" };
|
|
507
|
+
}}
|
|
508
|
+
onSelectTaskIds={ids => console.log("Selected:", ids)}
|
|
509
|
+
/>
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
## Comparison Mode
|
|
515
|
+
|
|
516
|
+
Overlay plan vs actual dates by providing `comparisonDates` on tasks.
|
|
517
|
+
|
|
518
|
+
```tsx
|
|
519
|
+
const tasks: Task[] = [
|
|
520
|
+
{
|
|
521
|
+
id: "1",
|
|
522
|
+
type: "task",
|
|
523
|
+
name: "Feature A",
|
|
524
|
+
start: new Date(2026, 0, 5), // actual
|
|
525
|
+
end: new Date(2026, 0, 20),
|
|
526
|
+
progress: 50,
|
|
527
|
+
comparisonDates: {
|
|
528
|
+
start: new Date(2026, 0, 1), // planned
|
|
529
|
+
end: new Date(2026, 0, 15),
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
];
|
|
533
|
+
|
|
534
|
+
<Gantt tasks={tasks} comparisonLevels={2} />;
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
## Full API Reference
|
|
69
540
|
|
|
70
541
|
### GanttProps
|
|
71
542
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
| tasks
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
| [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
|
|
|
103
|
-
|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
|
118
|
-
|
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
|
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
543
|
+
| Prop | Type | Default | Description |
|
|
544
|
+
| --------------------------------- | --------------------------------------- | ------------- | ------------------------------- |
|
|
545
|
+
| `tasks` | `RenderTask[]` | **required** | Array of tasks to display |
|
|
546
|
+
| `viewMode` | `ViewMode` | `Day` | Time scale |
|
|
547
|
+
| `viewDate` | `Date` | — | Scroll to this date on mount |
|
|
548
|
+
| `columns` | `Column[]` | — | Custom table columns |
|
|
549
|
+
| `language` | `string` | — | Language code |
|
|
550
|
+
| `locale` | `GanttLocale` | English | Localization strings |
|
|
551
|
+
| `theme` | `GanttPartialTheme` | — | Theme overrides |
|
|
552
|
+
| `taskBar` | `GanttTaskBarProps` | — | Chart bar options |
|
|
553
|
+
| `taskList` | `GanttTaskListProps` | — | Task list options |
|
|
554
|
+
| `drawer` | `GanttDrawerProps` | — | Drawer panel options |
|
|
555
|
+
| `authorizedRelations` | `RelationKind[]` | all four | Allowed dependency types |
|
|
556
|
+
| `timeStep` | `number` | `300000` | Snap interval in ms |
|
|
557
|
+
| `comparisonLevels` | `number` | `1` | Number of comparison levels |
|
|
558
|
+
| `rowHeight` | `number` | theme default | Row height in pixels |
|
|
559
|
+
| `showTodayLine` | `boolean` | `true` | Show today marker |
|
|
560
|
+
| `showDataDateLine` | `boolean` | `false` | Show data-date marker |
|
|
561
|
+
| `dataDate` | `Date \| null` | `null` | Data date value |
|
|
562
|
+
| `todayColor` | `string` | theme default | Today line color |
|
|
563
|
+
| `dataDateColor` | `string` | theme default | Data date line color |
|
|
564
|
+
| `todayLabel` | `string` | `"Today"` | Today marker label |
|
|
565
|
+
| `dataDateLabel` | `string` | `"Data Date"` | Data date marker label |
|
|
566
|
+
| `showProgress` | `boolean` | `true` | Show progress fill on bars |
|
|
567
|
+
| `progressColor` | `string` | theme default | Custom progress color |
|
|
568
|
+
| `scrollToTaskId` | `TaskId` | — | Scroll to and select this task |
|
|
569
|
+
| `isMoveChildsWithParent` | `boolean` | `true` | Move children when parent moves |
|
|
570
|
+
| `isUpdateDisabledParentsOnChange` | `boolean` | `true` | Recompute parents on commit |
|
|
571
|
+
| `isUnknownDates` | `boolean` | `false` | Show offsets instead of dates |
|
|
572
|
+
| `isAdjustToWorkingDates` | `boolean` | `true` | Snap to working days |
|
|
573
|
+
| `checkIsHoliday` | `CheckIsHoliday` | — | Holiday check function |
|
|
574
|
+
| `getCopiedTaskId` | `GetCopiedTaskId` | — | ID generator for paste |
|
|
575
|
+
| `roundStartDate` | `(date, viewMode) => Date` | — | Round start after drag |
|
|
576
|
+
| `roundEndDate` | `(date, viewMode) => Date` | — | Round end after drag |
|
|
577
|
+
| `onCommitTasks` | `OnCommitTasks` | — | Task change callback |
|
|
578
|
+
| `onAddTaskAction` | `(task) => Promise<RenderTask \| null>` | — | Add task handler |
|
|
579
|
+
| `onEditTaskAction` | `(task) => Promise<RenderTask \| null>` | — | Edit task handler |
|
|
580
|
+
| `onSelectTaskIds` | `(ids: TaskId[]) => void` | — | Selection change |
|
|
581
|
+
| `onWheel` | `(event: WheelEvent) => void` | — | Wheel event |
|
|
582
|
+
| `onRowContextMenu` | `(task: RenderTask) => void` | — | Row right-click |
|
|
583
|
+
|
|
584
|
+
### Task
|
|
585
|
+
|
|
586
|
+
| Field | Type | Description |
|
|
587
|
+
| ----------------- | ------------------------------------ | ----------------------------- |
|
|
588
|
+
| `id` | `string` | Unique identifier |
|
|
589
|
+
| `type` | `"task" \| "milestone" \| "project"` | Task type |
|
|
590
|
+
| `name` | `string` | Display name |
|
|
591
|
+
| `start` | `Date` | Start date |
|
|
592
|
+
| `end` | `Date` | End date |
|
|
593
|
+
| `progress` | `number` | Completion percentage (0–100) |
|
|
594
|
+
| `assignees` | `string[]` | Assigned resources |
|
|
595
|
+
| `parent` | `string` | Parent task id for hierarchy |
|
|
596
|
+
| `dependencies` | `Dependency[]` | Task dependencies |
|
|
597
|
+
| `comparisonDates` | `{ start, end }` | Plan dates for comparison |
|
|
598
|
+
| `hideChildren` | `boolean` | Collapse children |
|
|
599
|
+
| `isDisabled` | `boolean` | Disable interactions |
|
|
600
|
+
| `displayOrder` | `number` | Sort order |
|
|
601
|
+
| `comparisonLevel` | `number` | Comparison level index |
|
|
602
|
+
| `style` | `CSSProperties` | Custom bar styles |
|
|
603
|
+
| `payload` | `Record<string, string>` | Custom data |
|
|
604
|
+
|
|
605
|
+
### GanttTaskListProps
|
|
606
|
+
|
|
607
|
+
| Prop | Type | Default | Description |
|
|
608
|
+
| ---------------------------- | -------------------------------- | ------------ | ----------------------------- |
|
|
609
|
+
| `isShowTaskNumbers` | `boolean` | `true` | Show row numbers |
|
|
610
|
+
| `canReorderTasks` | `boolean` | `true` | Enable drag reorder |
|
|
611
|
+
| `canResizeColumns` | `boolean` | `true` | Enable column resize |
|
|
612
|
+
| `canToggleColumns` | `boolean` | `false` | Show column visibility toggle |
|
|
613
|
+
| `allowReorderTask` | `AllowReorderTask` | `() => true` | Per-task reorder guard |
|
|
614
|
+
| `enableTableListContextMenu` | `number` | `1` | Context menu trigger |
|
|
615
|
+
| `contextMenuOptions` | `ContextMenuOptionType[]` | — | Menu options |
|
|
616
|
+
| `icons` | `Partial<GanttRenderIconsProps>` | — | Custom icons |
|
|
617
|
+
| `onResizeColumn` | `OnResizeColumn` | — | Column resize callback |
|
|
618
|
+
| `onColumnVisibilityChange` | `OnColumnVisibilityChange` | — | Visibility change callback |
|
|
619
|
+
| `tableBottom` | `TableRenderBottomProps` | — | Footer render |
|
|
620
|
+
| `onClickTaskRow` | `(task: RenderTask) => void` | — | Row click |
|
|
621
|
+
| `onDoubleClickTaskRow` | `(task: RenderTask) => void` | — | Row double-click |
|
|
622
|
+
|
|
623
|
+
### GanttTaskBarProps
|
|
624
|
+
|
|
625
|
+
| Prop | Type | Default | Description |
|
|
626
|
+
| --------------------------------- | ---------------------------- | ------------------ | ------------------------------- |
|
|
627
|
+
| `isShowCriticalPath` | `boolean` | `false` | Show critical path |
|
|
628
|
+
| `isProgressChangeable` | `(task) => boolean` | `!task.isDisabled` | Allow progress drag |
|
|
629
|
+
| `isDateChangeable` | `(task) => boolean` | `!task.isDisabled` | Allow date drag |
|
|
630
|
+
| `isRelationChangeable` | `(task) => boolean` | — | Allow relation draw |
|
|
631
|
+
| `isDeleteDependencyOnDoubleClick` | `boolean` | `true` | Delete deps on dblclick |
|
|
632
|
+
| `preStepsCount` | `number` | `1` | Empty columns before first task |
|
|
633
|
+
| `allowMoveTaskBar` | `(action, task) => boolean` | — | Per-action move guard |
|
|
634
|
+
| `renderBottomHeader` | `RenderBottomHeader` | — | Custom bottom header |
|
|
635
|
+
| `renderTopHeader` | `RenderTopHeader` | — | Custom top header |
|
|
636
|
+
| `renderCustomLabel` | `RenderCustomLabel` | — | Custom bar label |
|
|
637
|
+
| `TooltipContent` | `ComponentType<{ task }>` | built-in | Custom tooltip |
|
|
638
|
+
| `taskGanttContextMenuOption` | `ContextMenuOptionType[]` | — | Chart context menu |
|
|
639
|
+
| `onClick` | `(task: RenderTask) => void` | — | Bar click |
|
|
640
|
+
| `onDoubleClick` | `(task: Task) => void` | — | Bar double-click |
|
|
641
|
+
| `onArrowClick` | `(from, to) => void` | — | Arrow click |
|
|
642
|
+
| `onArrowDoubleClick` | `OnArrowDoubleClick` | — | Arrow double-click |
|
|
643
|
+
|
|
644
|
+
### GanttDrawerProps
|
|
645
|
+
|
|
646
|
+
| Prop | Type | Default | Description |
|
|
647
|
+
| --------------------- | --------------------- | ------- | ----------------------- |
|
|
648
|
+
| `enableDrawer` | `boolean` | `false` | Enable drawer panel |
|
|
649
|
+
| `drawerWidth` | `number` | `360` | Panel width in px |
|
|
650
|
+
| `renderDrawerContent` | `RenderDrawerContent` | — | Custom content renderer |
|
|
651
|
+
|
|
652
|
+
`RenderDrawerContent = (data: GanttDrawerData, goToTask: (taskId: string) => void) => ReactNode`
|
|
653
|
+
|
|
654
|
+
### Column
|
|
655
|
+
|
|
656
|
+
| Field | Type | Description |
|
|
657
|
+
| ----------- | ---------------------------- | ------------------ |
|
|
658
|
+
| `id` | `string` | Unique column id |
|
|
659
|
+
| `component` | `ComponentType<ColumnProps>` | Render component |
|
|
660
|
+
| `width` | `number` | Column width in px |
|
|
661
|
+
| `title` | `ReactNode` | Header text |
|
|
662
|
+
| `canResize` | `boolean` | Allow resize |
|
|
663
|
+
| `pinned` | `"left" \| "right"` | Sticky pinning |
|
|
664
|
+
| `hidden` | `boolean` | Hide column |
|
|
665
|
+
|
|
666
|
+
---
|
|
667
|
+
|
|
668
|
+
## Running Storybook
|
|
669
|
+
|
|
670
|
+
```bash
|
|
671
|
+
npm run storybook
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
## License
|
|
675
|
+
|
|
676
|
+
MIT
|
|
677
|
+
| barProgressColor | string | Specifies the taskbar progress fill color globally. |
|
|
678
|
+
| barProgressSelectedColor | string | Specifies the taskbar progress fill color globally on select. |
|
|
679
|
+
| barBackgroundColor | string | Specifies the taskbar background fill color globally. |
|
|
680
|
+
| barBackgroundSelectedColor | string | Specifies the taskbar background fill color globally on select. |
|
|
681
|
+
| arrowColor | string | Specifies the relationship arrow fill color. |
|
|
682
|
+
| arrowIndent | number | Specifies the relationship arrow right indent. Sets in px |
|
|
683
|
+
| todayColor | string | Specifies the current period column fill color. |
|
|
684
|
+
| TooltipContent | | Specifies the Tooltip view for selected taskbar. |
|
|
685
|
+
| TaskListHeader | | Specifies the task list Header view |
|
|
686
|
+
| TaskListTable | | Specifies the task list Table view |
|
|
131
687
|
|
|
132
688
|
- TooltipContent: [`React.FC<{ task: Task; fontSize: string; fontFamily: string; }>;`](https://github.com/MaTeMaTuK/gantt-task-react/blob/main/src/components/other/tooltip.tsx#L56)
|
|
133
689
|
- TaskListHeader: `React.FC<{ headerHeight: number; rowWidth: string; fontFamily: string; fontSize: string;}>;`
|