@visactor/vtable-gantt 1.23.3 → 1.24.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/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 +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/ts-types/gantt-engine.d.ts +2 -0
- package/cjs/ts-types/gantt-engine.js.map +1 -1
- package/dist/vtable-gantt.js +1256 -801
- 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/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 +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/ts-types/gantt-engine.d.ts +2 -0
- package/es/ts-types/gantt-engine.js.map +1 -1
- package/package.json +4 -4
package/es/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/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;
|
|
@@ -509,13 +585,13 @@ export class Gantt extends EventTarget {
|
|
|
509
585
|
}
|
|
510
586
|
_scrollToMarkLine() {
|
|
511
587
|
if (this.parsedOptions.scrollToMarkLineDate && this.parsedOptions.minDate) {
|
|
512
|
-
const
|
|
588
|
+
const left = this.getXByTime(this.parsedOptions.scrollToMarkLineDate.getTime()) - this.tableNoFrameWidth / 2;
|
|
513
589
|
this.stateManager.setScrollLeft(left);
|
|
514
590
|
}
|
|
515
591
|
}
|
|
516
592
|
scrollToMarkLine(date) {
|
|
517
593
|
if (!date || !this.parsedOptions.minDate) return;
|
|
518
|
-
const
|
|
594
|
+
const left = this.getXByTime(date.getTime()) - this.tableNoFrameWidth / 2;
|
|
519
595
|
this.stateManager.setScrollLeft(left);
|
|
520
596
|
}
|
|
521
597
|
addLink(link) {
|
|
@@ -554,9 +630,17 @@ export class Gantt extends EventTarget {
|
|
|
554
630
|
};
|
|
555
631
|
}
|
|
556
632
|
getDateColWidth(dateIndex) {
|
|
557
|
-
|
|
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;
|
|
558
636
|
}
|
|
559
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
|
+
}
|
|
560
644
|
return (endDateIndex - startDateIndex + 1) * this.parsedOptions.timelineColWidth;
|
|
561
645
|
}
|
|
562
646
|
getDateRangeByIndex(index) {
|