@visactor/vtable-gantt 1.23.3 → 1.24.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/Gantt.d.ts +8 -0
- package/cjs/Gantt.js +91 -9
- package/cjs/Gantt.js.map +1 -1
- package/cjs/components/MenuElementStyle.js +1 -2
- package/cjs/event/touch.js +1 -0
- package/cjs/gantt-helper.js +1 -2
- 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 +8 -7
- 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.js +3 -7
- package/cjs/scenegraph/task-bar.js.map +1 -1
- package/cjs/scenegraph/timeline-header.js +2 -6
- package/cjs/scenegraph/timeline-header.js.map +1 -1
- package/cjs/state/gantt-table-sync.js +1 -0
- 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/ts-types/gantt-engine.d.ts +2 -0
- package/cjs/ts-types/gantt-engine.js.map +1 -1
- package/dist/vtable-gantt.js +1263 -804
- package/dist/vtable-gantt.min.js +2 -2
- package/es/Gantt.d.ts +8 -0
- package/es/Gantt.js +92 -8
- package/es/Gantt.js.map +1 -1
- package/es/components/MenuElementStyle.js +1 -2
- package/es/event/touch.js +2 -1
- package/es/gantt-helper.js +1 -2
- 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 +6 -8
- 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.js +4 -5
- package/es/scenegraph/task-bar.js.map +1 -1
- package/es/scenegraph/timeline-header.js +3 -5
- package/es/scenegraph/timeline-header.js.map +1 -1
- package/es/state/gantt-table-sync.js +2 -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/ts-types/gantt-engine.d.ts +2 -0
- package/es/ts-types/gantt-engine.js.map +1 -1
- package/package.json +5 -5
package/cjs/Gantt.d.ts
CHANGED
|
@@ -119,6 +119,10 @@ export declare class Gantt extends EventTarget {
|
|
|
119
119
|
};
|
|
120
120
|
private millisecondsPerPixel;
|
|
121
121
|
zoomScaleManager?: ZoomScaleManager;
|
|
122
|
+
private _timelineColWidths;
|
|
123
|
+
private _timelineColX;
|
|
124
|
+
private _timelineColStartTimes;
|
|
125
|
+
private _timelineColEndTimes;
|
|
122
126
|
recalculateTimeScale(): void;
|
|
123
127
|
zoomByFactor(factor: number, keepCenter?: boolean, centerX?: number): void;
|
|
124
128
|
taskTableWidth: number;
|
|
@@ -135,6 +139,10 @@ export declare class Gantt extends EventTarget {
|
|
|
135
139
|
getContainer(): HTMLElement;
|
|
136
140
|
_sortScales(): void;
|
|
137
141
|
_generateTimeLineDateMap(): void;
|
|
142
|
+
private _rebuildTimelineColXMap;
|
|
143
|
+
getXByTime(time: number): number;
|
|
144
|
+
getDateIndexByTime(time: number): number;
|
|
145
|
+
getDateIndexByX(x: number): number;
|
|
138
146
|
getRowHeightByIndex(index: number): number;
|
|
139
147
|
getRowsHeightByIndex(startIndex: number, endIndex: number): number;
|
|
140
148
|
getAllRowsHeight(): number;
|
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.
|
|
32
|
-
this.
|
|
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
|
-
|
|
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;
|
|
@@ -504,15 +580,13 @@ class Gantt extends EventTarget_1.EventTarget {
|
|
|
504
580
|
}
|
|
505
581
|
_scrollToMarkLine() {
|
|
506
582
|
if (this.parsedOptions.scrollToMarkLineDate && this.parsedOptions.minDate) {
|
|
507
|
-
const
|
|
508
|
-
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;
|
|
509
584
|
this.stateManager.setScrollLeft(left);
|
|
510
585
|
}
|
|
511
586
|
}
|
|
512
587
|
scrollToMarkLine(date) {
|
|
513
588
|
if (!date || !this.parsedOptions.minDate) return;
|
|
514
|
-
const
|
|
515
|
-
util_1.computeCountToTimeScale)(date, minDate, unit, step) * this.parsedOptions.timelineColWidth - this.tableNoFrameWidth / 2;
|
|
589
|
+
const left = this.getXByTime(date.getTime()) - this.tableNoFrameWidth / 2;
|
|
516
590
|
this.stateManager.setScrollLeft(left);
|
|
517
591
|
}
|
|
518
592
|
addLink(link) {
|
|
@@ -551,9 +625,17 @@ class Gantt extends EventTarget_1.EventTarget {
|
|
|
551
625
|
};
|
|
552
626
|
}
|
|
553
627
|
getDateColWidth(dateIndex) {
|
|
554
|
-
|
|
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;
|
|
555
631
|
}
|
|
556
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
|
+
}
|
|
557
639
|
return (endDateIndex - startDateIndex + 1) * this.parsedOptions.timelineColWidth;
|
|
558
640
|
}
|
|
559
641
|
getDateRangeByIndex(index) {
|