@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.
Files changed (73) hide show
  1. package/cjs/Gantt.d.ts +19 -0
  2. package/cjs/Gantt.js +135 -9
  3. package/cjs/Gantt.js.map +1 -1
  4. package/cjs/event/event-manager.js +17 -6
  5. package/cjs/event/event-manager.js.map +1 -1
  6. package/cjs/gantt-helper.d.ts +7 -0
  7. package/cjs/gantt-helper.js +76 -66
  8. package/cjs/gantt-helper.js.map +1 -1
  9. package/cjs/index.d.ts +1 -1
  10. package/cjs/index.js +1 -1
  11. package/cjs/index.js.map +1 -1
  12. package/cjs/plugins/index.js.map +1 -1
  13. package/cjs/scenegraph/dependency-link.js +28 -38
  14. package/cjs/scenegraph/dependency-link.js.map +1 -1
  15. package/cjs/scenegraph/grid.js +12 -11
  16. package/cjs/scenegraph/grid.js.map +1 -1
  17. package/cjs/scenegraph/mark-line.js +10 -12
  18. package/cjs/scenegraph/mark-line.js.map +1 -1
  19. package/cjs/scenegraph/task-bar.d.ts +11 -1
  20. package/cjs/scenegraph/task-bar.js +189 -29
  21. package/cjs/scenegraph/task-bar.js.map +1 -1
  22. package/cjs/scenegraph/timeline-header.js +1 -4
  23. package/cjs/scenegraph/timeline-header.js.map +1 -1
  24. package/cjs/state/state-manager.js +22 -18
  25. package/cjs/state/state-manager.js.map +1 -1
  26. package/cjs/tools/isx.d.ts +1 -1
  27. package/cjs/tools/util.js +2 -1
  28. package/cjs/tools/util.js.map +1 -1
  29. package/cjs/ts-types/gantt-engine.d.ts +8 -0
  30. package/cjs/ts-types/gantt-engine.js +2 -1
  31. package/cjs/ts-types/gantt-engine.js.map +1 -1
  32. package/cjs/zoom-scale/DataZoomIntegration.d.ts +2 -0
  33. package/cjs/zoom-scale/DataZoomIntegration.js +32 -20
  34. package/cjs/zoom-scale/DataZoomIntegration.js.map +1 -1
  35. package/cjs/zoom-scale/ZoomScaleManager.js +1 -2
  36. package/dist/vtable-gantt.js +4154 -1803
  37. package/dist/vtable-gantt.min.js +1 -15
  38. package/es/Gantt.d.ts +19 -0
  39. package/es/Gantt.js +135 -8
  40. package/es/Gantt.js.map +1 -1
  41. package/es/event/event-manager.js +17 -6
  42. package/es/event/event-manager.js.map +1 -1
  43. package/es/gantt-helper.d.ts +7 -0
  44. package/es/gantt-helper.js +75 -63
  45. package/es/gantt-helper.js.map +1 -1
  46. package/es/index.d.ts +1 -1
  47. package/es/index.js +1 -1
  48. package/es/index.js.map +1 -1
  49. package/es/plugins/index.js.map +1 -1
  50. package/es/scenegraph/dependency-link.js +29 -27
  51. package/es/scenegraph/dependency-link.js.map +1 -1
  52. package/es/scenegraph/grid.js +10 -12
  53. package/es/scenegraph/grid.js.map +1 -1
  54. package/es/scenegraph/mark-line.js +10 -11
  55. package/es/scenegraph/mark-line.js.map +1 -1
  56. package/es/scenegraph/task-bar.d.ts +11 -1
  57. package/es/scenegraph/task-bar.js +190 -29
  58. package/es/scenegraph/task-bar.js.map +1 -1
  59. package/es/scenegraph/timeline-header.js +2 -3
  60. package/es/scenegraph/timeline-header.js.map +1 -1
  61. package/es/state/state-manager.js +22 -18
  62. package/es/state/state-manager.js.map +1 -1
  63. package/es/tools/isx.d.ts +1 -1
  64. package/es/tools/util.js +2 -1
  65. package/es/tools/util.js.map +1 -1
  66. package/es/ts-types/gantt-engine.d.ts +8 -0
  67. package/es/ts-types/gantt-engine.js +2 -1
  68. package/es/ts-types/gantt-engine.js.map +1 -1
  69. package/es/zoom-scale/DataZoomIntegration.d.ts +2 -0
  70. package/es/zoom-scale/DataZoomIntegration.js +32 -20
  71. package/es/zoom-scale/DataZoomIntegration.js.map +1 -1
  72. package/es/zoom-scale/ZoomScaleManager.js +1 -2
  73. package/package.json +11 -9
