gantt-canvas-chart 1.3.1 → 1.4.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/dist/index.cjs.js +17 -8
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +17 -8
- package/dist/index.umd.js +17 -8
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* gantt-canvas-chart v1.
|
|
2
|
+
* gantt-canvas-chart v1.4.0
|
|
3
3
|
* (c) 2025-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -121,6 +121,9 @@ class GanttChart {
|
|
|
121
121
|
onDataLoad = null;
|
|
122
122
|
scrollLoadTimer = null;
|
|
123
123
|
constructor(rootContainer, data, config = {}) {
|
|
124
|
+
if (rootContainer.querySelector(".__gantt-chart-container")) {
|
|
125
|
+
throw new Error("GanttChart already exists in this container");
|
|
126
|
+
}
|
|
124
127
|
const container = document.createElement("div");
|
|
125
128
|
const scrollEl = document.createElement("div");
|
|
126
129
|
const headerCanvas = document.createElement("canvas");
|
|
@@ -157,6 +160,7 @@ class GanttChart {
|
|
|
157
160
|
todayColor: "#ff4d4f",
|
|
158
161
|
offsetTop: 0,
|
|
159
162
|
offsetLeft: 0,
|
|
163
|
+
scrollEdgeThresholds: 10,
|
|
160
164
|
enabledLoadMore: [],
|
|
161
165
|
viewFactors: { Day: 80, Week: 20, Month: 15, Year: 6 },
|
|
162
166
|
planBorderColor: "#C1EFCF",
|
|
@@ -372,9 +376,10 @@ class GanttChart {
|
|
|
372
376
|
const viewportHeight = this.viewportHeight;
|
|
373
377
|
const totalWidth = this.totalWidth;
|
|
374
378
|
const totalHeight = this.totalHeight;
|
|
375
|
-
const
|
|
376
|
-
const
|
|
377
|
-
const
|
|
379
|
+
const thresholds = this.config.scrollEdgeThresholds;
|
|
380
|
+
const atLeftEdge = scrollLeft <= thresholds;
|
|
381
|
+
const atRightEdge = scrollLeft + viewportWidth >= totalWidth - thresholds;
|
|
382
|
+
const atBottomEdge = scrollTop + viewportHeight >= totalHeight - thresholds;
|
|
378
383
|
try {
|
|
379
384
|
if (this.hasMoreDataLeft && atLeftEdge && scrollLeft < this.lastScrollLeft) {
|
|
380
385
|
await this.loadMoreData("left");
|
|
@@ -390,9 +395,7 @@ class GanttChart {
|
|
|
390
395
|
}
|
|
391
396
|
// Add this method to reset scroll loading state
|
|
392
397
|
resetScrollLoadingState() {
|
|
393
|
-
this.
|
|
394
|
-
this.hasMoreDataRight = true;
|
|
395
|
-
this.hasMoreDataBottom = true;
|
|
398
|
+
this.updateLoadMoreConf();
|
|
396
399
|
this.lastScrollLeft = 0;
|
|
397
400
|
this.lastScrollTop = 0;
|
|
398
401
|
if (this.scrollLoadTimer !== null) {
|
|
@@ -514,15 +517,21 @@ class GanttChart {
|
|
|
514
517
|
let offset_x_actual_start = null, offset_x_actual_end = null;
|
|
515
518
|
let x_plan_width = 0;
|
|
516
519
|
let x_actual_width = 0;
|
|
520
|
+
let isValidPlanTask = false, isValidActualTask = false;
|
|
517
521
|
const [offsetX_actual, percent_actual] = this.config.viewMode === "Day" && task.actualOffsetPercent ? task.actualOffsetPercent : [0, 1];
|
|
518
522
|
const [offsetX, percent_plan] = this.config.viewMode === "Day" && task.planOffsetPercent ? task.planOffsetPercent : [0, 1];
|
|
519
|
-
if (x_plan_start && x_plan_end) {
|
|
523
|
+
if (x_plan_start && x_plan_end && x_plan_start < x_plan_end) {
|
|
520
524
|
x_plan_width = x_plan_end - x_plan_start;
|
|
521
525
|
offset_x_plan_start = x_plan_start + x_plan_width * offsetX;
|
|
522
526
|
x_plan_end && (offset_x_plan_end = offset_x_plan_start + x_plan_width * percent_plan);
|
|
527
|
+
isValidPlanTask = true;
|
|
523
528
|
}
|
|
524
529
|
if (task.actualStart) {
|
|
525
530
|
x_actual_start = this.dateToX(new Date(task.actualStart));
|
|
531
|
+
isValidActualTask = true;
|
|
532
|
+
}
|
|
533
|
+
if (!isValidPlanTask && !isValidActualTask) {
|
|
534
|
+
return;
|
|
526
535
|
}
|
|
527
536
|
if (task.actualEnd) {
|
|
528
537
|
x_actual_end = this.dateToX(DateUtils.addDays(task.actualEnd, 1));
|
package/dist/index.css
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -142,6 +142,7 @@ export declare interface GanttConfig {
|
|
|
142
142
|
todayColor?: string;
|
|
143
143
|
offsetTop?: number;
|
|
144
144
|
offsetLeft?: number;
|
|
145
|
+
scrollEdgeThresholds?: number;
|
|
145
146
|
enabledLoadMore?: [LoadMoreDirection?, LoadMoreDirection?, LoadMoreDirection?];
|
|
146
147
|
viewFactors?: {
|
|
147
148
|
Day: number;
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* gantt-canvas-chart v1.
|
|
2
|
+
* gantt-canvas-chart v1.4.0
|
|
3
3
|
* (c) 2025-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -119,6 +119,9 @@ class GanttChart {
|
|
|
119
119
|
onDataLoad = null;
|
|
120
120
|
scrollLoadTimer = null;
|
|
121
121
|
constructor(rootContainer, data, config = {}) {
|
|
122
|
+
if (rootContainer.querySelector(".__gantt-chart-container")) {
|
|
123
|
+
throw new Error("GanttChart already exists in this container");
|
|
124
|
+
}
|
|
122
125
|
const container = document.createElement("div");
|
|
123
126
|
const scrollEl = document.createElement("div");
|
|
124
127
|
const headerCanvas = document.createElement("canvas");
|
|
@@ -155,6 +158,7 @@ class GanttChart {
|
|
|
155
158
|
todayColor: "#ff4d4f",
|
|
156
159
|
offsetTop: 0,
|
|
157
160
|
offsetLeft: 0,
|
|
161
|
+
scrollEdgeThresholds: 10,
|
|
158
162
|
enabledLoadMore: [],
|
|
159
163
|
viewFactors: { Day: 80, Week: 20, Month: 15, Year: 6 },
|
|
160
164
|
planBorderColor: "#C1EFCF",
|
|
@@ -370,9 +374,10 @@ class GanttChart {
|
|
|
370
374
|
const viewportHeight = this.viewportHeight;
|
|
371
375
|
const totalWidth = this.totalWidth;
|
|
372
376
|
const totalHeight = this.totalHeight;
|
|
373
|
-
const
|
|
374
|
-
const
|
|
375
|
-
const
|
|
377
|
+
const thresholds = this.config.scrollEdgeThresholds;
|
|
378
|
+
const atLeftEdge = scrollLeft <= thresholds;
|
|
379
|
+
const atRightEdge = scrollLeft + viewportWidth >= totalWidth - thresholds;
|
|
380
|
+
const atBottomEdge = scrollTop + viewportHeight >= totalHeight - thresholds;
|
|
376
381
|
try {
|
|
377
382
|
if (this.hasMoreDataLeft && atLeftEdge && scrollLeft < this.lastScrollLeft) {
|
|
378
383
|
await this.loadMoreData("left");
|
|
@@ -388,9 +393,7 @@ class GanttChart {
|
|
|
388
393
|
}
|
|
389
394
|
// Add this method to reset scroll loading state
|
|
390
395
|
resetScrollLoadingState() {
|
|
391
|
-
this.
|
|
392
|
-
this.hasMoreDataRight = true;
|
|
393
|
-
this.hasMoreDataBottom = true;
|
|
396
|
+
this.updateLoadMoreConf();
|
|
394
397
|
this.lastScrollLeft = 0;
|
|
395
398
|
this.lastScrollTop = 0;
|
|
396
399
|
if (this.scrollLoadTimer !== null) {
|
|
@@ -512,15 +515,21 @@ class GanttChart {
|
|
|
512
515
|
let offset_x_actual_start = null, offset_x_actual_end = null;
|
|
513
516
|
let x_plan_width = 0;
|
|
514
517
|
let x_actual_width = 0;
|
|
518
|
+
let isValidPlanTask = false, isValidActualTask = false;
|
|
515
519
|
const [offsetX_actual, percent_actual] = this.config.viewMode === "Day" && task.actualOffsetPercent ? task.actualOffsetPercent : [0, 1];
|
|
516
520
|
const [offsetX, percent_plan] = this.config.viewMode === "Day" && task.planOffsetPercent ? task.planOffsetPercent : [0, 1];
|
|
517
|
-
if (x_plan_start && x_plan_end) {
|
|
521
|
+
if (x_plan_start && x_plan_end && x_plan_start < x_plan_end) {
|
|
518
522
|
x_plan_width = x_plan_end - x_plan_start;
|
|
519
523
|
offset_x_plan_start = x_plan_start + x_plan_width * offsetX;
|
|
520
524
|
x_plan_end && (offset_x_plan_end = offset_x_plan_start + x_plan_width * percent_plan);
|
|
525
|
+
isValidPlanTask = true;
|
|
521
526
|
}
|
|
522
527
|
if (task.actualStart) {
|
|
523
528
|
x_actual_start = this.dateToX(new Date(task.actualStart));
|
|
529
|
+
isValidActualTask = true;
|
|
530
|
+
}
|
|
531
|
+
if (!isValidPlanTask && !isValidActualTask) {
|
|
532
|
+
return;
|
|
524
533
|
}
|
|
525
534
|
if (task.actualEnd) {
|
|
526
535
|
x_actual_end = this.dateToX(DateUtils.addDays(task.actualEnd, 1));
|
package/dist/index.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* gantt-canvas-chart v1.
|
|
2
|
+
* gantt-canvas-chart v1.4.0
|
|
3
3
|
* (c) 2025-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -123,6 +123,9 @@
|
|
|
123
123
|
onDataLoad = null;
|
|
124
124
|
scrollLoadTimer = null;
|
|
125
125
|
constructor(rootContainer, data, config = {}) {
|
|
126
|
+
if (rootContainer.querySelector(".__gantt-chart-container")) {
|
|
127
|
+
throw new Error("GanttChart already exists in this container");
|
|
128
|
+
}
|
|
126
129
|
const container = document.createElement("div");
|
|
127
130
|
const scrollEl = document.createElement("div");
|
|
128
131
|
const headerCanvas = document.createElement("canvas");
|
|
@@ -159,6 +162,7 @@
|
|
|
159
162
|
todayColor: "#ff4d4f",
|
|
160
163
|
offsetTop: 0,
|
|
161
164
|
offsetLeft: 0,
|
|
165
|
+
scrollEdgeThresholds: 10,
|
|
162
166
|
enabledLoadMore: [],
|
|
163
167
|
viewFactors: { Day: 80, Week: 20, Month: 15, Year: 6 },
|
|
164
168
|
planBorderColor: "#C1EFCF",
|
|
@@ -374,9 +378,10 @@
|
|
|
374
378
|
const viewportHeight = this.viewportHeight;
|
|
375
379
|
const totalWidth = this.totalWidth;
|
|
376
380
|
const totalHeight = this.totalHeight;
|
|
377
|
-
const
|
|
378
|
-
const
|
|
379
|
-
const
|
|
381
|
+
const thresholds = this.config.scrollEdgeThresholds;
|
|
382
|
+
const atLeftEdge = scrollLeft <= thresholds;
|
|
383
|
+
const atRightEdge = scrollLeft + viewportWidth >= totalWidth - thresholds;
|
|
384
|
+
const atBottomEdge = scrollTop + viewportHeight >= totalHeight - thresholds;
|
|
380
385
|
try {
|
|
381
386
|
if (this.hasMoreDataLeft && atLeftEdge && scrollLeft < this.lastScrollLeft) {
|
|
382
387
|
await this.loadMoreData("left");
|
|
@@ -392,9 +397,7 @@
|
|
|
392
397
|
}
|
|
393
398
|
// Add this method to reset scroll loading state
|
|
394
399
|
resetScrollLoadingState() {
|
|
395
|
-
this.
|
|
396
|
-
this.hasMoreDataRight = true;
|
|
397
|
-
this.hasMoreDataBottom = true;
|
|
400
|
+
this.updateLoadMoreConf();
|
|
398
401
|
this.lastScrollLeft = 0;
|
|
399
402
|
this.lastScrollTop = 0;
|
|
400
403
|
if (this.scrollLoadTimer !== null) {
|
|
@@ -516,15 +519,21 @@
|
|
|
516
519
|
let offset_x_actual_start = null, offset_x_actual_end = null;
|
|
517
520
|
let x_plan_width = 0;
|
|
518
521
|
let x_actual_width = 0;
|
|
522
|
+
let isValidPlanTask = false, isValidActualTask = false;
|
|
519
523
|
const [offsetX_actual, percent_actual] = this.config.viewMode === "Day" && task.actualOffsetPercent ? task.actualOffsetPercent : [0, 1];
|
|
520
524
|
const [offsetX, percent_plan] = this.config.viewMode === "Day" && task.planOffsetPercent ? task.planOffsetPercent : [0, 1];
|
|
521
|
-
if (x_plan_start && x_plan_end) {
|
|
525
|
+
if (x_plan_start && x_plan_end && x_plan_start < x_plan_end) {
|
|
522
526
|
x_plan_width = x_plan_end - x_plan_start;
|
|
523
527
|
offset_x_plan_start = x_plan_start + x_plan_width * offsetX;
|
|
524
528
|
x_plan_end && (offset_x_plan_end = offset_x_plan_start + x_plan_width * percent_plan);
|
|
529
|
+
isValidPlanTask = true;
|
|
525
530
|
}
|
|
526
531
|
if (task.actualStart) {
|
|
527
532
|
x_actual_start = this.dateToX(new Date(task.actualStart));
|
|
533
|
+
isValidActualTask = true;
|
|
534
|
+
}
|
|
535
|
+
if (!isValidPlanTask && !isValidActualTask) {
|
|
536
|
+
return;
|
|
528
537
|
}
|
|
529
538
|
if (task.actualEnd) {
|
|
530
539
|
x_actual_end = this.dateToX(DateUtils.addDays(task.actualEnd, 1));
|