gantt-canvas-chart 1.1.1 → 1.2.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.1.1
2
+ * gantt-canvas-chart v1.2.0
3
3
  * (c) 2025-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -96,7 +96,7 @@ class GanttChart {
96
96
  timelineStart;
97
97
  timelineEnd;
98
98
  minDate;
99
- // private maxDate: Date | null;
99
+ maxDate;
100
100
  pixelsPerDay;
101
101
  scrollLeft;
102
102
  scrollTop;
@@ -166,6 +166,7 @@ class GanttChart {
166
166
  this.timelineStart = /* @__PURE__ */ new Date();
167
167
  this.timelineEnd = /* @__PURE__ */ new Date();
168
168
  this.minDate = null;
169
+ this.maxDate = null;
169
170
  this.pixelsPerDay = 40;
170
171
  this.scrollLeft = 0;
171
172
  this.scrollTop = 0;
@@ -243,11 +244,12 @@ class GanttChart {
243
244
  this.container.remove();
244
245
  }
245
246
  calculateFullTimeline() {
247
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
246
248
  let minDate = new Date(9999, 0, 1);
247
249
  let maxDate = new Date(1e3, 0, 1);
248
250
  if (this.data.length === 0) {
249
251
  minDate = /* @__PURE__ */ new Date();
250
- maxDate = DateUtils.addDays(/* @__PURE__ */ new Date(), 30);
252
+ maxDate = DateUtils.addDays(/* @__PURE__ */ new Date(), 60);
251
253
  } else {
252
254
  this.taskMap.forEach(({ task }) => {
253
255
  const pStart = new Date(task.planStart);
@@ -263,8 +265,11 @@ class GanttChart {
263
265
  });
264
266
  }
265
267
  this.minDate = minDate;
266
- minDate = DateUtils.addDays(minDate, -7);
267
- maxDate = DateUtils.addDays(maxDate, 14);
268
+ this.maxDate = maxDate;
269
+ const minYear = minDate.getFullYear();
270
+ const maxYear = maxDate.getFullYear();
271
+ minDate = DateUtils.addDays(minYear === 9999 ? new Date(currentYear, 0, 1) : minDate, -7);
272
+ maxDate = DateUtils.addDays(maxYear === 1e3 ? new Date(currentYear + 1, 0, 1) : maxDate, 14);
268
273
  switch (this.config.viewMode) {
269
274
  case "Year":
270
275
  this.timelineStart = DateUtils.getStartOfYear(minDate);
@@ -683,7 +688,7 @@ class GanttChart {
683
688
  const x = this.dateToX(this.today);
684
689
  if (x >= this.scrollLeft && x <= this.scrollLeft + this.viewportWidth) {
685
690
  ctx.strokeStyle = this.config.todayColor;
686
- ctx.lineWidth = 2;
691
+ ctx.lineWidth = 1;
687
692
  ctx.beginPath();
688
693
  ctx.moveTo(x, this.scrollTop);
689
694
  ctx.lineTo(x, this.scrollTop + this.viewportHeight);
package/dist/index.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * gantt-canvas-chart v1.1.1
2
+ * gantt-canvas-chart v1.2.0
3
3
  * (c) 2025-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/dist/index.d.ts CHANGED
@@ -22,7 +22,7 @@ export declare function firstValidValue(...args: any[]): any;
22
22
 
23
23
  export declare class GanttChart {
24
24
  private rootContainer;
25
- private container;
25
+ container: HTMLElement;
26
26
  private data;
27
27
  private config;
28
28
  private headerCanvas;
@@ -33,7 +33,8 @@ export declare class GanttChart {
33
33
  private mainCtx;
34
34
  private timelineStart;
35
35
  private timelineEnd;
36
- private minDate;
36
+ minDate: Date | null;
37
+ maxDate: Date | null;
37
38
  private pixelsPerDay;
38
39
  private scrollLeft;
39
40
  private scrollTop;
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * gantt-canvas-chart v1.1.1
2
+ * gantt-canvas-chart v1.2.0
3
3
  * (c) 2025-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -94,7 +94,7 @@ class GanttChart {
94
94
  timelineStart;
95
95
  timelineEnd;
96
96
  minDate;
97
- // private maxDate: Date | null;
97
+ maxDate;
98
98
  pixelsPerDay;
99
99
  scrollLeft;
100
100
  scrollTop;
@@ -164,6 +164,7 @@ class GanttChart {
164
164
  this.timelineStart = /* @__PURE__ */ new Date();
165
165
  this.timelineEnd = /* @__PURE__ */ new Date();
166
166
  this.minDate = null;
167
+ this.maxDate = null;
167
168
  this.pixelsPerDay = 40;
168
169
  this.scrollLeft = 0;
169
170
  this.scrollTop = 0;
@@ -241,11 +242,12 @@ class GanttChart {
241
242
  this.container.remove();
242
243
  }
243
244
  calculateFullTimeline() {
245
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
244
246
  let minDate = new Date(9999, 0, 1);
245
247
  let maxDate = new Date(1e3, 0, 1);
246
248
  if (this.data.length === 0) {
247
249
  minDate = /* @__PURE__ */ new Date();
248
- maxDate = DateUtils.addDays(/* @__PURE__ */ new Date(), 30);
250
+ maxDate = DateUtils.addDays(/* @__PURE__ */ new Date(), 60);
249
251
  } else {
250
252
  this.taskMap.forEach(({ task }) => {
251
253
  const pStart = new Date(task.planStart);
@@ -261,8 +263,11 @@ class GanttChart {
261
263
  });
262
264
  }
263
265
  this.minDate = minDate;
264
- minDate = DateUtils.addDays(minDate, -7);
265
- maxDate = DateUtils.addDays(maxDate, 14);
266
+ this.maxDate = maxDate;
267
+ const minYear = minDate.getFullYear();
268
+ const maxYear = maxDate.getFullYear();
269
+ minDate = DateUtils.addDays(minYear === 9999 ? new Date(currentYear, 0, 1) : minDate, -7);
270
+ maxDate = DateUtils.addDays(maxYear === 1e3 ? new Date(currentYear + 1, 0, 1) : maxDate, 14);
266
271
  switch (this.config.viewMode) {
267
272
  case "Year":
268
273
  this.timelineStart = DateUtils.getStartOfYear(minDate);
@@ -681,7 +686,7 @@ class GanttChart {
681
686
  const x = this.dateToX(this.today);
682
687
  if (x >= this.scrollLeft && x <= this.scrollLeft + this.viewportWidth) {
683
688
  ctx.strokeStyle = this.config.todayColor;
684
- ctx.lineWidth = 2;
689
+ ctx.lineWidth = 1;
685
690
  ctx.beginPath();
686
691
  ctx.moveTo(x, this.scrollTop);
687
692
  ctx.lineTo(x, this.scrollTop + this.viewportHeight);
package/dist/index.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * gantt-canvas-chart v1.1.1
2
+ * gantt-canvas-chart v1.2.0
3
3
  * (c) 2025-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -98,7 +98,7 @@
98
98
  timelineStart;
99
99
  timelineEnd;
100
100
  minDate;
101
- // private maxDate: Date | null;
101
+ maxDate;
102
102
  pixelsPerDay;
103
103
  scrollLeft;
104
104
  scrollTop;
@@ -168,6 +168,7 @@
168
168
  this.timelineStart = /* @__PURE__ */ new Date();
169
169
  this.timelineEnd = /* @__PURE__ */ new Date();
170
170
  this.minDate = null;
171
+ this.maxDate = null;
171
172
  this.pixelsPerDay = 40;
172
173
  this.scrollLeft = 0;
173
174
  this.scrollTop = 0;
@@ -245,11 +246,12 @@
245
246
  this.container.remove();
246
247
  }
247
248
  calculateFullTimeline() {
249
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
248
250
  let minDate = new Date(9999, 0, 1);
249
251
  let maxDate = new Date(1e3, 0, 1);
250
252
  if (this.data.length === 0) {
251
253
  minDate = /* @__PURE__ */ new Date();
252
- maxDate = DateUtils.addDays(/* @__PURE__ */ new Date(), 30);
254
+ maxDate = DateUtils.addDays(/* @__PURE__ */ new Date(), 60);
253
255
  } else {
254
256
  this.taskMap.forEach(({ task }) => {
255
257
  const pStart = new Date(task.planStart);
@@ -265,8 +267,11 @@
265
267
  });
266
268
  }
267
269
  this.minDate = minDate;
268
- minDate = DateUtils.addDays(minDate, -7);
269
- maxDate = DateUtils.addDays(maxDate, 14);
270
+ this.maxDate = maxDate;
271
+ const minYear = minDate.getFullYear();
272
+ const maxYear = maxDate.getFullYear();
273
+ minDate = DateUtils.addDays(minYear === 9999 ? new Date(currentYear, 0, 1) : minDate, -7);
274
+ maxDate = DateUtils.addDays(maxYear === 1e3 ? new Date(currentYear + 1, 0, 1) : maxDate, 14);
270
275
  switch (this.config.viewMode) {
271
276
  case "Year":
272
277
  this.timelineStart = DateUtils.getStartOfYear(minDate);
@@ -685,7 +690,7 @@
685
690
  const x = this.dateToX(this.today);
686
691
  if (x >= this.scrollLeft && x <= this.scrollLeft + this.viewportWidth) {
687
692
  ctx.strokeStyle = this.config.todayColor;
688
- ctx.lineWidth = 2;
693
+ ctx.lineWidth = 1;
689
694
  ctx.beginPath();
690
695
  ctx.moveTo(x, this.scrollTop);
691
696
  ctx.lineTo(x, this.scrollTop + this.viewportHeight);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-canvas-chart",
3
- "version": "1.1.1",
3
+ "version": "1.2.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",