gantt-canvas-chart 1.4.0 → 1.5.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * gantt-canvas-chart v1.4.0
2
+ * gantt-canvas-chart v1.5.0
3
3
  * (c) 2025-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -205,8 +205,8 @@ class GanttChart {
205
205
  }
206
206
  init() {
207
207
  this.buildTaskMap();
208
- this.calculateFullTimeline();
209
208
  this.updatePixelsPerDay();
209
+ this.calculateFullTimeline();
210
210
  this.setupEvents();
211
211
  this.handleResize();
212
212
  }
@@ -278,6 +278,9 @@ class GanttChart {
278
278
  maxDate = DateUtils.addDays(/* @__PURE__ */ new Date(), 60);
279
279
  } else {
280
280
  this.taskMap.forEach(({ task }) => {
281
+ if (task.hide) {
282
+ return;
283
+ }
281
284
  const pStart = new Date(task.planStart);
282
285
  const pEnd = new Date(task.planEnd);
283
286
  if (pStart < minDate) minDate = pStart;
@@ -311,8 +314,8 @@ class GanttChart {
311
314
  break;
312
315
  case "Day":
313
316
  default:
314
- this.timelineStart = DateUtils.addDays(minDate, -3);
315
- this.timelineEnd = DateUtils.addDays(maxDate, 3);
317
+ this.timelineStart = DateUtils.addDays(minDate, 3);
318
+ this.timelineEnd = DateUtils.addDays(maxDate, -5);
316
319
  break;
317
320
  }
318
321
  }
@@ -478,7 +481,7 @@ class GanttChart {
478
481
  if (this.scrollTop !== scrollTop) this.container.scrollTop = scrollTop;
479
482
  }
480
483
  updateVirtualRanges() {
481
- const buffer = 200;
484
+ const buffer = 100;
482
485
  this.visibleDateRange = {
483
486
  start: this.xToDate(this.scrollLeft - buffer),
484
487
  end: this.xToDate(this.scrollLeft + this.viewportWidth + buffer)
@@ -508,8 +511,14 @@ class GanttChart {
508
511
  this.taskPositions.clear();
509
512
  for (let i = 0; i < this.data.length; i++) {
510
513
  const row = this.data[i];
514
+ if (row.hide) {
515
+ continue;
516
+ }
511
517
  const y = i * this.config.rowHeight;
512
518
  row.tasks.forEach((task) => {
519
+ if (task.hide) {
520
+ return;
521
+ }
513
522
  const x_plan_start = this.dateToX(new Date(task.planStart));
514
523
  const x_plan_end = this.dateToX(DateUtils.addDays(task.planEnd, 1));
515
524
  let x_actual_start = null, x_actual_end = null;
@@ -530,12 +539,12 @@ class GanttChart {
530
539
  x_actual_start = this.dateToX(new Date(task.actualStart));
531
540
  isValidActualTask = true;
532
541
  }
533
- if (!isValidPlanTask && !isValidActualTask) {
534
- return;
535
- }
536
542
  if (task.actualEnd) {
537
543
  x_actual_end = this.dateToX(DateUtils.addDays(task.actualEnd, 1));
538
544
  }
545
+ if (!isValidPlanTask && !isValidActualTask) {
546
+ return;
547
+ }
539
548
  if (x_actual_start) {
540
549
  x_actual_width = (x_actual_end ? x_actual_end : this.dateToX(this.today)) - x_actual_start;
541
550
  offset_x_actual_start = Math.round(x_actual_start + x_actual_width * offsetX_actual);
package/dist/index.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * gantt-canvas-chart v1.4.0
2
+ * gantt-canvas-chart v1.5.0
3
3
  * (c) 2025-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/index.d.ts CHANGED
@@ -23,7 +23,7 @@ export declare function firstValidValue(...args: any[]): any;
23
23
  export declare class GanttChart {
24
24
  private rootContainer;
25
25
  container: HTMLElement;
26
- private data;
26
+ data: GanttData;
27
27
  private config;
28
28
  private headerCanvas;
29
29
  private mainCanvas;
@@ -160,13 +160,14 @@ export declare type LoadMoreDirection = 'left' | 'right' | 'bottom';
160
160
  export declare interface Row {
161
161
  id: string;
162
162
  name: string;
163
+ hide?: boolean;
163
164
  tasks: Task[];
164
165
  }
165
166
 
166
167
  export declare interface Task {
167
168
  id: string;
168
169
  name: string;
169
- type?: 'task' | 'leave';
170
+ type?: 'task' | 'leave' | 'overtime' | string;
170
171
  planStart?: string;
171
172
  planEnd?: string;
172
173
  actualStart?: string;
@@ -178,6 +179,7 @@ export declare interface Task {
178
179
  styleClass?: string;
179
180
  planBorderColor?: string;
180
181
  actualBgColor?: string;
182
+ hide?: boolean;
181
183
  _data?: any;
182
184
  planOffsetPercent?: [number, number];
183
185
  actualOffsetPercent?: [number, number];
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * gantt-canvas-chart v1.4.0
2
+ * gantt-canvas-chart v1.5.0
3
3
  * (c) 2025-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -203,8 +203,8 @@ class GanttChart {
203
203
  }
204
204
  init() {
205
205
  this.buildTaskMap();
206
- this.calculateFullTimeline();
207
206
  this.updatePixelsPerDay();
207
+ this.calculateFullTimeline();
208
208
  this.setupEvents();
209
209
  this.handleResize();
210
210
  }
@@ -276,6 +276,9 @@ class GanttChart {
276
276
  maxDate = DateUtils.addDays(/* @__PURE__ */ new Date(), 60);
277
277
  } else {
278
278
  this.taskMap.forEach(({ task }) => {
279
+ if (task.hide) {
280
+ return;
281
+ }
279
282
  const pStart = new Date(task.planStart);
280
283
  const pEnd = new Date(task.planEnd);
281
284
  if (pStart < minDate) minDate = pStart;
@@ -309,8 +312,8 @@ class GanttChart {
309
312
  break;
310
313
  case "Day":
311
314
  default:
312
- this.timelineStart = DateUtils.addDays(minDate, -3);
313
- this.timelineEnd = DateUtils.addDays(maxDate, 3);
315
+ this.timelineStart = DateUtils.addDays(minDate, 3);
316
+ this.timelineEnd = DateUtils.addDays(maxDate, -5);
314
317
  break;
315
318
  }
316
319
  }
@@ -476,7 +479,7 @@ class GanttChart {
476
479
  if (this.scrollTop !== scrollTop) this.container.scrollTop = scrollTop;
477
480
  }
478
481
  updateVirtualRanges() {
479
- const buffer = 200;
482
+ const buffer = 100;
480
483
  this.visibleDateRange = {
481
484
  start: this.xToDate(this.scrollLeft - buffer),
482
485
  end: this.xToDate(this.scrollLeft + this.viewportWidth + buffer)
@@ -506,8 +509,14 @@ class GanttChart {
506
509
  this.taskPositions.clear();
507
510
  for (let i = 0; i < this.data.length; i++) {
508
511
  const row = this.data[i];
512
+ if (row.hide) {
513
+ continue;
514
+ }
509
515
  const y = i * this.config.rowHeight;
510
516
  row.tasks.forEach((task) => {
517
+ if (task.hide) {
518
+ return;
519
+ }
511
520
  const x_plan_start = this.dateToX(new Date(task.planStart));
512
521
  const x_plan_end = this.dateToX(DateUtils.addDays(task.planEnd, 1));
513
522
  let x_actual_start = null, x_actual_end = null;
@@ -528,12 +537,12 @@ class GanttChart {
528
537
  x_actual_start = this.dateToX(new Date(task.actualStart));
529
538
  isValidActualTask = true;
530
539
  }
531
- if (!isValidPlanTask && !isValidActualTask) {
532
- return;
533
- }
534
540
  if (task.actualEnd) {
535
541
  x_actual_end = this.dateToX(DateUtils.addDays(task.actualEnd, 1));
536
542
  }
543
+ if (!isValidPlanTask && !isValidActualTask) {
544
+ return;
545
+ }
537
546
  if (x_actual_start) {
538
547
  x_actual_width = (x_actual_end ? x_actual_end : this.dateToX(this.today)) - x_actual_start;
539
548
  offset_x_actual_start = Math.round(x_actual_start + x_actual_width * offsetX_actual);
package/dist/index.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * gantt-canvas-chart v1.4.0
2
+ * gantt-canvas-chart v1.5.0
3
3
  * (c) 2025-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -207,8 +207,8 @@
207
207
  }
208
208
  init() {
209
209
  this.buildTaskMap();
210
- this.calculateFullTimeline();
211
210
  this.updatePixelsPerDay();
211
+ this.calculateFullTimeline();
212
212
  this.setupEvents();
213
213
  this.handleResize();
214
214
  }
@@ -280,6 +280,9 @@
280
280
  maxDate = DateUtils.addDays(/* @__PURE__ */ new Date(), 60);
281
281
  } else {
282
282
  this.taskMap.forEach(({ task }) => {
283
+ if (task.hide) {
284
+ return;
285
+ }
283
286
  const pStart = new Date(task.planStart);
284
287
  const pEnd = new Date(task.planEnd);
285
288
  if (pStart < minDate) minDate = pStart;
@@ -313,8 +316,8 @@
313
316
  break;
314
317
  case "Day":
315
318
  default:
316
- this.timelineStart = DateUtils.addDays(minDate, -3);
317
- this.timelineEnd = DateUtils.addDays(maxDate, 3);
319
+ this.timelineStart = DateUtils.addDays(minDate, 3);
320
+ this.timelineEnd = DateUtils.addDays(maxDate, -5);
318
321
  break;
319
322
  }
320
323
  }
@@ -480,7 +483,7 @@
480
483
  if (this.scrollTop !== scrollTop) this.container.scrollTop = scrollTop;
481
484
  }
482
485
  updateVirtualRanges() {
483
- const buffer = 200;
486
+ const buffer = 100;
484
487
  this.visibleDateRange = {
485
488
  start: this.xToDate(this.scrollLeft - buffer),
486
489
  end: this.xToDate(this.scrollLeft + this.viewportWidth + buffer)
@@ -510,8 +513,14 @@
510
513
  this.taskPositions.clear();
511
514
  for (let i = 0; i < this.data.length; i++) {
512
515
  const row = this.data[i];
516
+ if (row.hide) {
517
+ continue;
518
+ }
513
519
  const y = i * this.config.rowHeight;
514
520
  row.tasks.forEach((task) => {
521
+ if (task.hide) {
522
+ return;
523
+ }
515
524
  const x_plan_start = this.dateToX(new Date(task.planStart));
516
525
  const x_plan_end = this.dateToX(DateUtils.addDays(task.planEnd, 1));
517
526
  let x_actual_start = null, x_actual_end = null;
@@ -532,12 +541,12 @@
532
541
  x_actual_start = this.dateToX(new Date(task.actualStart));
533
542
  isValidActualTask = true;
534
543
  }
535
- if (!isValidPlanTask && !isValidActualTask) {
536
- return;
537
- }
538
544
  if (task.actualEnd) {
539
545
  x_actual_end = this.dateToX(DateUtils.addDays(task.actualEnd, 1));
540
546
  }
547
+ if (!isValidPlanTask && !isValidActualTask) {
548
+ return;
549
+ }
541
550
  if (x_actual_start) {
542
551
  x_actual_width = (x_actual_end ? x_actual_end : this.dateToX(this.today)) - x_actual_start;
543
552
  offset_x_actual_start = Math.round(x_actual_start + x_actual_width * offsetX_actual);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-canvas-chart",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "High performance Gantt chart component based on Canvas, can be applied to any framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",