mzgantt 1.0.6 → 1.0.7
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.en.md +962 -25
- package/cdn/export.js +1 -1
- package/package.json +1 -1
- package/readme.md +7 -5
- package/sample/sample.html +465 -0
package/README.en.md
CHANGED
|
@@ -1,36 +1,973 @@
|
|
|
1
|
-
# MZGantt甘特图插件npm版
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
MZGantt
|
|
2
|
+
# MZGantt Gantt Chart Plugin
|
|
3
|
+
MZGantt is a native JavaScript Gantt chart plugin. It supports Vue, TypeScript, JavaScript and other popular frontend frameworks, and can be quickly integrated into web applications or mobile apps.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
Software architecture description
|
|
5
|
+
## I. Plugin Features
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
* <b>Drag & Drop Editing:</b> Supports drag and drop editing
|
|
8
|
+
* <b>Inline Editing:</b> Supports inline editing functionality
|
|
9
|
+
* <b>Modal Support:</b> Provides task model to work with external modals for task editing
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
* <b>Customizable Columns:</b> Supports custom task attribute columns
|
|
12
|
+
* <b>Multi-segment Display:</b> Supports multi-segment display within task rows
|
|
13
|
+
* <b>Calendar Support:</b> Supports custom calendars
|
|
14
|
+
* <b>Image Export:</b> Supports full Gantt chart image export
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
* <b>Big Data Processing:</b> Supports lazy loading for tasks
|
|
17
|
+
* <b>Filter Support:</b> Supports setting conditions for quick filtering
|
|
18
|
+
* <b>Milestone Markers:</b> Supports configuring milestone marker lines
|
|
19
|
+
* <b>Four Task Relationships:</b> Supports drag-and-drop creation and editing of four task relationships (FS, FF, SF, SS)
|
|
20
|
+
* <b>Customizable Tooltips:</b> Supports custom tooltip content and styles
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
* <b>Customizable Styles:</b> Supports custom display styles
|
|
23
|
+
* <b>Easy to Use:</b> Direct JS reference or npm installation (supports Vue, TypeScript)
|
|
24
|
+
* <b>Rich Configuration:</b> Provides extensive configuration parameters and interfaces to meet project requirements
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
## II. Demo
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
2. Create Feat_xxx branch
|
|
25
|
-
3. Commit your code
|
|
26
|
-
4. Create Pull Request
|
|
28
|
+
Demo URL: <https://mzgantt.com/en/demo>
|
|
27
29
|
|
|
30
|
+
## III. How to Use?
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
MZGantt supports two usage methods: JS reference and npm installation.
|
|
30
33
|
|
|
31
|
-
1.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
1. Download
|
|
35
|
+
Before use, download the standard JS version or install via npm.
|
|
36
|
+
|
|
37
|
+
2. Reference MZGantt Plugin
|
|
38
|
+
Include the following JS packages in the HTML page header:
|
|
39
|
+
* Standard JS reference:
|
|
40
|
+
```javascript
|
|
41
|
+
<!-- Include jQuery library -->
|
|
42
|
+
<script language="javascript" src="jquery.min.js"></script>
|
|
43
|
+
|
|
44
|
+
<!-- Include Gantt chart plugin -->
|
|
45
|
+
<link rel="stylesheet" type="text/css" href="./gantt/mzgantt.css" />
|
|
46
|
+
<script language="javascript" src="./gantt/mzgantt.js"></script>
|
|
47
|
+
<script language="javascript" src="./gantt/edit.js"></script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
* npm reference:
|
|
51
|
+
```javascript
|
|
52
|
+
// Import MZGantt packages, include the following packages as needed:
|
|
53
|
+
// 1. Core package: MZGantt (required, includes basic Gantt chart display)
|
|
54
|
+
// 2. Editor package: MZGanttEditor (optional, includes editing functionality)
|
|
55
|
+
// 3. Export package: MZGanttExport (optional, includes image export functionality)
|
|
56
|
+
// 4. Mobile package: MZGanttMobile (optional, includes mobile support)
|
|
57
|
+
import {MZGantt, MZGanttEditor} from '/node_modules/mzgantt';
|
|
58
|
+
|
|
59
|
+
// Get and set license key
|
|
60
|
+
MZGantt.LicenseKey = "Your license key";
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
3. Define Gantt Chart Container (div)
|
|
64
|
+
Define a div in the HTML page as the container for displaying the Gantt chart:
|
|
65
|
+
```html
|
|
66
|
+
<div id="GanttChartDIV" style="width:100%;"></div>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
4. Define Gantt Chart Parameters (can define empty object {}, plugin will use default values)
|
|
70
|
+
This step is optional. When personalized display is needed, set Gantt chart parameters. Some configurable parameters are as follows:
|
|
71
|
+
```javascript
|
|
72
|
+
var ganttConfig = {
|
|
73
|
+
useFor: "Task", // Set Gantt chart purpose: 'Resource' for resource utilization (e.g., meeting room management), 'Task' for task management (e.g., planning and progress). Default: Task
|
|
74
|
+
ganttStatus: "e", // Set Gantt chart status (e: edit plan, r: read-only)
|
|
75
|
+
|
|
76
|
+
// Column configuration (left table column display configuration, not Gantt data format)
|
|
77
|
+
columnDefs: [
|
|
78
|
+
{name: 'seq', field: "seq", type:"level"},
|
|
79
|
+
{name: 'checkbox', field: "checkbox"},
|
|
80
|
+
{name: 'iconColsVal', field: "iconColsVal", width: 30},
|
|
81
|
+
|
|
82
|
+
// For the following fields, name can be customized and must match corresponding item names in data. field values are built-in fixed values, cannot be reset, and do not support type setting.
|
|
83
|
+
{name: 'name', field: "name", title: "Task Name", width: 150},
|
|
84
|
+
{name: 'resId', field: "resId", title: "Responsible Person", width: 50, options: resourceList},
|
|
85
|
+
{name: 'dur', field: "dur", title: "Duration", width: 60},
|
|
86
|
+
{name: 'planStart', field: "planStart", title: "Plan Start", width: 120, editable: false},
|
|
87
|
+
{name: 'planEnd', field: "planEnd", title: "Plan End", width: 120, colCallBack:custCallbackFunc1},
|
|
88
|
+
{name: 'planDur', field: "planDur", title: "Plan Days", width: 60},
|
|
89
|
+
{name: 'rsltStart', field: "rsltStart", title: "Actual Start", width: 120},
|
|
90
|
+
{name: 'rsltEnd', field: "rsltEnd", title: "Actual End", width: 120},
|
|
91
|
+
{name: 'rsltDur', field: "rsltDur", title: "Actual Days", width: 60},
|
|
92
|
+
{name: 'pctComp', field: "pctComp", title: "Completion", width: 60},
|
|
93
|
+
// {name: 'caption', field: "caption", title: "Label Text"},
|
|
94
|
+
|
|
95
|
+
// Custom columns (field: "custCol"): supports type setting: DropDownList/TextBox
|
|
96
|
+
// Attribute altText: custom column replacement display text
|
|
97
|
+
{name:"yourColName1", field: "custCol", title:"Column 1", type: "TextBox", default: 10, width:50,align:"left"},
|
|
98
|
+
{name:"yourColName2", field: "custCol", title:"Column 2", type: "DropDownList", options:dropDownListData, width:100, align:"left"},
|
|
99
|
+
{name:"yourColName3", field: "custCol", title:"Column 3","width":150,"align":"left", colCallBack:custCallbackFunc2, altText: "View Image"}
|
|
100
|
+
],
|
|
101
|
+
|
|
102
|
+
// Gantt chart area display control
|
|
103
|
+
showTrack: 1, // 0: Plan Gantt; 1: Actual Gantt. Default: Plan Gantt
|
|
104
|
+
showDuplicate: 0, // Whether to show resource overlap indicator
|
|
105
|
+
showMileStone: 1, // Whether to show milestone: 0: not show
|
|
106
|
+
showDependencies: 1, // Whether to show connection lines (0/1), default: 0 (not show)
|
|
107
|
+
showDayDate: "date", // When day format is set, display weekday or date (day: weekday; date: date). Default: day shows weekday
|
|
108
|
+
showWeekIndex: "", // When day format is set, right header shows week number or first date of week. Y: show week number; others: show date. Default: show date
|
|
109
|
+
|
|
110
|
+
// Data definition class===============================================================================
|
|
111
|
+
weekWorkSetting: // Weekly workday settings (D1: Monday...D0: Sunday. 1: workday, 0: rest day)
|
|
112
|
+
{D1:1, D2:1, D3:1, D4:1, D5:1, D6:0, D0:0},
|
|
113
|
+
holidayList: [ // Set holiday list. When weekends are normally displayed, add dates in the list as holidays, displayed in gray
|
|
114
|
+
'2023-02-09',
|
|
115
|
+
'2023-02-21',
|
|
116
|
+
'2023-03-20'],
|
|
117
|
+
workdayList: ['2023-03-18'], // Set workday list
|
|
118
|
+
mileStoneLines: [ // Milestone configuration
|
|
119
|
+
{date:'2023-11-05',name:'startMS', title:'Project Design Discussion', color:'#FF00BF', thickness: "2px"},
|
|
120
|
+
{date:'2023-11-25',name:'pjMeeting', title:'Code Review', color:'#088A29', thickness: "2px"},
|
|
121
|
+
{date:'today',name:'today', title:'Today', color:'#FF0000', thickness: "2px"}
|
|
122
|
+
],
|
|
123
|
+
|
|
124
|
+
// Plugin configuration class===============================================================================
|
|
125
|
+
captionType: 'Caption', // Set Gantt chart title (None, Name, Caption, Resource, Duration, Complete, Reserver, Title, Theme). None: do not show title
|
|
126
|
+
captionPosition: 'Right', // Set Gantt chart title position (Over: above Gantt bar; Right: right side of Gantt bar, default: Over)
|
|
127
|
+
|
|
128
|
+
// Display date format and input date format should be unified
|
|
129
|
+
dateFormat: 'yyyy-mm-dd', // Set parameter date format ('mm/dd/yyyy', 'dd/mm/yyyy', 'yyyy-mm-dd','yyyy/mm/dd')
|
|
130
|
+
weekStartDay: 0, // Set first day of week (1: Monday; 0: Sunday), default: 0
|
|
131
|
+
|
|
132
|
+
workingHourRange: ['1','23'], // Set daily working hours in hour format (in hours). Default: 1,23
|
|
133
|
+
hourFormat: 0, // Set hour format (0: hour without :00; 1: hour with :00). Default: 0 shows weekday
|
|
134
|
+
|
|
135
|
+
dragChgDur: "1", // Set drag to change workdays. If showChgDur is set to not show, this option is invalid
|
|
136
|
+
autoCalDur: 1, // Set automatic calculation of workdays (default: not auto-calculate)
|
|
137
|
+
|
|
138
|
+
includeHoliday: "N", // Whether workday calculation includes holidays and weekends: Y: include; N: exclude
|
|
139
|
+
includeToTime: "Y", // Whether Gantt completion time includes the last time point (set to include when start and end times are date type, set to exclude for hours), default: Y
|
|
140
|
+
|
|
141
|
+
durPrecision: 2, // Set duration and workday precision (default: one decimal place)
|
|
142
|
+
fixColsCnt: 3, // Set number of locked columns, default: 0 (no locked columns)
|
|
143
|
+
fixParent: 1, // Fix parent task range (1: does not change with child task drag; 0: changes with child task drag)
|
|
144
|
+
idType: "Snow", // Task ID calculation method (default: 12-digit arbitrary characters; UUID: uuid; Snow: snowflake ID)
|
|
145
|
+
|
|
146
|
+
// Style control class===============================================================================
|
|
147
|
+
// Background color settings
|
|
148
|
+
// planBackground: vPlanBackground, // Set Gantt plan bar background
|
|
149
|
+
// resultBackground: vResultBackground, // Set Gantt actual bar background
|
|
150
|
+
compBackground: '#0000FF', // Set completion background
|
|
151
|
+
// groupBackground: '#00FF00', // Set parent task row background
|
|
152
|
+
holidayBGColor: '#E6E6E6', // Set rest day/holiday background
|
|
153
|
+
currentTimeBackColor: ['h','#FF9797'], // Set current time background (param1: h: show current time via header style; c: show current time via cell style. param2: color value)
|
|
154
|
+
intervalColor: ['#FFFFFF','#F4F4F4'], // Set alternating row background color, default: #FFFFFF,#F4F4F4
|
|
155
|
+
selectedRowColor: '#CAE1FF', // Set selected row background color, default: #CAE1FF
|
|
156
|
+
selectedCellColor: '#2E9AFE', // Set selected cell border color, default: 2E9AFE
|
|
157
|
+
borderColor: '#9E9E9E', // Set Gantt border color, default: #9E9E9E
|
|
158
|
+
|
|
159
|
+
// Gantt bars
|
|
160
|
+
barBorderRadius: 6, // Set Gantt bar border radius, default: 3px
|
|
161
|
+
barBorderWeight: 1, // Set Gantt bar border weight, default: 1px
|
|
162
|
+
barBorderColor: '#9E0000', // Set Gantt bar border color, default: #9E9E9E
|
|
163
|
+
barOpacity: 1, // Set Gantt bar opacity, default: 0.7
|
|
164
|
+
barGridBorderWeight: 1, // Set Gantt bar background border weight, default: 1px
|
|
165
|
+
resultBarStyle: 'mark', // Actual bar style (normal: do not mark dates outside plan, mark: mark dates outside plan; cust: custom segments)
|
|
166
|
+
markResultBarColor: // Actual bar background color when resultBarStyle is mark type
|
|
167
|
+
{beforePlanBGColor: '#00FF00',
|
|
168
|
+
exceedPlanDBColor: '#cc0000'},
|
|
169
|
+
barHeightAdj: 0, // Progress bar height adjustment (default 0px, no adjustment; larger value = higher bar. Can be negative)
|
|
170
|
+
barDistanceAdj: 0, // Distance adjustment between plan and actual progress bars (default 0px, no adjustment; larger value = closer. Can be negative)
|
|
171
|
+
|
|
172
|
+
// Drag handle
|
|
173
|
+
dragHandlerBackColor: '#D8D8D8', // Drag handle background color
|
|
174
|
+
|
|
175
|
+
// lineExpandLen: 0, // Dependency line extension parameter
|
|
176
|
+
dependLineColor: '#228B22', // Connection line color
|
|
177
|
+
dependLineMouseOverColor: '#FE9A2E', // Connection line mouse hover color
|
|
178
|
+
criticalPathBGColor: '#FE9A2E', // Critical path marker color
|
|
179
|
+
|
|
180
|
+
// Width and height settings
|
|
181
|
+
leftSideWidth: 300, // Set left panel width, default: 300px
|
|
182
|
+
contentHeight: 360, // Set Gantt chart height (excluding header), default: 300px. If adjustGanttHeight function is called on page for auto-height, this parameter can be omitted
|
|
183
|
+
rowHeight: 35, // Set row height, default: 35px
|
|
184
|
+
|
|
185
|
+
// Left column width settings, can be deprecated after columnDefs is complete
|
|
186
|
+
iconColWidth: 30, // Set icon column width, default: 60px
|
|
187
|
+
nameColWidth: 150, // Set task/resource column width, default: 150px
|
|
188
|
+
dateColWidth: 120, // Set date column width, default: 80px
|
|
189
|
+
|
|
190
|
+
// Right grid width settings (for different time scales)
|
|
191
|
+
hourColWidth: 20, // Hour scale
|
|
192
|
+
dayColWidth: 20, // Day scale
|
|
193
|
+
monthColWidth: 70, // Month scale
|
|
194
|
+
quarterColWidth: 100 // Quarter scale
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// Gantt chart parameter configuration
|
|
198
|
+
myGantt.config(ganttConfig);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
5. Get data from backend, or define data
|
|
202
|
+
|
|
203
|
+
```javascript
|
|
204
|
+
/*
|
|
205
|
+
Gantt chart data object item description:
|
|
206
|
+
I: Built-in fixed data items, cannot customize other names
|
|
207
|
+
1. id // (Required) String Node ID (any string or number, must be unique)
|
|
208
|
+
2. plan // (Optional) Array Plan data
|
|
209
|
+
3. isExpand // (Optional) Number(0 or 1) Whether to expand display 1: expand/0: collapse
|
|
210
|
+
4. isGroup // (Optional) Number(0 or 1) Whether to set as parent (group) 1: group/0: leaf node
|
|
211
|
+
5. preNodes // (Optional) String|Array Predecessor nodes, use comma to separate multiple predecessor nodes
|
|
212
|
+
6. parentId // (Optional) String Parent node ID (when current row is top-level node, this value must be set to empty "")
|
|
213
|
+
7. isMS // (Optional) Number(0 or 1) Whether milestone
|
|
214
|
+
8. caption // (Optional) String Title
|
|
215
|
+
9. planBarColor // (Optional) String Gantt plan background (color value)
|
|
216
|
+
|
|
217
|
+
II: The following data items can use custom names and must match the name in column definitions
|
|
218
|
+
10. name // (Required) String Name (can be task name, resource name, etc.)
|
|
219
|
+
11. iconColsVal // (Optional) Array Icon column (can be multiple icons separated by comma)
|
|
220
|
+
12. rsltStart // (Optional) String Date Actual start
|
|
221
|
+
13. rsltEnd // (Optional) String Date Actual end
|
|
222
|
+
14. rsltDur // (Optional) Number Actual workdays
|
|
223
|
+
15. resId // (Optional) String Resource/Responsible person
|
|
224
|
+
16. pctComp // (Optional) Number Completion (0 ~ 100 percentage)
|
|
225
|
+
17. seq // (Optional) Decimal Sort number
|
|
226
|
+
18. yourColName // (Optional) String Custom column value, key needs to match custom column name
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
// Gantt chart data
|
|
230
|
+
let ganttData= [
|
|
231
|
+
{
|
|
232
|
+
"id": 1,
|
|
233
|
+
"seq": 1000,
|
|
234
|
+
"iconColsVal": [],
|
|
235
|
+
"name": "Unit A Construction Period",
|
|
236
|
+
"plan": [{}],
|
|
237
|
+
"rsltStart": "",
|
|
238
|
+
"rsltEnd": "",
|
|
239
|
+
"rsltDur": 1,
|
|
240
|
+
"planBarColor": "",
|
|
241
|
+
"isMS": 0,
|
|
242
|
+
"resId": "1",
|
|
243
|
+
"pctComp": 0,
|
|
244
|
+
"isGroup": 1,
|
|
245
|
+
"parentId": "",
|
|
246
|
+
"isExpand": 1,
|
|
247
|
+
"preNodes": "",
|
|
248
|
+
"caption": "Key Focus",
|
|
249
|
+
"yourColName1": "10",
|
|
250
|
+
"yourColName2": "02",
|
|
251
|
+
"yourColName3": "<img src='./images/stop.png'>",
|
|
252
|
+
}, {
|
|
253
|
+
"id": 11,
|
|
254
|
+
"seq": 2000,
|
|
255
|
+
"iconColsVal": [{
|
|
256
|
+
"src": "./images/stop.png",
|
|
257
|
+
"title": "Stop"
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
"name": "Task Name 1",
|
|
261
|
+
"plan": [{
|
|
262
|
+
"start": "",
|
|
263
|
+
"end": "",
|
|
264
|
+
"dur": "2"
|
|
265
|
+
}
|
|
266
|
+
],
|
|
267
|
+
"rsltStart": "2023-07-02",
|
|
268
|
+
"rsltEnd": "2023-07-06",
|
|
269
|
+
"rsltDur": 1,
|
|
270
|
+
"planBarColor": "#2EFE9A",
|
|
271
|
+
"isMS": 0,
|
|
272
|
+
"resId": "2",
|
|
273
|
+
"pctComp": 50,
|
|
274
|
+
"isGroup": 0,
|
|
275
|
+
"parentId": 1,
|
|
276
|
+
"isExpand": 1,
|
|
277
|
+
"preNodes": "",
|
|
278
|
+
"caption": "",
|
|
279
|
+
"yourColName1": "1",
|
|
280
|
+
"yourColName2": "02",
|
|
281
|
+
"yourColName3": "",
|
|
282
|
+
"custRsltBars": [
|
|
283
|
+
{
|
|
284
|
+
name: "p1",
|
|
285
|
+
title: "Segment 1",
|
|
286
|
+
start: "2023-07-02",
|
|
287
|
+
end: "2023-07-04",
|
|
288
|
+
style: "background:#2E9AFE;color:#FFFFFF;text-align:left;"
|
|
289
|
+
}, {
|
|
290
|
+
name: "p2",
|
|
291
|
+
title: "Segment 2",
|
|
292
|
+
start: "2023-07-06",
|
|
293
|
+
end: "2023-07-17",
|
|
294
|
+
html: "<span style='height:7px;border-radius:5px 5px;position:absolute;left:5px;top:-1px;background:red;font-size:9px;color:#FFFFFF'>Beautiful</span>",
|
|
295
|
+
style: "background:#FF0000;color:#FFFFFF;text-align:left;"
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
}, {
|
|
299
|
+
"id": 12,
|
|
300
|
+
"seq": 3000,
|
|
301
|
+
"iconColsVal": [],
|
|
302
|
+
"name": "Task Name 2",
|
|
303
|
+
"plan": [{
|
|
304
|
+
"start": "2023-07-06",
|
|
305
|
+
"end": "2023-07-10"
|
|
306
|
+
}
|
|
307
|
+
],
|
|
308
|
+
"rsltStart": "2023-07-07",
|
|
309
|
+
"rsltEnd": "2023-07-10",
|
|
310
|
+
"rsltDur": 1,
|
|
311
|
+
"planBarColor": "#2EFE9A",
|
|
312
|
+
"isMS": 0,
|
|
313
|
+
"resId": "2",
|
|
314
|
+
"pctComp": 10,
|
|
315
|
+
"isGroup": 0,
|
|
316
|
+
"parentId": 1,
|
|
317
|
+
"isExpand": 1,
|
|
318
|
+
"preNodes": "",
|
|
319
|
+
"caption": "Note 1",
|
|
320
|
+
"yourColName1": "1",
|
|
321
|
+
"yourColName2": "03",
|
|
322
|
+
"yourColName3": "",
|
|
323
|
+
}, {
|
|
324
|
+
"id": 13,
|
|
325
|
+
"seq": 4000,
|
|
326
|
+
"iconColsVal": [{
|
|
327
|
+
"src": "./images/star.png",
|
|
328
|
+
"title": "Star"
|
|
329
|
+
}
|
|
330
|
+
],
|
|
331
|
+
"name": "Task Name 3",
|
|
332
|
+
"plan": [{
|
|
333
|
+
"start": "2023-07-11",
|
|
334
|
+
"end": "2023-07-15"
|
|
335
|
+
}
|
|
336
|
+
],
|
|
337
|
+
"rsltStart": "2023-07-11",
|
|
338
|
+
"rsltEnd": "2023-07-14",
|
|
339
|
+
"rsltDur": 1,
|
|
340
|
+
"planBarColor": "#2EFE9A",
|
|
341
|
+
"isMS": 0,
|
|
342
|
+
"resId": "2",
|
|
343
|
+
"pctComp": 20,
|
|
344
|
+
"isGroup": 0,
|
|
345
|
+
"parentId": 1,
|
|
346
|
+
"isExpand": 1,
|
|
347
|
+
"preNodes": 12,
|
|
348
|
+
"caption": "",
|
|
349
|
+
"yourColName1": "50",
|
|
350
|
+
"yourColName2": "01",
|
|
351
|
+
"yourColName3": "",
|
|
352
|
+
}, {
|
|
353
|
+
"id": 14,
|
|
354
|
+
"seq": 5000,
|
|
355
|
+
"iconColsVal": [],
|
|
356
|
+
"name": "Task Name 4",
|
|
357
|
+
"plan": [{
|
|
358
|
+
"start": "",
|
|
359
|
+
"end": "2023-07-17"
|
|
360
|
+
}
|
|
361
|
+
],
|
|
362
|
+
"rsltStart": "2023-07-16",
|
|
363
|
+
"rsltEnd": "2023-07-17",
|
|
364
|
+
"rsltDur": 1,
|
|
365
|
+
"planBarColor": vPlanBackground,
|
|
366
|
+
"isMS": 0,
|
|
367
|
+
"resId": "2",
|
|
368
|
+
"pctComp": 0,
|
|
369
|
+
"isGroup": 0,
|
|
370
|
+
"parentId": 1,
|
|
371
|
+
"isExpand": 1,
|
|
372
|
+
"preNodes": "",
|
|
373
|
+
"caption": "",
|
|
374
|
+
"yourColName1": "20",
|
|
375
|
+
"yourColName2": "01",
|
|
376
|
+
"yourColName3": "",
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"id": 2,
|
|
380
|
+
"seq": 6000,
|
|
381
|
+
"iconColsVal": [],
|
|
382
|
+
"name": "Unit B Construction Period",
|
|
383
|
+
"plan": [{}
|
|
384
|
+
],
|
|
385
|
+
"rsltStart": "",
|
|
386
|
+
"rsltEnd": "",
|
|
387
|
+
"rsltDur": 1,
|
|
388
|
+
"planBarColor": "",
|
|
389
|
+
"isMS": 0,
|
|
390
|
+
"resId": "1",
|
|
391
|
+
"pctComp": 0,
|
|
392
|
+
"isGroup": 1,
|
|
393
|
+
"parentId": "",
|
|
394
|
+
"isExpand": 1,
|
|
395
|
+
"preNodes": "",
|
|
396
|
+
"caption": "",
|
|
397
|
+
"yourColName1": "4",
|
|
398
|
+
"yourColName2": "01",
|
|
399
|
+
"yourColName3": "<img src='./images/stop.png'>",
|
|
400
|
+
}, {
|
|
401
|
+
"id": 21,
|
|
402
|
+
"seq": 7000,
|
|
403
|
+
"iconColsVal": [{
|
|
404
|
+
"src": "./images/stop.png",
|
|
405
|
+
"title": "Stop"
|
|
406
|
+
}
|
|
407
|
+
],
|
|
408
|
+
"name": "Task Name 1",
|
|
409
|
+
"plan": [{
|
|
410
|
+
"start": "2023-07-19",
|
|
411
|
+
"end": "2023-07-29"
|
|
412
|
+
}
|
|
413
|
+
],
|
|
414
|
+
"rsltStart": "2023-07-26",
|
|
415
|
+
"rsltEnd": "2023-07-29",
|
|
416
|
+
"rsltDur": 1,
|
|
417
|
+
"planBarColor": vPlanBackground,
|
|
418
|
+
"isMS": 0,
|
|
419
|
+
"resId": "2",
|
|
420
|
+
"pctComp": 40,
|
|
421
|
+
"isGroup": 0,
|
|
422
|
+
"parentId": 2,
|
|
423
|
+
"isExpand": 1,
|
|
424
|
+
"preNodes": "",
|
|
425
|
+
"caption": "",
|
|
426
|
+
"yourColName1": "4",
|
|
427
|
+
"yourColName2": "02",
|
|
428
|
+
"yourColName3": "",
|
|
429
|
+
},
|
|
430
|
+
......
|
|
431
|
+
];
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
6. Create Gantt Chart Object
|
|
436
|
+
|
|
437
|
+
```javascript
|
|
438
|
+
// Instantiate Gantt chart object (in Vue, this statement is needed to instantiate the Gantt chart object)
|
|
439
|
+
const myGantt = MZGantt.init();
|
|
440
|
+
|
|
441
|
+
// Start functional modules
|
|
442
|
+
// (1) When using npm package, if editing, export and mobile support are needed, start them here after importing corresponding packages
|
|
443
|
+
// (2) When using standard JS package, the following start commands can be omitted
|
|
444
|
+
// Start Gantt chart editing
|
|
445
|
+
MZGanttEditor.start(myGantt);
|
|
446
|
+
// Start export functionality
|
|
447
|
+
MZGanttExport.start(myGantt);
|
|
448
|
+
|
|
449
|
+
/*
|
|
450
|
+
Create and display Gantt chart
|
|
451
|
+
Parameter 1: (Required) Container div object id
|
|
452
|
+
Parameter 2: (Optional) Time scale type
|
|
453
|
+
Parameter 3: (Optional) Configuration options
|
|
454
|
+
Parameter 4: (Optional) Data
|
|
455
|
+
*/
|
|
456
|
+
myGantt.createGantt("GanttChartDIV", "day", ganttConfig, data);
|
|
457
|
+
|
|
458
|
+
// Note: If ganttConfig and data are not set here, you can use configuration method and data binding method separately
|
|
459
|
+
// Gantt chart parameter configuration
|
|
460
|
+
myGantt.config(ganttConfig);
|
|
461
|
+
|
|
462
|
+
// Load data
|
|
463
|
+
myGantt.bindGanttData(data);
|
|
464
|
+
|
|
465
|
+
// Display Gantt chart
|
|
466
|
+
myGantt.drawGantt()
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
7. Event Listeners
|
|
470
|
+
MZGantt supports listening to rendering or click events, which can be used to implement special control effects.
|
|
471
|
+
|
|
472
|
+
```javascript
|
|
473
|
+
// Cell rendering
|
|
474
|
+
myGantt.on("cellRender", function (row, cellObj) {
|
|
475
|
+
// *******************************************************
|
|
476
|
+
// Can control rendering of the following cell types (field) in the left table of Gantt chart:
|
|
477
|
+
// I. Built-in type columns:
|
|
478
|
+
// name Name
|
|
479
|
+
// iconColsVal Icon column
|
|
480
|
+
// resId Resource/Responsible person
|
|
481
|
+
// planStart Plan start
|
|
482
|
+
// planEnd Plan end
|
|
483
|
+
// planDur Plan days
|
|
484
|
+
// rsltStart Actual start
|
|
485
|
+
// rsltEnd Actual end
|
|
486
|
+
// rsltDur Actual workdays
|
|
487
|
+
// pctComp Completion
|
|
488
|
+
|
|
489
|
+
// II. Custom columns
|
|
490
|
+
// yourColName1 Custom column name (name)
|
|
491
|
+
// *******************************************************
|
|
492
|
+
|
|
493
|
+
// Get cell name (rendering object cell)
|
|
494
|
+
var field = cellObj.field;
|
|
495
|
+
|
|
496
|
+
// Define rendering style object
|
|
497
|
+
var cellStyle = {};
|
|
498
|
+
|
|
499
|
+
// Style setting: Task name
|
|
500
|
+
if (field == "name") {
|
|
501
|
+
if (row.plan[0].dur > 5) {
|
|
502
|
+
cellStyle["cellHTML"] = '<span style="color:red;" >' + row.name + '</span>';
|
|
503
|
+
// cell.style.color = "red";
|
|
504
|
+
}
|
|
505
|
+
if (row.plan[0].dur >= 2 && row.plan[0].dur <= 5) {
|
|
506
|
+
cellStyle["cellHTML"] = '<span style="color:green;" >' + row.name + '</span>';
|
|
507
|
+
}
|
|
508
|
+
if (row.plan[0].dur < 2) {
|
|
509
|
+
cellStyle["cellHTML"] = '<span style="color:black;" >' + row.name + '</span>';
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// Style setting: Responsible person
|
|
514
|
+
if (field == "resId") {
|
|
515
|
+
if (row.name == "Task Name 1") {
|
|
516
|
+
cellStyle["ce11Style"] = 'color:green;font-weight:bold';
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// // Style setting: Custom column (using custom column name)
|
|
521
|
+
// if (field == "yourColName2") {
|
|
522
|
+
// cellStyle["cellHTML"] = '<input id="tstBtn" type ="button" value="Hide Milestone" onclick="test1">';
|
|
523
|
+
// }
|
|
524
|
+
|
|
525
|
+
return cellStyle;
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
// Progress bar rendering
|
|
529
|
+
myGantt.on("barRender", function (row) {
|
|
530
|
+
// Define rendering style object
|
|
531
|
+
var barStyle = {};
|
|
532
|
+
|
|
533
|
+
if (row.name === "Task Name 2") {
|
|
534
|
+
barStyle["planBarStyle"] = 'background:red;';
|
|
535
|
+
// barStyle["planBarLeftHtml"] = '<img width="20px" height="20px" src="./images/work.svg" />';
|
|
536
|
+
// barStyle["planBarOverHtml"] = '';
|
|
537
|
+
barStyle["planBarRightHtml"] = '<div style="display:block;">Hard Work is Cool</div>';
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// Return object
|
|
541
|
+
return barStyle;
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
// Click progress bar
|
|
545
|
+
myGantt.on("clickBar", function (row, eventXY, dom) {
|
|
546
|
+
console.log("click: Task: " + row.name + ", Click date: " + eventXY.date);
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
// Right-click progress bar
|
|
550
|
+
myGantt.on("rightClick", function (row, eventXY, dom) {
|
|
551
|
+
console.log("right click: Task: " + row.name + ", Click object id: " + dom.id);
|
|
552
|
+
console.log("Click date: " + eventXY.date);
|
|
553
|
+
});
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
8. Multiple Loading Methods
|
|
557
|
+
To improve loading efficiency, the plugin supports multiple loading methods.
|
|
558
|
+
###### Method 1: Normal Loading (load and render all tasks at once)
|
|
559
|
+
```javascript
|
|
560
|
+
// Create Gantt chart object and configure
|
|
561
|
+
myGantt.createGantt("GanttChartDIV", "day");
|
|
562
|
+
myGantt.config(ganttConfig);
|
|
563
|
+
// Bind data
|
|
564
|
+
myGantt.bindGanttData(data);
|
|
565
|
+
|
|
566
|
+
// ※ The above three steps can be simplified to:
|
|
567
|
+
myGantt.createGantt("GanttChartDIV", "day", ganttConfig, data);
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
###### Method 2: Data Listener Rendering Loading
|
|
571
|
+
```javascript
|
|
572
|
+
// Configuration parameters
|
|
573
|
+
var ganttConfig = {
|
|
574
|
+
loadType: "listenLoad"
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
// Create Gantt chart object and configure
|
|
578
|
+
myGantt.createGantt("GanttChartDIV", "day");
|
|
579
|
+
myGantt.config(ganttConfig);
|
|
580
|
+
|
|
581
|
+
// Define Gantt chart listener
|
|
582
|
+
var dataListener = myGantt.listener;
|
|
583
|
+
|
|
584
|
+
// Set Gantt chart value, automatically drive plugin to update display
|
|
585
|
+
dataListener.rawGanttData = [
|
|
586
|
+
{
|
|
587
|
+
"id": 1,
|
|
588
|
+
"seq": 1000,
|
|
589
|
+
"iconColsVal": [],
|
|
590
|
+
"name": "Unit A Construction Period",
|
|
591
|
+
"rsltStart": "",
|
|
592
|
+
"rsltEnd": "",
|
|
593
|
+
"rsltDur": 1,
|
|
594
|
+
"planBarColor": "#C0EBE8",
|
|
595
|
+
"linkTo": "http://",
|
|
596
|
+
"isMS": 0,
|
|
597
|
+
"resId": "1",
|
|
598
|
+
"pctComp": 0,
|
|
599
|
+
"isGroup": 1,
|
|
600
|
+
"parentId": "",
|
|
601
|
+
"isExpand": 1,
|
|
602
|
+
"preNodes": "",
|
|
603
|
+
"caption": "Key Focus",
|
|
604
|
+
"plan": [{ "start": "2023-07-05", "end": "2023-07-06", "dur": 10 }]
|
|
605
|
+
}
|
|
606
|
+
];
|
|
607
|
+
|
|
608
|
+
// No need to execute bindGanttData and drawGantt methods
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
###### Method 3: Paginated Rendering (load all data at once, render in pages)
|
|
612
|
+
```javascript
|
|
613
|
+
// Configuration parameters
|
|
614
|
+
var ganttConfig = {
|
|
615
|
+
loadType: "loadAllToPage",
|
|
616
|
+
pageSize: 20 // Pagination page size
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
// Create Gantt chart object and configure
|
|
620
|
+
myGantt.createGantt("GanttChartDIV", "day");
|
|
621
|
+
myGantt.config(ganttConfig);
|
|
622
|
+
|
|
623
|
+
// Bind data (data displayed page by page)
|
|
624
|
+
myGantt.bindGanttData(data);
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
###### Method 4: Paginated Loading Rendering (load and render a certain number of rows each time, load and render page by page)
|
|
628
|
+
```javascript
|
|
629
|
+
// Pagination loading handler
|
|
630
|
+
// Parameter pageNo is the page data requested by plugin, starting from 1
|
|
631
|
+
function loadPageData(pageNode) {
|
|
632
|
+
// Return Gantt chart data for specified page
|
|
633
|
+
...
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// Configuration parameters
|
|
637
|
+
var ganttConfig = {
|
|
638
|
+
loadType: "loadByPage",
|
|
639
|
+
pageSize: 20, // Pagination page size
|
|
640
|
+
loadDataFunc: loadPageData // Pagination loading handler
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
// Create Gantt chart object and configure
|
|
644
|
+
myGantt.createGantt("GanttChartDIV", "day");
|
|
645
|
+
myGantt.config(ganttConfig);
|
|
646
|
+
|
|
647
|
+
// Gantt chart rendering
|
|
648
|
+
myGantt.drawGantt();
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
## IV. Gantt Chart Data Row Data Model
|
|
652
|
+
The table below shows the MZGantt Gantt chart data row data model. Before binding data to the Gantt chart, data must be created in this format. Can bind in batch, refer to bindGanttDate method; can also bind single row, mostly used with external modals.
|
|
653
|
+
|
|
654
|
+
<div style="margin-left:30px">
|
|
655
|
+
|
|
656
|
+
|<div style="width:170px">Data Item</div>| <div style="width:260px">Type</div>| <div style="width:290px">Description</div> |
|
|
657
|
+
|----| ----| ----|
|
|
658
|
+
id| (Required) String|ID
|
|
659
|
+
name|(Required) String|Name
|
|
660
|
+
isGroup|(Optional) Number(0 or 1)|Whether group task (parent task), determines if a task can contain child tasks
|
|
661
|
+
iconColsVal| (Optional) Array|Image object (src, title) array
|
|
662
|
+
resId|(Optional) String|Resource ID
|
|
663
|
+
resName|(Optional) String|Resource name
|
|
664
|
+
plan|(Optional) Array|Plan object, contains start, end, dur attributes
|
|
665
|
+
rsltStart|(Optional) String Date|Actual start time
|
|
666
|
+
rsltEnd|(Optional) String Date|Actual end time
|
|
667
|
+
pctComp|(Optional) Number|Completion
|
|
668
|
+
rsltDur|(Optional) Number |Actual input
|
|
669
|
+
planBarColor|(Optional) String| Gantt bar color (plan)
|
|
670
|
+
preNodes| (Optional) String|Array|Predecessor nodes
|
|
671
|
+
parentId|(Optional) String |(Optional) String|Parent task ID
|
|
672
|
+
caption|(Optional) String |Title
|
|
673
|
+
isMS|(Optional) Number(0 or 1)|Whether milestone
|
|
674
|
+
Custom Column 1|(Optional) String|Custom column
|
|
675
|
+
Custom Column 2|(Optional) String|Custom column
|
|
676
|
+
custRsltBars|(Optional) Array|Segmented progress bar (name, title, start, end, html, style) array
|
|
677
|
+
|
|
678
|
+
```javascript
|
|
679
|
+
// ****************** Modal example reference as follows ******************
|
|
680
|
+
// Step 1: Use modal, construct the following data when modal is confirmed
|
|
681
|
+
var task = {};
|
|
682
|
+
|
|
683
|
+
task.name = "Test Task 1"; // (Required) Task name
|
|
684
|
+
task.isGroup = 0; // (Optional) Whether parent task (group)
|
|
685
|
+
task.iconColsVal = [{"src": "./images/test.jpg","title": "",}]; // (Optional) Icon column value
|
|
686
|
+
task.resId = "01"; // (Optional) Responsible person ID
|
|
687
|
+
task.resName = "Andy Lau"; // (Optional) Responsible person name (optional)
|
|
688
|
+
task.plan = [{"start": "2023-12-20","end": "2023-12-25","dur": 5}]; // (Optional) Plan data
|
|
689
|
+
task.planBarColor = "#FF0000"; // (Optional) Progress bar color
|
|
690
|
+
task.rsltStart = "2023-12-20"; // (Optional) Actual start
|
|
691
|
+
task.rsltEnd = "2023-12-26"; // (Optional) Actual end
|
|
692
|
+
task.pctComp = 90; // (Optional) Completion percentage
|
|
693
|
+
task.rsltDur = 6; // (Optional) Completion amount
|
|
694
|
+
task.preNodes = [{"id":13,"type":"FS","gapDays":1}]; // (Optional) Predecessor tasks (can be multiple)
|
|
695
|
+
task.parentId = ""; // (Optional when saveType is add/append/insert; required when addChild) Parent task
|
|
696
|
+
task.caption = "Test Task 1"; // (Optional) Task title
|
|
697
|
+
task.isMS = 0; // (Optional) Whether milestone task
|
|
698
|
+
|
|
699
|
+
// Step 2: Update task row data
|
|
700
|
+
var ret = MZGantt.updRows(saveType, createTaskModel()); // saveType: add/append/insert/edit/addChild
|
|
701
|
+
if (ret.code == 0) {
|
|
702
|
+
// Close task input box
|
|
703
|
+
|
|
704
|
+
} else {
|
|
705
|
+
// Show error message
|
|
706
|
+
console.log(ret.msg);
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
```
|
|
710
|
+
</div>
|
|
711
|
+
|
|
712
|
+
## V. Advanced Features
|
|
713
|
+
|
|
714
|
+
MZGantt supports more advanced features, such as internationalization and multi-language package settings, drag to create and edit task relationships, loading animation configuration, etc.
|
|
715
|
+
|
|
716
|
+
1. Internationalization and Language Package Settings
|
|
717
|
+
```javascript
|
|
718
|
+
// Set language package
|
|
719
|
+
// Note: Language type setting must be executed before Gantt chart display method (drawGantt)
|
|
720
|
+
myGantt.setGanttLang("en"); // cn: Chinese; en: English; jp: Japanese;
|
|
721
|
+
|
|
722
|
+
// Character renaming (the following characters can be renamed)
|
|
723
|
+
// count_tab: "No.",
|
|
724
|
+
// reserve_pic: "Reserver",
|
|
725
|
+
// theme: "Theme",
|
|
726
|
+
// loading:"Loading...",
|
|
727
|
+
// click_2_view:"View Image",
|
|
728
|
+
// column_task: "Task Name",
|
|
729
|
+
// column_complete_ratio: "Completion",
|
|
730
|
+
// column_rslt: "Actual Start-End Date",
|
|
731
|
+
// column_start_date: "Plan Start Time",
|
|
732
|
+
// column_end_date: "Plan End Time",
|
|
733
|
+
// column_rslt_start_date: "Actual Start Time",
|
|
734
|
+
// column_rslt_end_date: "Actual End Time",
|
|
735
|
+
// week: "Week",
|
|
736
|
+
// quarter: "Quarter",
|
|
737
|
+
// menu_goto:"Go to Task",
|
|
738
|
+
// menu_goto_today:"Go to Today",
|
|
739
|
+
// select_child:"Select All Child Tasks",
|
|
740
|
+
// menu_FF: "Finish-Finish(FF)",
|
|
741
|
+
// menu_FS: "Finish-Start(FS)",
|
|
742
|
+
// menu_SF: "Start-Finish(SF)",
|
|
743
|
+
// menu_SS: "Start-Start(SS)"
|
|
744
|
+
var labelDefs = {
|
|
745
|
+
"menu_SF":"Start-Finish"}
|
|
746
|
+
;
|
|
747
|
+
|
|
748
|
+
// Internationalization settings
|
|
749
|
+
myGantt.setMyLabels(labelDefs, "en");
|
|
750
|
+
```
|
|
751
|
+
2. Progress Bar Tooltip Customization
|
|
752
|
+
When mouse hovers over progress bar, a tooltip automatically displays task information. You can also customize the tooltip according to requirements.
|
|
753
|
+
```javascript
|
|
754
|
+
// Set parameters infoBoxItems and infoBoxStyle in Gantt chart configuration
|
|
755
|
+
var ganttConfig = {
|
|
756
|
+
...
|
|
757
|
+
infoBoxItems: [ // Tooltip item definition
|
|
758
|
+
{
|
|
759
|
+
title: '',value: "name",
|
|
760
|
+
titleStyle: "font-weight: bold;",
|
|
761
|
+
valStyle: "font-weight: bold;"},
|
|
762
|
+
{
|
|
763
|
+
title: 'Formula', expression: "((yourColName1 * yourColName3) + pctComp) + ' days'",
|
|
764
|
+
titleStyle: "font-weight: bold;",
|
|
765
|
+
valStyle: "color: red;"},
|
|
766
|
+
{
|
|
767
|
+
title: 'Formatted String', value: "This is formatted: {planStart}",
|
|
768
|
+
titleStyle: "font-weight: bold;",
|
|
769
|
+
valStyle: "color: red;"},
|
|
770
|
+
{
|
|
771
|
+
title: 'Plan Start', value: "planStart",
|
|
772
|
+
titleStyle: ""},
|
|
773
|
+
{
|
|
774
|
+
title: 'Plan End', value: "planEnd",
|
|
775
|
+
titleStyle: "", },
|
|
776
|
+
{
|
|
777
|
+
title: 'Actual Start', value: "rsltStart",
|
|
778
|
+
titleStyle: ""},
|
|
779
|
+
{
|
|
780
|
+
title: 'Actual End', value: "rsltEnd",
|
|
781
|
+
titleStyle: "", },
|
|
782
|
+
{
|
|
783
|
+
title: 'Title', value: "title",
|
|
784
|
+
titleStyle: "", }
|
|
785
|
+
],
|
|
786
|
+
infoBoxStyle: // Tooltip style definition
|
|
787
|
+
"BORDER: #cdcdcd 1px solid;background:#FFFFFF;box-shadow: 3px 3px 2px #CDCDCD;border-radius:5px;padding:5px;",
|
|
788
|
+
|
|
789
|
+
...
|
|
790
|
+
}
|
|
791
|
+
```
|
|
792
|
+
Tooltip item settings can use any of the following methods:
|
|
793
|
+
1. Use value
|
|
794
|
+
2. Use expression
|
|
795
|
+
* Date/string type values: must be quoted, e.g.:
|
|
796
|
+
> expression: "This is actual start date: 'rsltStart'"
|
|
797
|
+
* Numeric type values: write directly in expression, e.g.:
|
|
798
|
+
> expression: "((yourColName1 * yourColName3) + pctComp) + ' days'"
|
|
799
|
+
3. Use string replacement ({...})
|
|
800
|
+
|
|
801
|
+
3. Task Relationships
|
|
802
|
+
* <b>Create Task Relationship:</b>
|
|
803
|
+
In edit mode, press mouse on task A progress bar and drag down to task B, release mouse, task relationship modal will pop up, select relationship type, click OK to establish relationship between task A and B.
|
|
804
|
+
* <b>Edit Task Relationship:</b>
|
|
805
|
+
In edit mode, click relationship line, task relationship modal will pop up, modify or delete task relationship.
|
|
806
|
+
|
|
807
|
+
* <b>Gap Time Modification Methods:</b>
|
|
808
|
+
Method 1: Modify and save in relationship modal;
|
|
809
|
+
Method 2: Drag successor task, automatically modify.
|
|
810
|
+
|
|
811
|
+
4. Loading Animation Settings
|
|
812
|
+
MZGantt supports displaying loading animation. There are two types: plugin initialization loading animation and manual on/off animation, please refer to the following example.
|
|
813
|
+
```javascript
|
|
814
|
+
// 1. Plugin initialization animation**************************************************
|
|
815
|
+
// 1.1 Standard JS version
|
|
816
|
+
<!-- Import Gantt chart plugin -->
|
|
817
|
+
<link rel="stylesheet" type="text/css" href="../../gantt/mzgantt.css" />
|
|
818
|
+
<script language="javascript">
|
|
819
|
+
// Parameters: show: whether to show plugin initialization animation, default: not show; containerId: display to Gantt chart container dom object id, default: entire window
|
|
820
|
+
window.showInitLoading = {show:true, containerId: "GanttChartDIV"};
|
|
821
|
+
</script>
|
|
822
|
+
<script language="javascript" src="../../gantt/mzgantt.js"></script>
|
|
823
|
+
...
|
|
824
|
+
|
|
825
|
+
// 1.2 npm version
|
|
826
|
+
// Initialize Gantt chart plugin (parameter explanation same as above)
|
|
827
|
+
var showInitLoadingMsg = {show:true, containerId: "GanttChartDIV"};
|
|
828
|
+
const myGantt = MZGantt.init(showInitLoadingMsg);
|
|
829
|
+
...
|
|
830
|
+
|
|
831
|
+
// 2. Manual on/off animation****************************************************
|
|
832
|
+
// When manually turning on loading animation, standard JS version and npm version use the same method.
|
|
833
|
+
// Parameter 1: Display switch (true: show; false: close)
|
|
834
|
+
// Parameter 2: Display position dom object ID (default: entire window)
|
|
835
|
+
myGantt.showLoading(true,"GanttChartDIV");
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
## VI. Plugin Methods and Events
|
|
839
|
+
|
|
840
|
+
MZGantt provides rich interfaces to operate or control Gantt chart data and features.
|
|
841
|
+
1. Gantt Chart Display
|
|
842
|
+
|<div style="width:150px">Method</div>|<div style="width:166px">Description</div>|<div style="width:200px">Parameters</div>|
|
|
843
|
+
|----| ----|----|
|
|
844
|
+
|init|Initialize Gantt chart instance|None (when using plugin in Vue, need to execute this method to instantiate plugin)|
|
|
845
|
+
|createGantt| Create Gantt chart object| Parameter 1: (Required) DIV container ID<br>Parameter 2: (Optional) Time scale day/week/month/quarter (default: day)<br>Parameter 3: Configuration options<br>Parameter 4: (Optional) Data|
|
|
846
|
+
|config|Configure Gantt chart|JSON object value, refer to: Gantt chart parameter configuration|
|
|
847
|
+
|bindGanttData| Bind Gantt chart data|Gantt chart JSON data: must conform to MZGantt data model|
|
|
848
|
+
|drawGantt|Display Gantt chart|None|
|
|
849
|
+
|
|
850
|
+
2. Display Control
|
|
851
|
+
|<div style="width:150px">Method</div>|<div style="width:248px">Description</div>|<div style="width:200px">Parameters</div>|
|
|
852
|
+
|----| ----|----|
|
|
853
|
+
|changeFormat|Change display scale|Display scale: day/week/month/quarter|
|
|
854
|
+
|switchTrack| Switch to show actual|Switch value: true/false|
|
|
855
|
+
|showMileStone|Toggle milestone time marker lines|Switch value: true/false|
|
|
856
|
+
|setMSLine|Dynamically add/modify milestone time marker lines|Milestone definition object (refer to object definition in mileStoneLines)|
|
|
857
|
+
|rmMSLine|Dynamically delete milestone time marker lines|Milestone marker line name (name)|
|
|
858
|
+
|showCriticalPath|Toggle critical path display|Switch value: "1"/"0"|
|
|
859
|
+
|setRowReadonly|Set row read-only condition|Condition judgment function.<br>Example, when setting newly added rows as read-only, code is as follows:<br>`myGantt.setRowReadonly(function(row) {`<br> `return row.operation != "new" && row.operation != "newmodified";`<br>`});`|
|
|
860
|
+
|adjustGanttHeight|Dynamically adjust Gantt chart area height, can achieve Gantt chart height auto-adaptation|Gantt chart area height (pixel value)|
|
|
861
|
+
|setColsVisiable|Dynamically set column visibility|Refer to example for parameters, set colname1 and colname2 invisible:<br>`myGantt.setColsVisiable({colname1: false, colname2: false})`|
|
|
862
|
+
|fitGanttWidth|Dynamically adjust Gantt chart right side time width, make width just fill right progress bar area|None|
|
|
863
|
+
|fitMobile|Make Gantt chart adapt to mobile display (auto landscape)|None|
|
|
864
|
+
|hideGanttBar|Hide/show right Gantt bar area|Switch value: true/false|
|
|
865
|
+
|
|
866
|
+
3. Get Data
|
|
867
|
+
|<div style="width:150px">Method</div>|<div style="width:360px">Description</div>|<div style="width:240px">Parameters</div>|
|
|
868
|
+
|----| ----|----|
|
|
869
|
+
|getAllRows | Get all row data|None|
|
|
870
|
+
|getUpdatedRows |Get rows with changed values|None|
|
|
871
|
+
|getSelectedRows |Get currently selected rows|None|
|
|
872
|
+
|getAllParentRows | Get all group tasks|None|
|
|
873
|
+
|getChildRows|Get all child task data for specified row|Task ID|
|
|
874
|
+
|getSelectedRowID |Get selected row task ID|None|
|
|
875
|
+
|getSelectedBarID|Get selected progress bar ID (used in resource management)|None|
|
|
876
|
+
|getSelectedRowSeq|Get current selected row index|None|
|
|
877
|
+
|getSelectedRowParent|Get selected row parent task ID|None|
|
|
878
|
+
|getMileStoneLines|Get milestone timeline data|None|
|
|
879
|
+
|
|
880
|
+
4. Property Settings
|
|
881
|
+
|<div style="width:100px">Method</div>|<div style="width:354px">Description</div>|<div style="width:215px">Parameters</div>|
|
|
882
|
+
|----| ----|----|
|
|
883
|
+
|setBulkMoveType|Synchronous move mode setting|D (Related tasks)<br>P (By responsible person)<br>N (All subsequent tasks)|
|
|
884
|
+
|setGanttStatus|Set Gantt chart edit status|Parameter: status character (r: read-only; e: edit)<br>String type|
|
|
885
|
+
|setColEditable|Dynamically set column editable/read-only|Parameter: key-value object (column name: true/false).<br>Example: {'planStart':false,'planEnd':false}<br>true: editable; false: read-only|
|
|
886
|
+
|setStartEndDate|Set project start and end dates|Parameter 1: Start date. String type<br>Parameter 2: End date. String type<br>Parameter 3: Whether to lock date range (true/false). String type|
|
|
887
|
+
|setToDate|Set Gantt chart display date|Parameter 1: Display target date. String type.<br>Parameter 2: Whether to auto-fit width (true/false)<br>Example: myGantt.setToDate('2025-04-16', true);<br>|
|
|
888
|
+
|
|
889
|
+
5. Data Editing
|
|
890
|
+
|<div style="width:130px">Method</div>|<div style="width:124px">Description</div>|<div style="width:240px">Parameters</div>
|
|
891
|
+
|----| ----|----|
|
|
892
|
+
|addRow|Add row|Parameter: Add position <br> add: after current row;<br> insert: before current row;<br> append: at end;<br> addChild: add child task|
|
|
893
|
+
|deleteRows|Delete selected rows|None|
|
|
894
|
+
|cloneRows |Clone selected rows|None|
|
|
895
|
+
|updRows|Update row data|Parameter 1: Add position <br> add: after current row;<br> insert: before current row;<br> append: at end;<br> addChild: add child task;<br> edit: modify<br> Parameter 2: Task model data<br> <br>Note:<br>When using inline editing, this method is not needed.<br>This interface is suitable when using external task edit modal, to submit data obtained from external edit modal (Parameter 2).|
|
|
896
|
+
|resetGantt |Reset all task row edit status|None|
|
|
897
|
+
6. Filter
|
|
898
|
+
|<div style="width:170px">Method</div>| <div style="width:592px">Description</div>
|
|
899
|
+
|----| ----|
|
|
900
|
+
addFilter|Set conditions to filter data. Example:<br>` MZGantt.filterRows((task) =>{return task.duration > 3;},"onlyShow")`
|
|
901
|
+
removefilter|Remove filter, restore data display. Example:<br>`MZGantt.removefilter()`
|
|
902
|
+
|
|
903
|
+
7. Export Image
|
|
904
|
+
|<div style="width:170px">Method</div>| <div style="width:190px">Description</div>| <div style="width:375px">Parameters</div>
|
|
905
|
+
|----| ----|----|
|
|
906
|
+
exportGanttImg |Save as image| None
|
|
907
|
+
|
|
908
|
+
8. Event Listeners
|
|
909
|
+
|<div style="width:230px">Event Name</div>| <div style="width:560px">Description</div>|
|
|
910
|
+
|----| ----|
|
|
911
|
+
|cellRender|Cell rendering event.<br>Supports listening to this event, setting custom callback handler. Render cells.<br>Example: ` MZGantt.on("cellRender", function(row, cellObj) {...})`|
|
|
912
|
+
|cellBlur|Cell blur event. Triggered when inline editing cell loses focus. Example:<br>` MZGantt.on("cellBlur", function(row, cellName, oldVal, newVal) {...})`|
|
|
913
|
+
|rowRender|Table row rendering event.<br>Supports listening to this event, setting custom callback handler. Render row styles.<br>Example: ` MZGantt.on("rowRender", function(row, rowStyleObj) {...})`|
|
|
914
|
+
|barRender|Progress bar rendering event.<br>Can dynamically listen to user data, render progress bar styles in real-time.<br>Example: ` MZGantt.on("barRender", function(row, barObj) {...})`|
|
|
915
|
+
|clickBar |Progress bar click event.<br>Example: ` MZGantt.on("clickBar", function(row, eventXY, dom) {...})`|
|
|
916
|
+
|dblClickBar |Progress bar double-click event.<br>Example: ` MZGantt.on("dblClickBar", function(row, barData, dom) {...})`|
|
|
917
|
+
|clickRow |Row click event.<br>Example: ` MZGantt.on("clickRow", function(row, eventXY) {...})`|
|
|
918
|
+
|rightClick/rightClickBar|Progress bar right-click event.<br>Example: ` MZGantt.on("rightClickBar", function(row, eventXY, dom) {...})`|
|
|
919
|
+
|loaded|Loading complete event.<br>Automatically executed after Gantt chart loading completes, can set user's own processing logic as needed.<br>Example: `MZGantt.on("loaded", function(e, data) {...})`|
|
|
920
|
+
|barDragEnd|Progress bar drag end event. Triggered when dragging progress bar is released. Example:<br>` MZGantt.on("barDragEnd", function(row, updRows) {...})`|
|
|
921
|
+
|rowDragEnd|Row drag end event. Triggered when dragging row is released. Example:<br>` MZGantt.on("rowDragEnd", function(row, updRows) {...})`|
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
## VII. Common Error Codes
|
|
925
|
+
<div style="margin-left:30px">
|
|
926
|
+
|
|
927
|
+
|<div style="width:230px">Error Code</div>| <div style="width:560px">Description</div>|
|
|
928
|
+
|----|----|
|
|
929
|
+
|0x00010|Before executing createGantt command, Gantt chart container div must be loaded, otherwise this error is shown.|
|
|
930
|
+
|0x00020|Error configuring Gantt chart.|
|
|
931
|
+
|0x00030|Error rendering Gantt chart (drawGantt command).|
|
|
932
|
+
|0x00040|Error rendering milestone marker lines.|
|
|
933
|
+
|0x00050|Exception occurred when binding data. Please refer to <IV. Gantt Chart Data Row Data Model> to create Gantt chart row data.|
|
|
934
|
+
|0x00060|Exception occurred when batch loading task data.|
|
|
935
|
+
|0x00080|Error occurred when clicking cell.|
|
|
936
|
+
|0x00090|Error occurred when clicking progress bar.|
|
|
937
|
+
|0x00100|Plugin initialization exception.|
|
|
938
|
+
</div>
|
|
939
|
+
|
|
940
|
+
## VIII. Download
|
|
941
|
+
1. Standard JS Version
|
|
942
|
+
Download Or use following CDN:
|
|
943
|
+
```
|
|
944
|
+
<link rel="stylesheet" type="text/css" href="https://gcore.jsdelivr.net/npm/mzgantt@1.0.7/cdn/mzgantt.css" />
|
|
945
|
+
<script language="javascript" src="https://gcore.jsdelivr.net/npm/mzgantt@1.0.7/cdn/mzgantt.js"></script>
|
|
946
|
+
<script language="javascript" src="https://gcore.jsdelivr.net/npm/mzgantt@1.0.7/cdn/edit.js"></script>
|
|
947
|
+
<script language="javascript" src="https://gcore.jsdelivr.net/npm/mzgantt@1.0.7/cdn/export.js"></script>
|
|
948
|
+
<script language="javascript" src="https://gcore.jsdelivr.net/npm/mzgantt@1.0.7/cdn/mobile.js"></script>
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
2. npm Version (supports Vue, etc.): Install directly using npm command.
|
|
952
|
+
> npm install mzgantt
|
|
953
|
+
|
|
954
|
+
## IX. Versions
|
|
955
|
+
|
|
956
|
+
MZGantt provides 3 versions to meet different user needs.
|
|
957
|
+
|
|
958
|
+
1. Free Trial Version
|
|
959
|
+
No authorization required, free to use after download (with some feature limitations), does not affect your development.
|
|
960
|
+
|
|
961
|
+
2. Personal Version
|
|
962
|
+
Need to obtain personal version license key after download, no feature limitations, can freely use all plugin features.
|
|
963
|
+
|
|
964
|
+
3. Commercial Version
|
|
965
|
+
Need to obtain commercial version license key after download, no feature limitations and no commercial use restrictions, can freely use all plugin features.
|
|
966
|
+
|
|
967
|
+
## X. Contact
|
|
968
|
+
|
|
969
|
+
Mobile: +31(0)623010866
|
|
970
|
+
Email:
|
|
971
|
+
- Service 1: info@ndes-global.com
|
|
972
|
+
- Service 2: info@tecjt.com
|
|
973
|
+
- Service 3: hubosoft@foxmail.com
|