@visactor/vtable-gantt 1.20.3 → 1.21.1-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 +15 -0
- package/cjs/Gantt.js +49 -8
- package/cjs/Gantt.js.map +1 -1
- package/cjs/event/scroll.js +7 -2
- package/cjs/event/scroll.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/state/gantt-table-sync.js +3 -3
- package/cjs/state/gantt-table-sync.js.map +1 -1
- package/cjs/state/state-manager.d.ts +2 -0
- package/cjs/state/state-manager.js +5 -2
- package/cjs/state/state-manager.js.map +1 -1
- package/cjs/ts-types/EVENT_TYPE.d.ts +1 -0
- package/cjs/ts-types/EVENT_TYPE.js +2 -1
- package/cjs/ts-types/EVENT_TYPE.js.map +1 -1
- package/cjs/ts-types/events.d.ts +3 -0
- package/cjs/ts-types/events.js.map +1 -1
- package/cjs/ts-types/gantt-engine.d.ts +2 -0
- package/cjs/ts-types/gantt-engine.js.map +1 -1
- package/cjs/ts-types/index.d.ts +1 -0
- package/cjs/ts-types/index.js +2 -1
- package/cjs/ts-types/index.js.map +1 -1
- package/cjs/ts-types/zoom-scale.d.ts +32 -0
- package/cjs/ts-types/zoom-scale.js +6 -0
- package/cjs/ts-types/zoom-scale.js.map +1 -0
- package/cjs/zoom-scale/DataZoomIntegration.d.ts +50 -0
- package/cjs/zoom-scale/DataZoomIntegration.js +261 -0
- package/cjs/zoom-scale/DataZoomIntegration.js.map +1 -0
- package/cjs/zoom-scale/ZoomScaleManager.d.ts +55 -0
- package/cjs/zoom-scale/ZoomScaleManager.js +327 -0
- package/cjs/zoom-scale/ZoomScaleManager.js.map +1 -0
- package/cjs/zoom-scale/index.d.ts +4 -0
- package/cjs/zoom-scale/index.js +24 -0
- package/cjs/zoom-scale/index.js.map +1 -0
- package/dist/vtable-gantt.js +2072 -207
- package/dist/vtable-gantt.min.js +2 -2
- package/es/Gantt.d.ts +15 -0
- package/es/Gantt.js +50 -8
- package/es/Gantt.js.map +1 -1
- package/es/event/scroll.js +7 -2
- package/es/event/scroll.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/state/gantt-table-sync.js +2 -4
- package/es/state/gantt-table-sync.js.map +1 -1
- package/es/state/state-manager.d.ts +2 -0
- package/es/state/state-manager.js +5 -2
- package/es/state/state-manager.js.map +1 -1
- package/es/ts-types/EVENT_TYPE.d.ts +1 -0
- package/es/ts-types/EVENT_TYPE.js +2 -1
- package/es/ts-types/EVENT_TYPE.js.map +1 -1
- package/es/ts-types/events.d.ts +3 -0
- package/es/ts-types/events.js.map +1 -1
- package/es/ts-types/gantt-engine.d.ts +2 -0
- package/es/ts-types/gantt-engine.js.map +1 -1
- package/es/ts-types/index.d.ts +1 -0
- package/es/ts-types/index.js +2 -0
- package/es/ts-types/index.js.map +1 -1
- package/es/ts-types/zoom-scale.d.ts +32 -0
- package/es/ts-types/zoom-scale.js +2 -0
- package/es/ts-types/zoom-scale.js.map +1 -0
- package/es/zoom-scale/DataZoomIntegration.d.ts +50 -0
- package/es/zoom-scale/DataZoomIntegration.js +253 -0
- package/es/zoom-scale/DataZoomIntegration.js.map +1 -0
- package/es/zoom-scale/ZoomScaleManager.d.ts +55 -0
- package/es/zoom-scale/ZoomScaleManager.js +321 -0
- package/es/zoom-scale/ZoomScaleManager.js.map +1 -0
- package/es/zoom-scale/index.d.ts +4 -0
- package/es/zoom-scale/index.js +4 -0
- package/es/zoom-scale/index.js.map +1 -0
- package/package.json +6 -6
package/cjs/Gantt.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { StateManager } from './state/state-manager';
|
|
|
8
8
|
import { EventTarget } from './event/EventTarget';
|
|
9
9
|
import { DataSource } from './data/DataSource';
|
|
10
10
|
import { PluginManager } from './plugins/plugin-manager';
|
|
11
|
+
import { ZoomScaleManager } from './zoom-scale';
|
|
11
12
|
export declare function createRootElement(padding: any, className?: string): HTMLElement;
|
|
12
13
|
export declare class Gantt extends EventTarget {
|
|
13
14
|
options: GanttConstructorOptions;
|
|
@@ -104,7 +105,16 @@ export declare class Gantt extends EventTarget {
|
|
|
104
105
|
eventOptions: IEventOptions;
|
|
105
106
|
keyboardOptions: IKeyboardOptions;
|
|
106
107
|
markLineCreateOptions: IMarkLineCreateOptions;
|
|
108
|
+
zoom?: {
|
|
109
|
+
minMillisecondsPerPixel?: number;
|
|
110
|
+
maxMillisecondsPerPixel?: number;
|
|
111
|
+
step?: number;
|
|
112
|
+
};
|
|
107
113
|
};
|
|
114
|
+
private millisecondsPerPixel;
|
|
115
|
+
zoomScaleManager?: ZoomScaleManager;
|
|
116
|
+
recalculateTimeScale(): void;
|
|
117
|
+
zoomByFactor(factor: number, keepCenter?: boolean, centerX?: number): void;
|
|
108
118
|
taskTableWidth: number;
|
|
109
119
|
taskTableColumns: ITableColumnsDefine;
|
|
110
120
|
records: any[];
|
|
@@ -148,6 +158,8 @@ export declare class Gantt extends EventTarget {
|
|
|
148
158
|
updateTasksShowMode(tasksShowMode: TasksShowMode): void;
|
|
149
159
|
_resize(): void;
|
|
150
160
|
_syncPropsFromTable(): void;
|
|
161
|
+
private hasDataZoom;
|
|
162
|
+
private getDataZoomHeight;
|
|
151
163
|
getContext(): CanvasRenderingContext2D;
|
|
152
164
|
release(): void;
|
|
153
165
|
updateOption(options: GanttConstructorOptions): void;
|
|
@@ -180,4 +192,7 @@ export declare class Gantt extends EventTarget {
|
|
|
180
192
|
parseTimeFormat(date: string): string;
|
|
181
193
|
getTaskBarStyle(task_index: number, sub_task_index?: number | number[]): ITaskBarStyle;
|
|
182
194
|
formatDate(date: Date | string, format: string): string;
|
|
195
|
+
getCurrentMillisecondsPerPixel(): number;
|
|
196
|
+
setMillisecondsPerPixel(millisecondsPerPixel: number): void;
|
|
197
|
+
getCurrentZoomScaleLevel(): number;
|
|
183
198
|
}
|
package/cjs/Gantt.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.Gantt = exports.createRootElement = void 0;
|
|
6
6
|
|
|
7
|
-
const scenegraph_1 = require("./scenegraph/scenegraph"), env_1 = require("./env"), ts_types_1 = require("./ts-types"), vtable_1 = require("@visactor/vtable"), event_manager_1 = require("./event/event-manager"), state_manager_1 = require("./state/state-manager"), gantt_helper_1 = require("./gantt-helper"), EventTarget_1 = require("./event/EventTarget"), util_1 = require("./tools/util"), DataSource_1 = require("./data/DataSource"), vutils_1 = require("@visactor/vutils"), plugin_manager_1 = require("./plugins/plugin-manager"), vtable_2 = require("@visactor/vtable");
|
|
7
|
+
const scenegraph_1 = require("./scenegraph/scenegraph"), env_1 = require("./env"), ts_types_1 = require("./ts-types"), vtable_1 = require("@visactor/vtable"), event_manager_1 = require("./event/event-manager"), state_manager_1 = require("./state/state-manager"), gantt_helper_1 = require("./gantt-helper"), EventTarget_1 = require("./event/EventTarget"), util_1 = require("./tools/util"), DataSource_1 = require("./data/DataSource"), vutils_1 = require("@visactor/vutils"), plugin_manager_1 = require("./plugins/plugin-manager"), vtable_2 = require("@visactor/vtable"), zoom_scale_1 = require("./zoom-scale");
|
|
8
8
|
|
|
9
9
|
function createRootElement(padding, className = "vtable-gantt") {
|
|
10
10
|
var _a, _b;
|
|
@@ -20,15 +20,23 @@ function createRootElement(padding, className = "vtable-gantt") {
|
|
|
20
20
|
exports.createRootElement = createRootElement;
|
|
21
21
|
|
|
22
22
|
class Gantt extends EventTarget_1.EventTarget {
|
|
23
|
+
recalculateTimeScale() {
|
|
24
|
+
this.zoomScaleManager && this.zoomScaleManager.recalculateTimeScale();
|
|
25
|
+
}
|
|
26
|
+
zoomByFactor(factor, keepCenter = !0, centerX) {
|
|
27
|
+
this.zoomScaleManager && this.zoomScaleManager.zoomByFactor(factor, keepCenter, centerX);
|
|
28
|
+
}
|
|
23
29
|
constructor(container, options) {
|
|
24
|
-
var _a, _b, _c, _d, _e;
|
|
30
|
+
var _a, _b, _c, _d, _e, _f;
|
|
25
31
|
super(), this.parsedOptions = {}, this.container = container, this.options = options,
|
|
26
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,
|
|
27
33
|
this.taskTableColumns = null !== (_d = null === (_c = null == options ? void 0 : options.taskListTable) || void 0 === _c ? void 0 : _c.columns) && void 0 !== _d ? _d : [],
|
|
28
34
|
this.records = null !== (_e = null == options ? void 0 : options.records) && void 0 !== _e ? _e : [],
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
|
|
35
|
+
(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)),
|
|
36
|
+
this._sortScales(), (0, gantt_helper_1.initOptions)(this), this.zoomScaleManager ? this.millisecondsPerPixel = this.zoomScaleManager.getInitialMillisecondsPerPixel() : this.millisecondsPerPixel = 144e4,
|
|
37
|
+
(0, gantt_helper_1.initProjectTaskTimes)(this), this.data = new DataSource_1.DataSource(this),
|
|
38
|
+
this._generateTimeLineDateMap(), this.timeLineHeaderLevel = this.parsedOptions.sortedTimelineScales.length,
|
|
39
|
+
this.element = createRootElement({
|
|
32
40
|
top: 0,
|
|
33
41
|
right: 0,
|
|
34
42
|
left: 0,
|
|
@@ -39,7 +47,8 @@ class Gantt extends EventTarget_1.EventTarget {
|
|
|
39
47
|
this._updateSize()) : this._updateSize(), this._generateListTable(), this._syncPropsFromTable(),
|
|
40
48
|
(0, gantt_helper_1.createSplitLineAndResizeLine)(this), this.scenegraph = new scenegraph_1.Scenegraph(this),
|
|
41
49
|
this.stateManager = new state_manager_1.StateManager(this), this.eventManager = new event_manager_1.EventManager(this),
|
|
42
|
-
this.scenegraph.afterCreateSceneGraph(), this._scrollToMarkLine(), this.pluginManager = new plugin_manager_1.PluginManager(this, options)
|
|
50
|
+
this.scenegraph.afterCreateSceneGraph(), this._scrollToMarkLine(), this.pluginManager = new plugin_manager_1.PluginManager(this, options),
|
|
51
|
+
this.recalculateTimeScale();
|
|
43
52
|
}
|
|
44
53
|
renderTaskBarsTable() {
|
|
45
54
|
this.scenegraph.updateNextFrame();
|
|
@@ -55,7 +64,7 @@ class Gantt extends EventTarget_1.EventTarget {
|
|
|
55
64
|
widthWithoutPadding = element.parentElement.offsetWidth - parseInt(computedStyle.paddingLeft || "0px", 10) - parseInt(computedStyle.paddingRight || "0px", 10),
|
|
56
65
|
heightWithoutPadding = element.parentElement.offsetHeight - parseInt(computedStyle.paddingTop || "0px", 10) - parseInt(computedStyle.paddingBottom || "0px", 20);
|
|
57
66
|
}
|
|
58
|
-
const width1 = (null != widthWithoutPadding ? widthWithoutPadding : 1) - 1 - this.taskTableWidth, height1 = (null != heightWithoutPadding ? heightWithoutPadding : 1) - 1;
|
|
67
|
+
const width1 = (null != widthWithoutPadding ? widthWithoutPadding : 1) - 1 - this.taskTableWidth, height1 = (null != heightWithoutPadding ? heightWithoutPadding : 1) - 1 - this.getDataZoomHeight();
|
|
59
68
|
element.style.width = width1 && `${width1}px` || "0px", element.style.height = height1 && `${height1}px` || "0px";
|
|
60
69
|
const {canvas: canvas} = this;
|
|
61
70
|
widthP = null !== (_b = null === (_a = canvas.parentElement) || void 0 === _a ? void 0 : _a.offsetWidth) && void 0 !== _b ? _b : 1,
|
|
@@ -381,13 +390,24 @@ class Gantt extends EventTarget_1.EventTarget {
|
|
|
381
390
|
this.headerHeight = this.getAllHeaderRowsHeight(), this.drawHeight = Math.min(this.getAllRowsHeight(), this.tableNoFrameHeight),
|
|
382
391
|
this.gridHeight = this.drawHeight - this.headerHeight;
|
|
383
392
|
}
|
|
393
|
+
hasDataZoom() {
|
|
394
|
+
var _a;
|
|
395
|
+
if (!this.zoomScaleManager) return !1;
|
|
396
|
+
const dataZoomConfig = null === (_a = this.zoomScaleManager.config) || void 0 === _a ? void 0 : _a.dataZoomAxis;
|
|
397
|
+
return !(!dataZoomConfig || !1 === dataZoomConfig.enabled) && null !== this.zoomScaleManager.getDataZoomIntegration();
|
|
398
|
+
}
|
|
399
|
+
getDataZoomHeight() {
|
|
400
|
+
var _a, _b, _c;
|
|
401
|
+
return this.hasDataZoom() ? (null === (_c = null === (_b = null === (_a = this.zoomScaleManager) || void 0 === _a ? void 0 : _a.config) || void 0 === _b ? void 0 : _b.dataZoomAxis) || void 0 === _c ? void 0 : _c.height) || 30 : 0;
|
|
402
|
+
}
|
|
384
403
|
getContext() {
|
|
385
404
|
return this.context;
|
|
386
405
|
}
|
|
387
406
|
release() {
|
|
388
407
|
var _a, _b, _c;
|
|
389
408
|
null === (_a = super.release) || void 0 === _a || _a.call(this), this.eventManager.release(),
|
|
390
|
-
null === (_b = this.taskListTableInstance) || void 0 === _b || _b.release()
|
|
409
|
+
null === (_b = this.taskListTableInstance) || void 0 === _b || _b.release(), this.zoomScaleManager && (this.zoomScaleManager.destroyDataZoomIntegration(),
|
|
410
|
+
this.zoomScaleManager = null);
|
|
391
411
|
const parentElement = null === (_c = this.element) || void 0 === _c ? void 0 : _c.parentElement;
|
|
392
412
|
parentElement && (parentElement.removeChild(this.element), this.verticalSplitResizeLine && parentElement.removeChild(this.verticalSplitResizeLine),
|
|
393
413
|
this.horizontalSplitLine && parentElement.removeChild(this.horizontalSplitLine)),
|
|
@@ -531,6 +551,27 @@ class Gantt extends EventTarget_1.EventTarget {
|
|
|
531
551
|
formatDate(date, format) {
|
|
532
552
|
return (0, util_1.formatDate)(date, format);
|
|
533
553
|
}
|
|
554
|
+
getCurrentMillisecondsPerPixel() {
|
|
555
|
+
return this.millisecondsPerPixel;
|
|
556
|
+
}
|
|
557
|
+
setMillisecondsPerPixel(millisecondsPerPixel) {
|
|
558
|
+
var _a, _b, _c, _d;
|
|
559
|
+
const minMillisecondsPerPixel = null !== (_b = null === (_a = this.parsedOptions.zoom) || void 0 === _a ? void 0 : _a.minMillisecondsPerPixel) && void 0 !== _b ? _b : 2e5, maxMillisecondsPerPixel = null !== (_d = null === (_c = this.parsedOptions.zoom) || void 0 === _c ? void 0 : _c.maxMillisecondsPerPixel) && void 0 !== _d ? _d : 3e6, oldMillisecondsPerPixel = this.millisecondsPerPixel, oldWidth = this.parsedOptions.timelineColWidth;
|
|
560
|
+
this.millisecondsPerPixel = Math.max(minMillisecondsPerPixel, Math.min(maxMillisecondsPerPixel, millisecondsPerPixel)),
|
|
561
|
+
this.recalculateTimeScale(), this._updateSize(), this.scenegraph.refreshAll();
|
|
562
|
+
const newWidth = this.parsedOptions.timelineColWidth, scale = newWidth / oldWidth;
|
|
563
|
+
this.hasListeners(ts_types_1.GANTT_EVENT_TYPE.ZOOM) && this.fireListeners(ts_types_1.GANTT_EVENT_TYPE.ZOOM, {
|
|
564
|
+
oldWidth: oldWidth,
|
|
565
|
+
newWidth: newWidth,
|
|
566
|
+
scale: scale,
|
|
567
|
+
oldMillisecondsPerPixel: oldMillisecondsPerPixel,
|
|
568
|
+
newMillisecondsPerPixel: this.millisecondsPerPixel
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
getCurrentZoomScaleLevel() {
|
|
572
|
+
var _a, _b;
|
|
573
|
+
return null !== (_b = null === (_a = this.zoomScaleManager) || void 0 === _a ? void 0 : _a.getCurrentLevel()) && void 0 !== _b ? _b : -1;
|
|
574
|
+
}
|
|
534
575
|
}
|
|
535
576
|
|
|
536
577
|
exports.Gantt = Gantt;
|