package/cjs/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/cjs/Gantt.js CHANGED
@@ -28,8 +28,9 @@ class Gantt extends EventTarget_1.EventTarget {
28
28
  }
29
29
  constructor(container, options) {
30
30
  var _a, _b, _c, _d, _e, _f;
31
- super(), this.parsedOptions = {}, this.container = container, this.options = options,
32
- 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,
31
+ super(), this.parsedOptions = {}, this._timelineColWidths = [], this._timelineColX = [],
32
+ this._timelineColStartTimes = [], this._timelineColEndTimes = [], this.container = container,
33
+ 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,
33
34
  this.taskTableColumns = null !== (_d = null === (_c = null == options ? void 0 : options.taskListTable) || void 0 === _c ? void 0 : _c.columns) && void 0 !== _d ? _d : [],
34
35
  this.records = null !== (_e = null == options ? void 0 : options.records) && void 0 !== _e ? _e : [],
35
36
  (null === (_f = options.timelineHeader) || void 0 === _f ? void 0 : _f.zoomScale) && !1 !== options.timelineHeader.zoomScale.enabled && (this.zoomScaleManager = new zoom_scale_1.ZoomScaleManager(this, options.timelineHeader.zoomScale)),
@@ -238,6 +239,80 @@ class Gantt extends EventTarget_1.EventTarget {
238
239
  _generateTimeLineDateMap() {
239
240
  if (this.parsedOptions.minDate && this.parsedOptions.maxDate) for (const scale of this.parsedOptions.reverseSortedTimelineScales) scale.timelineDates = (0,
240
241
  gantt_helper_1.generateTimeLineDate)(new Date(this.parsedOptions.minDate), this.parsedOptions.maxDate, scale);
242
+ this._rebuildTimelineColXMap();
243
+ }
244
+ _rebuildTimelineColXMap() {
245
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
246
+ 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);
247
+ this._timelineColWidths = new Array(timelineDates.length), this._timelineColX = new Array(timelineDates.length + 1),
248
+ this._timelineColStartTimes = new Array(timelineDates.length), this._timelineColEndTimes = new Array(timelineDates.length),
249
+ this._timelineColX[0] = 0;
250
+ let sumX = 0;
251
+ for (let i = 0; i < timelineDates.length; i++) {
252
+ 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;
253
+ this._timelineColStartTimes[i] = startTime, this._timelineColEndTimes[i] = endTime;
254
+ let w = baseWidth;
255
+ if (enableWeekendWidth) {
256
+ const day = d.startDate.getDay();
257
+ (0 === day || 6 === day) && (hideWeekend ? w = 0 : "number" == typeof weekendColWidth ? w = weekendColWidth : "function" == typeof weekendColWidth && (w = weekendColWidth(baseWidth)));
258
+ }
259
+ w = Math.max(0, Number.isFinite(w) ? w : baseWidth), this._timelineColWidths[i] = w,
260
+ sumX += w, this._timelineColX[i + 1] = sumX;
261
+ }
262
+ }
263
+ getXByTime(time) {
264
+ var _a, _b, _c, _d, _e;
265
+ const startTimes = this._timelineColStartTimes, endTimes = this._timelineColEndTimes, widths = this._timelineColWidths, xPrefix = this._timelineColX;
266
+ 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;
267
+ if (time <= startTimes[0]) return 0;
268
+ const lastIndex = endTimes.length - 1;
269
+ if (time > endTimes[lastIndex]) return null !== (_a = xPrefix[lastIndex + 1]) && void 0 !== _a ? _a : 0;
270
+ let low = 0, high = lastIndex;
271
+ for (;low <= high; ) {
272
+ const mid = low + high >> 1, st = startTimes[mid], et = endTimes[mid];
273
+ if (time < st) high = mid - 1; else {
274
+ if (!(time > et)) {
275
+ const offset = (time - st) / Math.max(1, et - st + 1);
276
+ return (null !== (_b = xPrefix[mid]) && void 0 !== _b ? _b : 0) + (null !== (_c = widths[mid]) && void 0 !== _c ? _c : 0) * offset;
277
+ }
278
+ low = mid + 1;
279
+ }
280
+ }
281
+ 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));
282
+ return (null !== (_d = xPrefix[idx]) && void 0 !== _d ? _d : 0) + (null !== (_e = widths[idx]) && void 0 !== _e ? _e : 0) * offset;
283
+ }
284
+ getDateIndexByTime(time) {
285
+ const startTimes = this._timelineColStartTimes, endTimes = this._timelineColEndTimes;
286
+ if (!(null == startTimes ? void 0 : startTimes.length) || !(null == endTimes ? void 0 : endTimes.length)) return 0;
287
+ if (time <= startTimes[0]) return 0;
288
+ const lastIndex = endTimes.length - 1;
289
+ if (time > endTimes[lastIndex]) return lastIndex;
290
+ let low = 0, high = lastIndex;
291
+ for (;low <= high; ) {
292
+ const mid = low + high >> 1, st = startTimes[mid], et = endTimes[mid];
293
+ if (time < st) high = mid - 1; else {
294
+ if (!(time > et)) return mid;
295
+ low = mid + 1;
296
+ }
297
+ }
298
+ return Math.max(0, Math.min(lastIndex, high));
299
+ }
300
+ getDateIndexByX(x) {
301
+ var _a, _b, _c;
302
+ const totalX = x + this.stateManager.scroll.horizontalBarPos, xPrefix = this._timelineColX;
303
+ if (!(null == xPrefix ? void 0 : xPrefix.length)) return 0;
304
+ if (totalX <= 0) return 0;
305
+ const lastIndex = xPrefix.length - 2;
306
+ if (totalX >= (null !== (_a = xPrefix[lastIndex + 1]) && void 0 !== _a ? _a : 0)) return Math.max(0, lastIndex);
307
+ let low = 0, high = lastIndex;
308
+ for (;low <= high; ) {
309
+ 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;
310
+ if (totalX < left) high = mid - 1; else {
311
+ if (!(totalX >= right)) return mid;
312
+ low = mid + 1;
313
+ }
314
+ }
315
+ return Math.max(0, Math.min(lastIndex, low));
241
316
  }
