diff --git a/src/bar.js b/src/bar.js index dd79357..037be55 100644 --- a/src/bar.js +++ b/src/bar.js @@ -587,9 +587,9 @@ 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++; } diff --git a/src/defaults.js b/src/defaults.js index 4262358..e357bd9 100644 --- a/src/defaults.js +++ b/src/defaults.js @@ -118,8 +118,17 @@ const DEFAULT_OPTIONS = { today_button: true, view_mode_select: false, default_snap: '1d', - holiday_highlight: { green: 'weekend' }, - ignore: ['weekend'], + holiday_highlight: { + green: [ + '2024-03-01', + '2024-03-02', + '2024-03-03', + '2024-03-04', + '2024-03-05', + '2024-03-06', + ], + }, + ignore: [], }; export { DEFAULT_OPTIONS, DEFAULT_VIEW_MODES }; diff --git a/src/index.js b/src/index.js index b956d15..d7247cf 100644 --- a/src/index.js +++ b/src/index.js @@ -559,7 +559,6 @@ export default class Gantt { let check_highlight = this.options.holiday_highlight[color]; if (check_highlight === 'weekend') check_highlight = (d) => d.getDay() === 0 || d.getDay() === 6; - let extra_func; if (typeof check_highlight === 'object') { @@ -600,13 +599,17 @@ export default class Gantt { const height = (this.options.bar_height + this.options.padding) * this.tasks.length; - createSVG('rect', { - x, + x: Math.round(x), y: this.options.header_height + this.options.padding / 2, - width: this.config.column_width, + width: + this.config.column_width / + date_utils.convert_scales( + this.config.view_mode.step, + 'day', + ), height, style: `fill: ${color};`, append_to: this.layers.grid, @@ -664,6 +667,7 @@ export default class Gantt { M3,5 l2,-2" style="stroke:black; stroke-width:0.5" /> `; + for ( let d = new Date(this.gantt_start); d <= this.gantt_end; @@ -673,10 +677,11 @@ export default class Gantt { !this.config.ignored_dates.find( (k) => k.getDate() == d.getDate(), ) && - this.config.ignored_function && - !this.config.ignored_function(d) + (!this.config.ignored_function || + !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',