You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gantt expects that *an array with tasks* will be named either **data** or **tasks** whereas *an array with links* will be named **links**.
44
-
45
-
This is the list of expected properties:
46
-
47
-
-**data** - (*[] | NewTask[]*) - the array with the task data
48
-
-**links?** - (*Link[]*) - the array with the link data
49
-
-**resources?** - (*NewResourceItem[]*) - the array with the resource data
50
-
-**assignments?** - (*NewAssignmentItem[]*) - the array with the assignment data
51
-
-**collections?** - (*Сollections*) - the object that has the arrays with the custom data
52
-
53
-
~~~js
54
-
gantt.parse({
55
-
data: [
56
-
{ id:1, start_date:"2025-09-23", duration:42,
57
-
text:"House Construction" },
58
-
{ id:2, start_date:"2025-12-02", duration:60,
59
-
text:"House Construction" },
60
-
],
61
-
"links": [
62
-
{ id:"1", source:"1", target:"2", type:"0" },
63
-
],
64
-
"resources": [
65
-
{ id:1, text:"Anna, Architect", unit:"hours/day",
66
-
default_value:8, type:"work" },
67
-
],
68
-
"assignments": [
69
-
{ task_id:"1", resource_id:"1", value:"8" },
70
-
{ task_id:"2", resource_id:"1", value:"8",
71
-
mode:"fixedDates", start_date:"2025-09-23",
72
-
end_date:"2025-09-25", duration:4, delay:2, },
73
-
{ task_id:"2", resource_id:"1", value:"8",
74
-
start_date:newDate("2025-09-23 00:00:00"),
75
-
end_date:newDate("2025-09-26 00:00:00"), },
76
-
]
77
-
})
78
-
~~~
79
-
80
-
81
-
The **data** or **tasks** array expects the **NewTask** object that is different from the **Task** object. It can be a string, an empty object.
82
-
It can have the same properties as the [**Task** object](guides/task-properties.md), and you can add any custom properties there.
83
-
The difference is that some properties of the **Task** object that start from the *$* sign are ignored and the dates can have the *string* type.
84
-
Here is the type description:
85
-
86
-
-**NewTask** - (*string | {} | object*) - the task object that will be added to Gantt. It can have the following properties:
87
-
-**_id?_** - (*string | number*) - optional, the task ID, auto-generated if not set.
88
-
-**_start_date?_** - (*string | Date*) - optional, the date when a task is scheduled to begin.
89
-
-**_duration?_** - (*number*) - optional, the task duration.
90
-
-**_end_date?_** - (*string | Date*) - optional, the date when a task is scheduled to be completed.
91
-
-**_text?_** - (*string*) - optional, the task name.
92
-
-**_open?_** - (*boolean*) - optional, specifies if the task will be opened on load (to show child tasks).
93
-
-**_parent?_** - (*string | number*) - optional, the ID of the parent task.
94
-
-**_constraint_date?_** - (*string | Date*) - optional, the date of the task constraint.
95
-
-**_[customProperty: string]_** - (*any*) - any other property you want to add, including the ones from the [**Task** object](guides/task-properties.md)
96
-
97
-
This is not the full list of possible task properties. For that, please refer to [this article](guides/task-properties.md).
98
-
99
-
~~~js
100
-
gantt.parse({
101
-
data: [
102
-
{ id:1, start_date:"2025-09-23", duration:42,
103
-
text:"House Construction" },
104
-
]
105
-
})
106
-
~~~
107
-
42
+
The `parse()` method accepts the top-level [GanttData](guides/data-model.md#ganttdata) object.
108
43
109
-
---
44
+
Gantt expects that the array with tasks will be named either `data` or `tasks`, while the array with links will be named `links`.
110
45
46
+
This is the list of supported properties:
111
47
112
-
The **links** array expects the [**Link** objects](guides/link-properties.md).
48
+
-`tasks` or `data` - (`(SerializedTask | Task)[]`) the array with task data
49
+
-`links?` - (`(SerializedLink | Link)[]`) the array with link data
50
+
-`resources?` - (`Partial<ResourceItem>[]`) the array with resource data
51
+
-`assignments?` - (`(SerializedResourceAssignment | ResourceAssignment)[]`) the array with assignment data
52
+
-`baselines?` - (`(SerializedBaseline | Baseline)[]`) the array with baseline data
53
+
-`collections?` - (`Record<string, Array<Record<string, unknown>>>`) the object with custom collections
`data` and `tasks` are alternative keys for the same task array. `tasks` is preferred in new code.
147
100
148
-
---
149
-
150
-
151
-
The **assignments** array expects the **NewAssignmentItem** object that may have the properties below:
152
-
153
-
-**NewAssignmentItem** - (*object*) - the assignment item object that will be added to Gantt. It can have the following properties:
154
-
-**_id?_** - (*string | number*) - optional, the assignment ID, auto-generated if not set
155
-
-**_task_id_** - (*string | number*) - the ID of the task the resource is assigned to
156
-
-**_resource_id_** - (*string | number*) - the ID of the resource that is assigned to the task
157
-
-**_value_** - (*number | string*) - optional, the assignment value
158
-
-**_mode?_** - (*string*) - optional, the calculation mode of the time of the resource assignment: "default"|"fixedDates"|"fixedDuration"
159
-
-**_delay?_** - (*number*) - optional, the difference between the assignment start date and the task start date
160
-
-**_start_date?_** - (*string | Date*) - optional, the date the assignment should start
161
-
-**_duration?_** - (*number*) - optional, the assignment duration
162
-
-**_end_date?_** - (*string | Date*) - optional, the date the assignment should end
163
-
-**_[customProperty: string]_** - (*any*) - any other property you want to add
164
-
101
+
If you load data from a JavaScript object created in code, `Task`, `ResourceAssignment`, and other runtime objects may contain `Date`. When data is exchanged as JSON with the server, date fields should be strings.
165
102
166
-
~~~js
167
-
gantt.parse({
168
-
data: [],
169
-
assignments: [
170
-
{ task_id:"1", resource_id:"1", value:"8" },
171
-
]
172
-
})
173
-
~~~
103
+
### Legacy Compatibility Names
174
104
175
-
---
176
-
177
-
The **collections** object allows loading any custom data. The properties can have any name, and the value should be an array that contains the collection items:
105
+
Older API docs and typings still use several compatibility aliases:
178
106
179
-
-**[collectionName: string]** - (*[] | СollectionItem[]*) - an array that contains the collection items.
107
+
-`DataToLoad1`, `DataToLoad2`
108
+
-`NewTask`
109
+
-`NewResourceItem`
110
+
-`NewAssignmentItem`
180
111
181
-
The **СollectionItem** is an object that can have any properties. It has the following types for its properties:
112
+
These names are kept for backward compatibility. The canonical overview of the accepted shapes is the [Data Model](guides/data-model.md) article.
182
113
183
-
-**[itemProperty: string]** - (*any*) - any custom property of the collection item.
114
+
### Collections
184
115
116
+
The `collections` object allows loading custom lists used by editors and controls. The property names can be arbitrary, and each value should be an array of collection items.
0 commit comments