gantt-canvas-chart 1.5.4 → 1.6.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 +32 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.es.js +32 -1
- package/dist/index.umd.js +32 -1
- 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.6.0
|
|
3
3
|
* (c) 2025-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -146,6 +146,7 @@ class GanttChart {
|
|
|
146
146
|
resizeObserver;
|
|
147
147
|
taskPositions;
|
|
148
148
|
taskMap;
|
|
149
|
+
holidaysMap;
|
|
149
150
|
isLoadingData = false;
|
|
150
151
|
hasMoreDataLeft = true;
|
|
151
152
|
hasMoreDataRight = true;
|
|
@@ -194,6 +195,9 @@ class GanttChart {
|
|
|
194
195
|
tooltipFormat: null,
|
|
195
196
|
tooltipColor: "black",
|
|
196
197
|
todayColor: "#ff4d4f",
|
|
198
|
+
weekendBgColor: "#f7f7f7",
|
|
199
|
+
holidays: [],
|
|
200
|
+
dateSeparator: "/",
|
|
197
201
|
offsetTop: 0,
|
|
198
202
|
offsetLeft: 0,
|
|
199
203
|
scrollEdgeThresholds: 10,
|
|
@@ -232,6 +236,7 @@ class GanttChart {
|
|
|
232
236
|
this.totalHeight = 0;
|
|
233
237
|
this.taskPositions = /* @__PURE__ */ new Map();
|
|
234
238
|
this.taskMap = /* @__PURE__ */ new Map();
|
|
239
|
+
this.holidaysMap = /* @__PURE__ */ new Map();
|
|
235
240
|
this.handleMouseMove = this.handleMouseMove.bind(this);
|
|
236
241
|
this.handleMouseLeave = this.handleMouseLeave.bind(this);
|
|
237
242
|
this.handleScroll = this.handleScroll.bind(this);
|
|
@@ -241,6 +246,9 @@ class GanttChart {
|
|
|
241
246
|
this.init();
|
|
242
247
|
}
|
|
243
248
|
init() {
|
|
249
|
+
if (this.config.holidays.length > 0) {
|
|
250
|
+
this.buildHolidaysMap();
|
|
251
|
+
}
|
|
244
252
|
this.buildTaskMap();
|
|
245
253
|
this.updatePixelsPerDay();
|
|
246
254
|
this.calculateFullTimeline();
|
|
@@ -289,10 +297,26 @@ class GanttChart {
|
|
|
289
297
|
this.updatePixelsPerDay();
|
|
290
298
|
this.calculateFullTimeline();
|
|
291
299
|
}
|
|
300
|
+
if (this.config.holidays.length !== this.holidaysMap.size) {
|
|
301
|
+
this.buildHolidaysMap();
|
|
302
|
+
}
|
|
292
303
|
this.updateLoadMoreConf();
|
|
293
304
|
this.updateDimensions();
|
|
294
305
|
this.render();
|
|
295
306
|
}
|
|
307
|
+
buildHolidaysMap() {
|
|
308
|
+
this.holidaysMap.clear();
|
|
309
|
+
const separator = this.config.dateSeparator;
|
|
310
|
+
if (this.config.holidays && this.config.holidays.length > 0 && this.config.holidays[0].includes(separator)) {
|
|
311
|
+
this.config.holidays.forEach((holiday) => {
|
|
312
|
+
this.holidaysMap.set(holiday, true);
|
|
313
|
+
});
|
|
314
|
+
} else {
|
|
315
|
+
this.config.holidays.forEach((holiday) => {
|
|
316
|
+
this.holidaysMap.set(DateUtils.format(new Date(holiday), `yyyy${separator}MM${separator}dd`), true);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
296
320
|
setData(newData, newConfig) {
|
|
297
321
|
this.data = newData;
|
|
298
322
|
this.buildTaskMap();
|
|
@@ -930,6 +954,7 @@ class GanttChart {
|
|
|
930
954
|
}
|
|
931
955
|
// In the drawGrid method
|
|
932
956
|
drawGrid(ctx, startDate, endDate) {
|
|
957
|
+
const separator = this.config.dateSeparator;
|
|
933
958
|
ctx.strokeStyle = "#e6e6e6";
|
|
934
959
|
ctx.lineWidth = 1;
|
|
935
960
|
ctx.beginPath();
|
|
@@ -989,6 +1014,12 @@ class GanttChart {
|
|
|
989
1014
|
const x = this.snap(this.dateToX(currentDate));
|
|
990
1015
|
ctx.moveTo(x, this.scrollTop);
|
|
991
1016
|
ctx.lineTo(x, this.scrollTop + this.viewportHeight);
|
|
1017
|
+
if (this.config.viewMode === "Day") {
|
|
1018
|
+
if ([0, 6].includes(currentDate.getDay()) || this.holidaysMap.has(DateUtils.format(currentDate, `yyyy${separator}MM${separator}dd`))) {
|
|
1019
|
+
ctx.fillStyle = this.config.weekendBgColor;
|
|
1020
|
+
ctx.fillRect(x + 1, this.scrollTop, Math.round(this.pixelsPerDay - 1), Math.round(this.scrollTop + this.viewportHeight));
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
992
1023
|
switch (this.config.viewMode) {
|
|
993
1024
|
case "Day":
|
|
994
1025
|
nextDate = DateUtils.addDays(currentDate, 1);
|
package/dist/index.css
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -85,6 +85,7 @@ export declare class GanttChart {
|
|
|
85
85
|
row: number;
|
|
86
86
|
task: Task;
|
|
87
87
|
}>;
|
|
88
|
+
holidaysMap: Map<string, boolean>;
|
|
88
89
|
private isLoadingData;
|
|
89
90
|
private hasMoreDataLeft;
|
|
90
91
|
private hasMoreDataRight;
|
|
@@ -99,6 +100,7 @@ export declare class GanttChart {
|
|
|
99
100
|
private buildTaskMap;
|
|
100
101
|
private setupEvents;
|
|
101
102
|
updateConfig(newConfig: GanttConfig): void;
|
|
103
|
+
private buildHolidaysMap;
|
|
102
104
|
setData(newData: GanttData, newConfig?: GanttConfig): void;
|
|
103
105
|
destroy(): void;
|
|
104
106
|
private calculateFullTimeline;
|
|
@@ -180,6 +182,9 @@ export declare interface GanttConfig {
|
|
|
180
182
|
showTooltip?: boolean;
|
|
181
183
|
tooltipColor?: 'black' | 'white';
|
|
182
184
|
todayColor?: string;
|
|
185
|
+
weekendBgColor?: string;
|
|
186
|
+
holidays?: string[];
|
|
187
|
+
dateSeparator?: string;
|
|
183
188
|
offsetTop?: number;
|
|
184
189
|
offsetLeft?: number;
|
|
185
190
|
scrollEdgeThresholds?: number;
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* gantt-canvas-chart v1.
|
|
2
|
+
* gantt-canvas-chart v1.6.0
|
|
3
3
|
* (c) 2025-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -144,6 +144,7 @@ class GanttChart {
|
|
|
144
144
|
resizeObserver;
|
|
145
145
|
taskPositions;
|
|
146
146
|
taskMap;
|
|
147
|
+
holidaysMap;
|
|
147
148
|
isLoadingData = false;
|
|
148
149
|
hasMoreDataLeft = true;
|
|
149
150
|
hasMoreDataRight = true;
|
|
@@ -192,6 +193,9 @@ class GanttChart {
|
|
|
192
193
|
tooltipFormat: null,
|
|
193
194
|
tooltipColor: "black",
|
|
194
195
|
todayColor: "#ff4d4f",
|
|
196
|
+
weekendBgColor: "#f7f7f7",
|
|
197
|
+
holidays: [],
|
|
198
|
+
dateSeparator: "/",
|
|
195
199
|
offsetTop: 0,
|
|
196
200
|
offsetLeft: 0,
|
|
197
201
|
scrollEdgeThresholds: 10,
|
|
@@ -230,6 +234,7 @@ class GanttChart {
|
|
|
230
234
|
this.totalHeight = 0;
|
|
231
235
|
this.taskPositions = /* @__PURE__ */ new Map();
|
|
232
236
|
this.taskMap = /* @__PURE__ */ new Map();
|
|
237
|
+
this.holidaysMap = /* @__PURE__ */ new Map();
|
|
233
238
|
this.handleMouseMove = this.handleMouseMove.bind(this);
|
|
234
239
|
this.handleMouseLeave = this.handleMouseLeave.bind(this);
|
|
235
240
|
this.handleScroll = this.handleScroll.bind(this);
|
|
@@ -239,6 +244,9 @@ class GanttChart {
|
|
|
239
244
|
this.init();
|
|
240
245
|
}
|
|
241
246
|
init() {
|
|
247
|
+
if (this.config.holidays.length > 0) {
|
|
248
|
+
this.buildHolidaysMap();
|
|
249
|
+
}
|
|
242
250
|
this.buildTaskMap();
|
|
243
251
|
this.updatePixelsPerDay();
|
|
244
252
|
this.calculateFullTimeline();
|
|
@@ -287,10 +295,26 @@ class GanttChart {
|
|
|
287
295
|
this.updatePixelsPerDay();
|
|
288
296
|
this.calculateFullTimeline();
|
|
289
297
|
}
|
|
298
|
+
if (this.config.holidays.length !== this.holidaysMap.size) {
|
|
299
|
+
this.buildHolidaysMap();
|
|
300
|
+
}
|
|
290
301
|
this.updateLoadMoreConf();
|
|
291
302
|
this.updateDimensions();
|
|
292
303
|
this.render();
|
|
293
304
|
}
|
|
305
|
+
buildHolidaysMap() {
|
|
306
|
+
this.holidaysMap.clear();
|
|
307
|
+
const separator = this.config.dateSeparator;
|
|
308
|
+
if (this.config.holidays && this.config.holidays.length > 0 && this.config.holidays[0].includes(separator)) {
|
|
309
|
+
this.config.holidays.forEach((holiday) => {
|
|
310
|
+
this.holidaysMap.set(holiday, true);
|
|
311
|
+
});
|
|
312
|
+
} else {
|
|
313
|
+
this.config.holidays.forEach((holiday) => {
|
|
314
|
+
this.holidaysMap.set(DateUtils.format(new Date(holiday), `yyyy${separator}MM${separator}dd`), true);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
294
318
|
setData(newData, newConfig) {
|
|
295
319
|
this.data = newData;
|
|
296
320
|
this.buildTaskMap();
|
|
@@ -928,6 +952,7 @@ class GanttChart {
|
|
|
928
952
|
}
|
|
929
953
|
// In the drawGrid method
|
|
930
954
|
drawGrid(ctx, startDate, endDate) {
|
|
955
|
+
const separator = this.config.dateSeparator;
|
|
931
956
|
ctx.strokeStyle = "#e6e6e6";
|
|
932
957
|
ctx.lineWidth = 1;
|
|
933
958
|
ctx.beginPath();
|
|
@@ -987,6 +1012,12 @@ class GanttChart {
|
|
|
987
1012
|
const x = this.snap(this.dateToX(currentDate));
|
|
988
1013
|
ctx.moveTo(x, this.scrollTop);
|
|
989
1014
|
ctx.lineTo(x, this.scrollTop + this.viewportHeight);
|
|
1015
|
+
if (this.config.viewMode === "Day") {
|
|
1016
|
+
if ([0, 6].includes(currentDate.getDay()) || this.holidaysMap.has(DateUtils.format(currentDate, `yyyy${separator}MM${separator}dd`))) {
|
|
1017
|
+
ctx.fillStyle = this.config.weekendBgColor;
|
|
1018
|
+
ctx.fillRect(x + 1, this.scrollTop, Math.round(this.pixelsPerDay - 1), Math.round(this.scrollTop + this.viewportHeight));
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
990
1021
|
switch (this.config.viewMode) {
|
|
991
1022
|
case "Day":
|
|
992
1023
|
nextDate = DateUtils.addDays(currentDate, 1);
|
package/dist/index.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* gantt-canvas-chart v1.
|
|
2
|
+
* gantt-canvas-chart v1.6.0
|
|
3
3
|
* (c) 2025-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -148,6 +148,7 @@
|
|
|
148
148
|
resizeObserver;
|
|
149
149
|
taskPositions;
|
|
150
150
|
taskMap;
|
|
151
|
+
holidaysMap;
|
|
151
152
|
isLoadingData = false;
|
|
152
153
|
hasMoreDataLeft = true;
|
|
153
154
|
hasMoreDataRight = true;
|
|
@@ -196,6 +197,9 @@
|
|
|
196
197
|
tooltipFormat: null,
|
|
197
198
|
tooltipColor: "black",
|
|
198
199
|
todayColor: "#ff4d4f",
|
|
200
|
+
weekendBgColor: "#f7f7f7",
|
|
201
|
+
holidays: [],
|
|
202
|
+
dateSeparator: "/",
|
|
199
203
|
offsetTop: 0,
|
|
200
204
|
offsetLeft: 0,
|
|
201
205
|
scrollEdgeThresholds: 10,
|
|
@@ -234,6 +238,7 @@
|
|
|
234
238
|
this.totalHeight = 0;
|
|
235
239
|
this.taskPositions = /* @__PURE__ */ new Map();
|
|
236
240
|
this.taskMap = /* @__PURE__ */ new Map();
|
|
241
|
+
this.holidaysMap = /* @__PURE__ */ new Map();
|
|
237
242
|
this.handleMouseMove = this.handleMouseMove.bind(this);
|
|
238
243
|
this.handleMouseLeave = this.handleMouseLeave.bind(this);
|
|
239
244
|
this.handleScroll = this.handleScroll.bind(this);
|
|
@@ -243,6 +248,9 @@
|
|
|
243
248
|
this.init();
|
|
244
249
|
}
|
|
245
250
|
init() {
|
|
251
|
+
if (this.config.holidays.length > 0) {
|
|
252
|
+
this.buildHolidaysMap();
|
|
253
|
+
}
|
|
246
254
|
this.buildTaskMap();
|
|
247
255
|
this.updatePixelsPerDay();
|
|
248
256
|
this.calculateFullTimeline();
|
|
@@ -291,10 +299,26 @@
|
|
|
291
299
|
this.updatePixelsPerDay();
|
|
292
300
|
this.calculateFullTimeline();
|
|
293
301
|
}
|
|
302
|
+
if (this.config.holidays.length !== this.holidaysMap.size) {
|
|
303
|
+
this.buildHolidaysMap();
|
|
304
|
+
}
|
|
294
305
|
this.updateLoadMoreConf();
|
|
295
306
|
this.updateDimensions();
|
|
296
307
|
this.render();
|
|
297
308
|
}
|
|
309
|
+
buildHolidaysMap() {
|
|
310
|
+
this.holidaysMap.clear();
|
|
311
|
+
const separator = this.config.dateSeparator;
|
|
312
|
+
if (this.config.holidays && this.config.holidays.length > 0 && this.config.holidays[0].includes(separator)) {
|
|
313
|
+
this.config.holidays.forEach((holiday) => {
|
|
314
|
+
this.holidaysMap.set(holiday, true);
|
|
315
|
+
});
|
|
316
|
+
} else {
|
|
317
|
+
this.config.holidays.forEach((holiday) => {
|
|
318
|
+
this.holidaysMap.set(DateUtils.format(new Date(holiday), `yyyy${separator}MM${separator}dd`), true);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
298
322
|
setData(newData, newConfig) {
|
|
299
323
|
this.data = newData;
|
|
300
324
|
this.buildTaskMap();
|
|
@@ -932,6 +956,7 @@
|
|
|
932
956
|
}
|
|
933
957
|
// In the drawGrid method
|
|
934
958
|
drawGrid(ctx, startDate, endDate) {
|
|
959
|
+
const separator = this.config.dateSeparator;
|
|
935
960
|
ctx.strokeStyle = "#e6e6e6";
|
|
936
961
|
ctx.lineWidth = 1;
|
|
937
962
|
ctx.beginPath();
|
|
@@ -991,6 +1016,12 @@
|
|
|
991
1016
|
const x = this.snap(this.dateToX(currentDate));
|
|
992
1017
|
ctx.moveTo(x, this.scrollTop);
|
|
993
1018
|
ctx.lineTo(x, this.scrollTop + this.viewportHeight);
|
|
1019
|
+
if (this.config.viewMode === "Day") {
|
|
1020
|
+
if ([0, 6].includes(currentDate.getDay()) || this.holidaysMap.has(DateUtils.format(currentDate, `yyyy${separator}MM${separator}dd`))) {
|
|
1021
|
+
ctx.fillStyle = this.config.weekendBgColor;
|
|
1022
|
+
ctx.fillRect(x + 1, this.scrollTop, Math.round(this.pixelsPerDay - 1), Math.round(this.scrollTop + this.viewportHeight));
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
994
1025
|
switch (this.config.viewMode) {
|
|
995
1026
|
case "Day":
|
|
996
1027
|
nextDate = DateUtils.addDays(currentDate, 1);
|