@wimi/vtable-gantt 1.0.2 → 1.0.4
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/cjs/Gantt.d.ts +19 -0
- package/cjs/Gantt.js +135 -9
- package/cjs/Gantt.js.map +1 -1
- package/cjs/event/event-manager.js +17 -6
- package/cjs/event/event-manager.js.map +1 -1
- package/cjs/gantt-helper.d.ts +7 -0
- package/cjs/gantt-helper.js +76 -66
- package/cjs/gantt-helper.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/plugins/index.js.map +1 -1
- package/cjs/scenegraph/dependency-link.js +28 -38
- package/cjs/scenegraph/dependency-link.js.map +1 -1
- package/cjs/scenegraph/grid.js +12 -11
- package/cjs/scenegraph/grid.js.map +1 -1
- package/cjs/scenegraph/mark-line.js +10 -12
- package/cjs/scenegraph/mark-line.js.map +1 -1
- package/cjs/scenegraph/task-bar.d.ts +11 -1
- package/cjs/scenegraph/task-bar.js +189 -29
- package/cjs/scenegraph/task-bar.js.map +1 -1
- package/cjs/scenegraph/timeline-header.js +1 -4
- package/cjs/scenegraph/timeline-header.js.map +1 -1
- package/cjs/state/state-manager.js +22 -18
- package/cjs/state/state-manager.js.map +1 -1
- package/cjs/tools/isx.d.ts +1 -1
- package/cjs/tools/util.js +2 -1
- package/cjs/tools/util.js.map +1 -1
- package/cjs/ts-types/gantt-engine.d.ts +8 -0
- package/cjs/ts-types/gantt-engine.js +2 -1
- package/cjs/ts-types/gantt-engine.js.map +1 -1
- package/cjs/zoom-scale/DataZoomIntegration.d.ts +2 -0
- package/cjs/zoom-scale/DataZoomIntegration.js +32 -20
- package/cjs/zoom-scale/DataZoomIntegration.js.map +1 -1
- package/cjs/zoom-scale/ZoomScaleManager.js +1 -2
- package/dist/vtable-gantt.js +4154 -1803
- package/dist/vtable-gantt.min.js +1 -15
- package/es/Gantt.d.ts +19 -0
- package/es/Gantt.js +135 -8
- package/es/Gantt.js.map +1 -1
- package/es/event/event-manager.js +17 -6
- package/es/event/event-manager.js.map +1 -1
- package/es/gantt-helper.d.ts +7 -0
- package/es/gantt-helper.js +75 -63
- package/es/gantt-helper.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/plugins/index.js.map +1 -1
- package/es/scenegraph/dependency-link.js +29 -27
- package/es/scenegraph/dependency-link.js.map +1 -1
- package/es/scenegraph/grid.js +10 -12
- package/es/scenegraph/grid.js.map +1 -1
- package/es/scenegraph/mark-line.js +10 -11
- package/es/scenegraph/mark-line.js.map +1 -1
- package/es/scenegraph/task-bar.d.ts +11 -1
- package/es/scenegraph/task-bar.js +190 -29
- package/es/scenegraph/task-bar.js.map +1 -1
- package/es/scenegraph/timeline-header.js +2 -3
- package/es/scenegraph/timeline-header.js.map +1 -1
- package/es/state/state-manager.js +22 -18
- package/es/state/state-manager.js.map +1 -1
- package/es/tools/isx.d.ts +1 -1
- package/es/tools/util.js +2 -1
- package/es/tools/util.js.map +1 -1
- package/es/ts-types/gantt-engine.d.ts +8 -0
- package/es/ts-types/gantt-engine.js +2 -1
- package/es/ts-types/gantt-engine.js.map +1 -1
- package/es/zoom-scale/DataZoomIntegration.d.ts +2 -0
- package/es/zoom-scale/DataZoomIntegration.js +32 -20
- package/es/zoom-scale/DataZoomIntegration.js.map +1 -1
- package/es/zoom-scale/ZoomScaleManager.js +1 -2
- package/package.json +11 -9
package/es/Gantt.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ export declare class Gantt extends EventTarget {
|
|
|
52
52
|
taskBarStyle: ITaskBarStyle | ((interactionArgs: TaskBarInteractionArgumentType) => ITaskBarStyle);
|
|
53
53
|
taskBarMilestoneStyle: IMilestoneStyle;
|
|
54
54
|
projectBarStyle: ITaskBarStyle | ((interactionArgs: TaskBarInteractionArgumentType) => ITaskBarStyle);
|
|
55
|
+
baselineStyle: ITaskBarStyle | ((interactionArgs: TaskBarInteractionArgumentType) => ITaskBarStyle);
|
|
55
56
|
taskBarMilestoneHypotenuse: number;
|
|
56
57
|
taskBarHoverStyle: ITaskBarHoverStyle;
|
|
57
58
|
taskBarSelectedStyle: ITaskBarSelectedStyle;
|
|
@@ -77,9 +78,13 @@ export declare class Gantt extends EventTarget {
|
|
|
77
78
|
tasksShowMode: TasksShowMode;
|
|
78
79
|
projectSubTasksExpandable: boolean;
|
|
79
80
|
taskBarClip: boolean;
|
|
81
|
+
taskBarLocateIcon: boolean;
|
|
80
82
|
startDateField: string;
|
|
81
83
|
endDateField: string;
|
|
82
84
|
progressField: string;
|
|
85
|
+
baselineStartDateField: string;
|
|
86
|
+
baselineEndDateField: string;
|
|
87
|
+
baselinePosition: 'top' | 'bottom' | 'overlap';
|
|
83
88
|
minDate: Date;
|
|
84
89
|
maxDate: Date;
|
|
85
90
|
_minDateTime: number;
|
|
@@ -115,6 +120,10 @@ export declare class Gantt extends EventTarget {
|
|
|
115
120
|
};
|
|
116
121
|
private millisecondsPerPixel;
|
|
117
122
|
zoomScaleManager?: ZoomScaleManager;
|
|
123
|
+
private _timelineColWidths;
|
|
124
|
+
private _timelineColX;
|
|
125
|
+
private _timelineColStartTimes;
|
|
126
|
+
private _timelineColEndTimes;
|
|
118
127
|
recalculateTimeScale(): void;
|
|
119
128
|
zoomByFactor(factor: number, keepCenter?: boolean, centerX?: number): void;
|
|
120
129
|
taskTableWidth: number;
|
|
@@ -131,6 +140,10 @@ export declare class Gantt extends EventTarget {
|
|
|
131
140
|
getContainer(): HTMLElement;
|
|
132
141
|
_sortScales(): void;
|
|
133
142
|
_generateTimeLineDateMap(): void;
|
|
143
|
+
private _rebuildTimelineColXMap;
|
|
144
|
+
getXByTime(time: number): number;
|
|
145
|
+
getDateIndexByTime(time: number): number;
|
|
146
|
+
getDateIndexByX(x: number): number;
|
|
134
147
|
getRowHeightByIndex(index: number): number;
|
|
135
148
|
getRowsHeightByIndex(startIndex: number, endIndex: number): number;
|
|
136
149
|
getAllRowsHeight(): number;
|
|
@@ -149,6 +162,11 @@ export declare class Gantt extends EventTarget {
|
|
|
149
162
|
endDate: Date;
|
|
150
163
|
progress: number;
|
|
151
164
|
};
|
|
165
|
+
getBaselineInfoByTaskListIndex(taskShowIndex: number, sub_task_index?: number | number[]): {
|
|
166
|
+
baselineStartDate: Date | null;
|
|
167
|
+
baselineEndDate: Date | null;
|
|
168
|
+
baselineDays: number;
|
|
169
|
+
};
|
|
152
170
|
_updateStartDateToTaskRecord(startDate: Date, index: number, sub_task_index?: number | number[]): void;
|
|
153
171
|
_updateEndDateToTaskRecord(endDate: Date, index: number, sub_task_index?: number): void;
|
|
154
172
|
_updateStartEndDateToTaskRecord(startDate: Date, endDate: Date, index: number, sub_task_index?: number): void;
|
|
@@ -193,6 +211,7 @@ export declare class Gantt extends EventTarget {
|
|
|
193
211
|
};
|
|
194
212
|
parseTimeFormat(date: string): string;
|
|
195
213
|
getTaskBarStyle(task_index: number, sub_task_index?: number | number[]): ITaskBarStyle;
|
|
214
|
+
getBaselineStyle(task_index: number, sub_task_index?: number | number[]): ITaskBarStyle;
|
|
196
215
|
formatDate(date: Date | string, format: string): string;
|
|
197
216
|
getCurrentMillisecondsPerPixel(): number;
|
|
198
217
|
setMillisecondsPerPixel(millisecondsPerPixel: number): void;
|
package/es/Gantt.js
CHANGED
|
@@ -14,7 +14,7 @@ import { computeRowsCountByRecordDate, computeRowsCountByRecordDateForCompact, c
|
|
|
14
14
|
|
|
15
15
|
import { EventTarget } from "./event/EventTarget";
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { createDateAtLastHour, createDateAtLastMillisecond, createDateAtMidnight, formatDate, isPropertyWritable, parseDateFormat } from "./tools/util";
|
|
18
18
|
|
|
19
19
|
import { DataSource } from "./data/DataSource";
|
|
20
20
|
|
|
@@ -46,8 +46,9 @@ export class Gantt extends EventTarget {
|
|
|
46
46
|
}
|
|
47
47
|
constructor(container, options) {
|
|
48
48
|
var _a, _b, _c, _d, _e, _f;
|
|
49
|
-
super(), this.parsedOptions = {}, this.
|
|
50
|
-
this.
|
|
49
|
+
super(), this.parsedOptions = {}, this._timelineColWidths = [], this._timelineColX = [],
|
|
50
|
+
this._timelineColStartTimes = [], this._timelineColEndTimes = [], this.container = container,
|
|
51
|
+
this.options = options, this.taskTableWidth = "number" == typeof (null === (_a = null == options ? void 0 : options.taskListTable) || void 0 === _a ? void 0 : _a.tableWidth) ? null === (_b = null == options ? void 0 : options.taskListTable) || void 0 === _b ? void 0 : _b.tableWidth : -1,
|
|
51
52
|
this.taskTableColumns = null !== (_d = null === (_c = null == options ? void 0 : options.taskListTable) || void 0 === _c ? void 0 : _c.columns) && void 0 !== _d ? _d : [],
|
|
52
53
|
this.records = null !== (_e = null == options ? void 0 : options.records) && void 0 !== _e ? _e : [],
|
|
53
54
|
(null === (_f = options.timelineHeader) || void 0 === _f ? void 0 : _f.zoomScale) && !1 !== options.timelineHeader.zoomScale.enabled && (this.zoomScaleManager = new ZoomScaleManager(this, options.timelineHeader.zoomScale)),
|
|
@@ -252,6 +253,80 @@ export class Gantt extends EventTarget {
|
|
|
252
253
|
}
|
|
253
254
|
_generateTimeLineDateMap() {
|
|
254
255
|
if (this.parsedOptions.minDate && this.parsedOptions.maxDate) for (const scale of this.parsedOptions.reverseSortedTimelineScales) scale.timelineDates = generateTimeLineDate(new Date(this.parsedOptions.minDate), this.parsedOptions.maxDate, scale);
|
|
256
|
+
this._rebuildTimelineColXMap();
|
|
257
|
+
}
|
|
258
|
+
_rebuildTimelineColXMap() {
|
|
259
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
260
|
+
const minScale = null === (_a = this.parsedOptions.reverseSortedTimelineScales) || void 0 === _a ? void 0 : _a[0], timelineDates = null !== (_b = null == minScale ? void 0 : minScale.timelineDates) && void 0 !== _b ? _b : [], baseWidth = null !== (_c = this.parsedOptions.timelineColWidth) && void 0 !== _c ? _c : 0, hideWeekend = !0 === (null === (_e = null === (_d = this.options) || void 0 === _d ? void 0 : _d.timelineHeader) || void 0 === _e ? void 0 : _e.hideWeekend), weekendColWidth = null === (_g = null === (_f = this.options) || void 0 === _f ? void 0 : _f.timelineHeader) || void 0 === _g ? void 0 : _g.weekendColWidth, enableWeekendWidth = "day" === (null == minScale ? void 0 : minScale.unit) && 1 === (null == minScale ? void 0 : minScale.step) && (hideWeekend || void 0 !== weekendColWidth);
|
|
261
|
+
this._timelineColWidths = new Array(timelineDates.length), this._timelineColX = new Array(timelineDates.length + 1),
|
|
262
|
+
this._timelineColStartTimes = new Array(timelineDates.length), this._timelineColEndTimes = new Array(timelineDates.length),
|
|
263
|
+
this._timelineColX[0] = 0;
|
|
264
|
+
let sumX = 0;
|
|
265
|
+
for (let i = 0; i < timelineDates.length; i++) {
|
|
266
|
+
const d = timelineDates[i], startTime = null !== (_k = null === (_j = null === (_h = d.startDate) || void 0 === _h ? void 0 : _h.getTime) || void 0 === _j ? void 0 : _j.call(_h)) && void 0 !== _k ? _k : 0, endTime = null !== (_o = null === (_m = null === (_l = d.endDate) || void 0 === _l ? void 0 : _l.getTime) || void 0 === _m ? void 0 : _m.call(_l)) && void 0 !== _o ? _o : startTime;
|
|
267
|
+
this._timelineColStartTimes[i] = startTime, this._timelineColEndTimes[i] = endTime;
|
|
268
|
+
let w = baseWidth;
|
|
269
|
+
if (enableWeekendWidth) {
|
|
270
|
+
const day = d.startDate.getDay();
|
|
271
|
+
(0 === day || 6 === day) && (hideWeekend ? w = 0 : "number" == typeof weekendColWidth ? w = weekendColWidth : "function" == typeof weekendColWidth && (w = weekendColWidth(baseWidth)));
|
|
272
|
+
}
|
|
273
|
+
w = Math.max(0, Number.isFinite(w) ? w : baseWidth), this._timelineColWidths[i] = w,
|
|
274
|
+
sumX += w, this._timelineColX[i + 1] = sumX;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
getXByTime(time) {
|
|
278
|
+
var _a, _b, _c, _d, _e;
|
|
279
|
+
const startTimes = this._timelineColStartTimes, endTimes = this._timelineColEndTimes, widths = this._timelineColWidths, xPrefix = this._timelineColX;
|
|
280
|
+
if (!((null == startTimes ? void 0 : startTimes.length) && (null == endTimes ? void 0 : endTimes.length) && (null == widths ? void 0 : widths.length) && (null == xPrefix ? void 0 : xPrefix.length))) return 0;
|
|
281
|
+
if (time <= startTimes[0]) return 0;
|
|
282
|
+
const lastIndex = endTimes.length - 1;
|
|
283
|
+
if (time > endTimes[lastIndex]) return null !== (_a = xPrefix[lastIndex + 1]) && void 0 !== _a ? _a : 0;
|
|
284
|
+
let low = 0, high = lastIndex;
|
|
285
|
+
for (;low <= high; ) {
|
|
286
|
+
const mid = low + high >> 1, st = startTimes[mid], et = endTimes[mid];
|
|
287
|
+
if (time < st) high = mid - 1; else {
|
|
288
|
+
if (!(time > et)) {
|
|
289
|
+
const offset = (time - st) / Math.max(1, et - st + 1);
|
|
290
|
+
return (null !== (_b = xPrefix[mid]) && void 0 !== _b ? _b : 0) + (null !== (_c = widths[mid]) && void 0 !== _c ? _c : 0) * offset;
|
|
291
|
+
}
|
|
292
|
+
low = mid + 1;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
const idx = Math.max(0, Math.min(lastIndex, high)), st = startTimes[idx], et = endTimes[idx], duration = Math.max(1, et - st + 1), offset = Math.max(0, Math.min(1, (time - st) / duration));
|
|
296
|
+
return (null !== (_d = xPrefix[idx]) && void 0 !== _d ? _d : 0) + (null !== (_e = widths[idx]) && void 0 !== _e ? _e : 0) * offset;
|
|
297
|
+
}
|
|
298
|
+
getDateIndexByTime(time) {
|
|
299
|
+
const startTimes = this._timelineColStartTimes, endTimes = this._timelineColEndTimes;
|
|
300
|
+
if (!(null == startTimes ? void 0 : startTimes.length) || !(null == endTimes ? void 0 : endTimes.length)) return 0;
|
|
301
|
+
if (time <= startTimes[0]) return 0;
|
|
302
|
+
const lastIndex = endTimes.length - 1;
|
|
303
|
+
if (time > endTimes[lastIndex]) return lastIndex;
|
|
304
|
+
let low = 0, high = lastIndex;
|
|
305
|
+
for (;low <= high; ) {
|
|
306
|
+
const mid = low + high >> 1, st = startTimes[mid], et = endTimes[mid];
|
|
307
|
+
if (time < st) high = mid - 1; else {
|
|
308
|
+
if (!(time > et)) return mid;
|
|
309
|
+
low = mid + 1;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return Math.max(0, Math.min(lastIndex, high));
|
|
313
|
+
}
|
|
314
|
+
getDateIndexByX(x) {
|
|
315
|
+
var _a, _b, _c;
|
|
316
|
+
const totalX = x + this.stateManager.scroll.horizontalBarPos, xPrefix = this._timelineColX;
|
|
317
|
+
if (!(null == xPrefix ? void 0 : xPrefix.length)) return 0;
|
|
318
|
+
if (totalX <= 0) return 0;
|
|
319
|
+
const lastIndex = xPrefix.length - 2;
|
|
320
|
+
if (totalX >= (null !== (_a = xPrefix[lastIndex + 1]) && void 0 !== _a ? _a : 0)) return Math.max(0, lastIndex);
|
|
321
|
+
let low = 0, high = lastIndex;
|
|
322
|
+
for (;low <= high; ) {
|
|
323
|
+
const mid = low + high >> 1, left = null !== (_b = xPrefix[mid]) && void 0 !== _b ? _b : 0, right = null !== (_c = xPrefix[mid + 1]) && void 0 !== _c ? _c : left;
|
|
324
|
+
if (totalX < left) high = mid - 1; else {
|
|
325
|
+
if (!(totalX >= right)) return mid;
|
|
326
|
+
low = mid + 1;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return Math.max(0, Math.min(lastIndex, low));
|
|
255
330
|
}
|
|
256
331
|
getRowHeightByIndex(index) {
|
|
257
332
|
return this.taskListTableInstance ? this.taskListTableInstance.getRowHeight(index + this.taskListTableInstance.columnHeaderLevelCount) : this.parsedOptions.rowHeight;
|
|
@@ -266,8 +341,9 @@ export class Gantt extends EventTarget {
|
|
|
266
341
|
return this.parsedOptions.timeLineHeaderRowHeights.reduce(((acc, curr, index) => !1 === this.parsedOptions.sortedTimelineScales[index].visible ? acc : acc + curr), 0);
|
|
267
342
|
}
|
|
268
343
|
getAllDateColsWidth() {
|
|
269
|
-
var _a, _b;
|
|
270
|
-
|
|
344
|
+
var _a, _b, _c;
|
|
345
|
+
const xPrefix = this._timelineColX;
|
|
346
|
+
return (null == xPrefix ? void 0 : xPrefix.length) ? null !== (_a = xPrefix[xPrefix.length - 1]) && void 0 !== _a ? _a : 0 : this.parsedOptions.timelineColWidth * (null !== (_c = null === (_b = this.parsedOptions.reverseSortedTimelineScales[0].timelineDates) || void 0 === _b ? void 0 : _b.length) && void 0 !== _c ? _c : 0);
|
|
271
347
|
}
|
|
272
348
|
getAllTaskBarsHeight() {
|
|
273
349
|
return this.taskListTableInstance ? this.taskListTableInstance.getRowsHeight(this.taskListTableInstance.columnHeaderLevelCount, this.taskListTableInstance.rowCount - 1) : this.itemCount * this.parsedOptions.rowHeight;
|
|
@@ -334,6 +410,36 @@ export class Gantt extends EventTarget {
|
|
|
334
410
|
progress: progress
|
|
335
411
|
};
|
|
336
412
|
}
|
|
413
|
+
getBaselineInfoByTaskListIndex(taskShowIndex, sub_task_index) {
|
|
414
|
+
const taskRecord = this.getRecordByIndex(taskShowIndex, sub_task_index), baselineStartDateField = this.parsedOptions.baselineStartDateField, baselineEndDateField = this.parsedOptions.baselineEndDateField;
|
|
415
|
+
if (!(baselineStartDateField && baselineEndDateField && (null == taskRecord ? void 0 : taskRecord[baselineStartDateField]) && (null == taskRecord ? void 0 : taskRecord[baselineEndDateField]))) return {
|
|
416
|
+
baselineStartDate: null,
|
|
417
|
+
baselineEndDate: null,
|
|
418
|
+
baselineDays: 0
|
|
419
|
+
};
|
|
420
|
+
const rawBaselineStartDateTime = createDateAtMidnight(null == taskRecord ? void 0 : taskRecord[baselineStartDateField]).getTime(), rawBaselineEndDateTime = createDateAtMidnight(null == taskRecord ? void 0 : taskRecord[baselineEndDateField]).getTime();
|
|
421
|
+
if (rawBaselineEndDateTime < this.parsedOptions._minDateTime || rawBaselineStartDateTime > this.parsedOptions._maxDateTime) return {
|
|
422
|
+
baselineStartDate: null,
|
|
423
|
+
baselineEndDate: null,
|
|
424
|
+
baselineDays: 0
|
|
425
|
+
};
|
|
426
|
+
let baselineStartDate, baselineEndDate;
|
|
427
|
+
if (this.parsedOptions.timeScaleIncludeHour) {
|
|
428
|
+
baselineStartDate = createDateAtMidnight(Math.min(Math.max(this.parsedOptions._minDateTime, rawBaselineStartDateTime), this.parsedOptions._maxDateTime));
|
|
429
|
+
const rawEnd = null == taskRecord ? void 0 : taskRecord[baselineEndDateField];
|
|
430
|
+
let hasMillisecondProvided = !1;
|
|
431
|
+
"string" == typeof rawEnd && (hasMillisecondProvided = /:\d{2}\.\d+/.test(rawEnd));
|
|
432
|
+
const shouldForceMillisecond = !hasMillisecondProvided;
|
|
433
|
+
baselineEndDate = createDateAtLastMillisecond(Math.max(Math.min(this.parsedOptions._maxDateTime, rawBaselineEndDateTime), this.parsedOptions._minDateTime), shouldForceMillisecond);
|
|
434
|
+
} else baselineStartDate = createDateAtMidnight(Math.min(Math.max(this.parsedOptions._minDateTime, rawBaselineStartDateTime), this.parsedOptions._maxDateTime), !0),
|
|
435
|
+
baselineEndDate = createDateAtLastHour(Math.max(Math.min(this.parsedOptions._maxDateTime, rawBaselineEndDateTime), this.parsedOptions._minDateTime), !0);
|
|
436
|
+
const baselineDays = (baselineEndDate.getTime() - baselineStartDate.getTime() + 1) / 864e5;
|
|
437
|
+
return {
|
|
438
|
+
baselineStartDate: baselineStartDate,
|
|
439
|
+
baselineEndDate: baselineEndDate,
|
|
440
|
+
baselineDays: baselineDays
|
|
441
|
+
};
|
|
442
|
+
}
|
|
337
443
|
_updateStartDateToTaskRecord(startDate, index, sub_task_index) {
|
|
338
444
|
var _a;
|
|
339
445
|
const taskRecord = this.getRecordByIndex(index, sub_task_index), startDateField = this.parsedOptions.startDateField, dateFormat = null !== (_a = this.parsedOptions.dateFormat) && void 0 !== _a ? _a : parseDateFormat(taskRecord[startDateField]), newStartDate = formatDate(startDate, dateFormat);
|
|
@@ -479,13 +585,13 @@ export class Gantt extends EventTarget {
|
|
|
479
585
|
}
|
|
480
586
|
_scrollToMarkLine() {
|
|
481
587
|
if (this.parsedOptions.scrollToMarkLineDate && this.parsedOptions.minDate) {
|
|
482
|
-
const
|
|
588
|
+
const left = this.getXByTime(this.parsedOptions.scrollToMarkLineDate.getTime()) - this.tableNoFrameWidth / 2;
|
|
483
589
|
this.stateManager.setScrollLeft(left);
|
|
484
590
|
}
|
|
485
591
|
}
|
|
486
592
|
scrollToMarkLine(date) {
|
|
487
593
|
if (!date || !this.parsedOptions.minDate) return;
|
|
488
|
-
const
|
|
594
|
+
const left = this.getXByTime(date.getTime()) - this.tableNoFrameWidth / 2;
|
|
489
595
|
this.stateManager.setScrollLeft(left);
|
|
490
596
|
}
|
|
491
597
|
addLink(link) {
|
|
@@ -524,9 +630,17 @@ export class Gantt extends EventTarget {
|
|
|
524
630
|
};
|
|
525
631
|
}
|
|
526
632
|
getDateColWidth(dateIndex) {
|
|
527
|
-
|
|
633
|
+
var _a;
|
|
634
|
+
const widths = this._timelineColWidths;
|
|
635
|
+
return (null == widths ? void 0 : widths.length) && dateIndex >= 0 && dateIndex < widths.length ? null !== (_a = widths[dateIndex]) && void 0 !== _a ? _a : 0 : this.parsedOptions.timelineColWidth;
|
|
528
636
|
}
|
|
529
637
|
getDateColsWidth(startDateIndex, endDateIndex) {
|
|
638
|
+
var _a, _b;
|
|
639
|
+
const xPrefix = this._timelineColX;
|
|
640
|
+
if (null == xPrefix ? void 0 : xPrefix.length) {
|
|
641
|
+
const start = Math.max(0, Math.min(startDateIndex, xPrefix.length - 1)), end = Math.max(0, Math.min(endDateIndex + 1, xPrefix.length - 1));
|
|
642
|
+
return end <= start ? 0 : (null !== (_a = xPrefix[end]) && void 0 !== _a ? _a : 0) - (null !== (_b = xPrefix[start]) && void 0 !== _b ? _b : 0);
|
|
643
|
+
}
|
|
530
644
|
return (endDateIndex - startDateIndex + 1) * this.parsedOptions.timelineColWidth;
|
|
531
645
|
}
|
|
532
646
|
getDateRangeByIndex(index) {
|
|
@@ -557,6 +671,19 @@ export class Gantt extends EventTarget {
|
|
|
557
671
|
}
|
|
558
672
|
return style;
|
|
559
673
|
}
|
|
674
|
+
getBaselineStyle(task_index, sub_task_index) {
|
|
675
|
+
const {startDate: startDate, endDate: endDate, taskRecord: taskRecord} = this.getTaskInfoByTaskListIndex(task_index, sub_task_index), style = this.parsedOptions.baselineStyle;
|
|
676
|
+
if ("function" == typeof style) {
|
|
677
|
+
return style({
|
|
678
|
+
index: task_index,
|
|
679
|
+
startDate: startDate,
|
|
680
|
+
endDate: endDate,
|
|
681
|
+
taskRecord: taskRecord,
|
|
682
|
+
ganttInstance: this
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
return style;
|
|
686
|
+
}
|
|
560
687
|
formatDate(date, format) {
|
|
561
688
|
return formatDate(date instanceof Date ? date : new Date(date), format);
|
|
562
689
|
}
|