242
317
  getRowHeightByIndex(index) {
243
318
  return this.taskListTableInstance ? this.taskListTableInstance.getRowHeight(index + this.taskListTableInstance.columnHeaderLevelCount) : this.parsedOptions.rowHeight;
@@ -252,8 +327,9 @@ class Gantt extends EventTarget_1.EventTarget {
252
327
  return this.parsedOptions.timeLineHeaderRowHeights.reduce(((acc, curr, index) => !1 === this.parsedOptions.sortedTimelineScales[index].visible ? acc : acc + curr), 0);
253
328
  }
254
329
  getAllDateColsWidth() {
255
- var _a, _b;
256
- return this.parsedOptions.timelineColWidth * (null !== (_b = null === (_a = this.parsedOptions.reverseSortedTimelineScales[0].timelineDates) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0);
330
+ var _a, _b, _c;
331
+ const xPrefix = this._timelineColX;
332
+ 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);
257
333
  }
258
334
  getAllTaskBarsHeight() {
259
335
  return this.taskListTableInstance ? this.taskListTableInstance.getRowsHeight(this.taskListTableInstance.columnHeaderLevelCount, this.taskListTableInstance.rowCount - 1) : this.itemCount * this.parsedOptions.rowHeight;
@@ -322,6 +398,37 @@ class Gantt extends EventTarget_1.EventTarget {
322
398
  progress: progress
323
399
  };
324
400
  }
401
+ getBaselineInfoByTaskListIndex(taskShowIndex, sub_task_index) {
402
+ const taskRecord = this.getRecordByIndex(taskShowIndex, sub_task_index), baselineStartDateField = this.parsedOptions.baselineStartDateField, baselineEndDateField = this.parsedOptions.baselineEndDateField;
403
+ if (!(baselineStartDateField && baselineEndDateField && (null == taskRecord ? void 0 : taskRecord[baselineStartDateField]) && (null == taskRecord ? void 0 : taskRecord[baselineEndDateField]))) return {
404
+ baselineStartDate: null,
405
+ baselineEndDate: null,
406
+ baselineDays: 0
407
+ };
408
+ const rawBaselineStartDateTime = (0, util_1.createDateAtMidnight)(null == taskRecord ? void 0 : taskRecord[baselineStartDateField]).getTime(), rawBaselineEndDateTime = (0,
409
+ util_1.createDateAtMidnight)(null == taskRecord ? void 0 : taskRecord[baselineEndDateField]).getTime();
410
+ if (rawBaselineEndDateTime < this.parsedOptions._minDateTime || rawBaselineStartDateTime > this.parsedOptions._maxDateTime) return {
411
+ baselineStartDate: null,
412
+ baselineEndDate: null,
413
+ baselineDays: 0
414
+ };
415
+ let baselineStartDate, baselineEndDate;
416
+ if (this.parsedOptions.timeScaleIncludeHour) {
417
+ baselineStartDate = (0, util_1.createDateAtMidnight)(Math.min(Math.max(this.parsedOptions._minDateTime, rawBaselineStartDateTime), this.parsedOptions._maxDateTime));
418
+ const rawEnd = null == taskRecord ? void 0 : taskRecord[baselineEndDateField];
419
+ let hasMillisecondProvided = !1;
420
+ "string" == typeof rawEnd && (hasMillisecondProvided = /:\d{2}\.\d+/.test(rawEnd));
421
+ const shouldForceMillisecond = !hasMillisecondProvided;
422
+ baselineEndDate = (0, util_1.createDateAtLastMillisecond)(Math.max(Math.min(this.parsedOptions._maxDateTime, rawBaselineEndDateTime), this.parsedOptions._minDateTime), shouldForceMillisecond);
423
+ } else baselineStartDate = (0, util_1.createDateAtMidnight)(Math.min(Math.max(this.parsedOptions._minDateTime, rawBaselineStartDateTime), this.parsedOptions._maxDateTime), !0),
424
+ baselineEndDate = (0, util_1.createDateAtLastHour)(Math.max(Math.min(this.parsedOptions._maxDateTime, rawBaselineEndDateTime), this.parsedOptions._minDateTime), !0);
425
+ const baselineDays = (baselineEndDate.getTime() - baselineStartDate.getTime() + 1) / 864e5;
426
+ return {
427
+ baselineStartDate: baselineStartDate,
428
+ baselineEndDate: baselineEndDate,
429
+ baselineDays: baselineDays
430
+ };
431
+ }
325
432
  _updateStartDateToTaskRecord(startDate, index, sub_task_index) {
326
433
  var _a;
327
434
  const taskRecord = this.getRecordByIndex(index, sub_task_index), startDateField = this.parsedOptions.startDateField, dateFormat = null !== (_a = this.parsedOptions.dateFormat) && void 0 !== _a ? _a : (0,
@@ -473,15 +580,13 @@ class Gantt extends EventTarget_1.EventTarget {
473
580
  }
474
581
  _scrollToMarkLine() {
475
582
  if (this.parsedOptions.scrollToMarkLineDate && this.parsedOptions.minDate) {
476
- const minDate = this.parsedOptions.minDate, {unit: unit, step: step} = this.parsedOptions.reverseSortedTimelineScales[0], left = (0,
477
- util_1.computeCountToTimeScale)(this.parsedOptions.scrollToMarkLineDate, minDate, unit, step) * this.parsedOptions.timelineColWidth - this.tableNoFrameWidth / 2;
583
+ const left = this.getXByTime(this.parsedOptions.scrollToMarkLineDate.getTime()) - this.tableNoFrameWidth / 2;
478
584
  this.stateManager.setScrollLeft(left);
479
585
  }
480
586
  }
481
587
  scrollToMarkLine(date) {
482
588
  if (!date || !this.parsedOptions.minDate) return;
483
- const minDate = this.parsedOptions.minDate, {unit: unit, step: step} = this.parsedOptions.reverseSortedTimelineScales[0], left = (0,
484
- util_1.computeCountToTimeScale)(date, minDate, unit, step) * this.parsedOptions.timelineColWidth - this.tableNoFrameWidth / 2;
589
+ const left = this.getXByTime(date.getTime()) - this.tableNoFrameWidth / 2;
485
590
  this.stateManager.setScrollLeft(left);
486
591
  }
487
592
  addLink(link) {
@@ -520,9 +625,17 @@ class Gantt extends EventTarget_1.EventTarget {
520
625
  };
521
626
  }
522
627
  getDateColWidth(dateIndex) {
523
- return this.parsedOptions.timelineColWidth;
628
+ var _a;
629
+ const widths = this._timelineColWidths;
630
+ return (null == widths ? void 0 : widths.length) && dateIndex >= 0 && dateIndex < widths.length ? null !== (_a = widths[dateIndex]) && void 0 !== _a ? _a : 0 : this.parsedOptions.timelineColWidth;
524
631
  }
525
632
  getDateColsWidth(startDateIndex, endDateIndex) {
633
+ var _a, _b;
634
+ const xPrefix = this._timelineColX;
635
+ if (null == xPrefix ? void 0 : xPrefix.length) {
636
+ const start = Math.max(0, Math.min(startDateIndex, xPrefix.length - 1)), end = Math.max(0, Math.min(endDateIndex + 1, xPrefix.length - 1));
637
+ return end <= start ? 0 : (null !== (_a = xPrefix[end]) && void 0 !== _a ? _a : 0) - (null !== (_b = xPrefix[start]) && void 0 !== _b ? _b : 0);
638
+ }
526
639
  return (endDateIndex - startDateIndex + 1) * this.parsedOptions.timelineColWidth;
527
640
  }
528
641
  getDateRangeByIndex(index) {
@@ -553,6 +666,19 @@ class Gantt extends EventTarget_1.EventTarget {
553
666
  }
554
667
  return style;
555
668
  }
669
+ getBaselineStyle(task_index, sub_task_index) {
670
+ const {startDate: startDate, endDate: endDate, taskRecord: taskRecord} = this.getTaskInfoByTaskListIndex(task_index, sub_task_index), style = this.parsedOptions.baselineStyle;
671
+ if ("function" == typeof style) {
672
+ return style({
673
+ index: task_index,
674
+ startDate: startDate,
675
+ endDate: endDate,
676
+ taskRecord: taskRecord,
677
+ ganttInstance: this
678
+ });
679
+ }
680
+ return style;
681
+ }
556
682
  formatDate(date, format) {
557
683
  return (0, util_1.formatDate)(date instanceof Date ? date : new Date(date), format);
558
684
  }