From af1c94b56a4975068b42f26c9532f1121ee0958c Mon Sep 17 00:00:00 2001 From: safwansamsudeen Date: Thu, 5 Dec 2024 13:16:50 +0530 Subject: [PATCH] perfect progress in ignore --- src/bar.js | 32 ++++++++++++++++++++------------ src/defaults.js | 9 +-------- src/index.js | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/bar.js b/src/bar.js index 037be55..f940912 100644 --- a/src/bar.js +++ b/src/bar.js @@ -402,6 +402,7 @@ export default class Bar { if (this.gantt.options.show_expected_progress) { this.update_expected_progressbar_position(); } + this.update_progressbar_position(); this.update_arrow_position(); } @@ -587,13 +588,14 @@ export default class Bar { if ( !this.gantt.config.ignored_dates.find( (k) => k.getTime() === d.getTime(), - ) || - (this.gantt.config.ignored_function && - !this.gantt.config.ignored_function(d)) + ) && + this.gantt.config.ignored_function && + !this.gantt.config.ignored_function(d) ) { actual_duration_in_days++; } } + console.log(this.actual_duration_in_days); this.actual_duration_in_days = actual_duration_in_days; this.duration = @@ -644,18 +646,24 @@ export default class Bar { update_progressbar_position() { if (this.invalid || this.gantt.options.readonly) return; this.$bar_progress.setAttribute('x', this.$bar.getX()); - let new_width = - this.actual_duration * - this.gantt.config.column_width * - (this.task.progress / 100); - const progress_area = this.x + this.progress_width; - new_width += + + const ignored_end = this.x + this.$bar.getWidth(); + const progress_end = this.x + this.progress_width; + const total_ignored_area = this.gantt.config.ignored_positions.reduce((acc, val) => { - return acc + (val >= this.x && val <= progress_area); + return acc + (val >= this.x && val < ignored_end); + }, 0) * this.gantt.config.column_width; + const progress_ignored_area = + this.gantt.config.ignored_positions.reduce((acc, val) => { + return acc + (val >= this.x && val < progress_end); }, 0) * this.gantt.config.column_width; - this.progress_width = new_width; - this.$bar_progress.setAttribute('width', new_width); + let new_width = + (this.duration * this.gantt.config.column_width - + total_ignored_area) * + (this.task.progress / 100); + this.progress_width = progress_ignored_area + new_width; + this.$bar_progress.setAttribute('width', this.progress_width); } update_label_position() { diff --git a/src/defaults.js b/src/defaults.js index e357bd9..3be270a 100644 --- a/src/defaults.js +++ b/src/defaults.js @@ -119,14 +119,7 @@ const DEFAULT_OPTIONS = { view_mode_select: false, default_snap: '1d', holiday_highlight: { - green: [ - '2024-03-01', - '2024-03-02', - '2024-03-03', - '2024-03-04', - '2024-03-05', - '2024-03-06', - ], + green: 'weekend', }, ignore: [], }; diff --git a/src/index.js b/src/index.js index 5d51bd8..23fa081 100644 --- a/src/index.js +++ b/src/index.js @@ -683,7 +683,7 @@ export default class Gantt { !this.config.ignored_function(d)) ) continue; - console.log(this.config.ignored_function); + let diff = date_utils.convert_scales( date_utils.diff(d, this.gantt_start) + 'd',