diff --git a/src/bar.js b/src/bar.js index 9cbce04..0761f5a 100644 --- a/src/bar.js +++ b/src/bar.js @@ -504,10 +504,14 @@ export default class Bar { and then add the days in the month, making sure the number does not exceed 29 so it is within the column */ if (this.gantt.view_is('Month')) { - const diffDaysBasedOn30DayMonths = date_utils.diff(task_start, gantt_start, 'month') * 30; - const dayInMonth = Math.min(29, date_utils.format(task_start, "DD")); + const diffDaysBasedOn30DayMonths = + date_utils.diff(task_start, gantt_start, 'month') * 30; + const dayInMonth = Math.min( + 29, + date_utils.format(task_start, 'DD'), + ); const diff = diffDaysBasedOn30DayMonths + dayInMonth; - + x = (diff * column_width) / 30; } this.x = x; diff --git a/src/date_utils.js b/src/date_utils.js index 77bebd0..11b2752 100644 --- a/src/date_utils.js +++ b/src/date_utils.js @@ -136,7 +136,7 @@ export default { diff(date_a, date_b, scale = DAY) { let milliseconds, seconds, hours, minutes, days, months, years; - + milliseconds = date_a - date_b; seconds = milliseconds / 1000; minutes = seconds / 60; @@ -145,17 +145,17 @@ export default { // Calculate months across years const yearDiff = date_a.getFullYear() - date_b.getFullYear(); const monthDiff = date_a.getMonth() - date_b.getMonth(); - + /* If monthDiff is negative, date_b is in an earlier month than date_a and thus subtracted from the year difference in months */ months = yearDiff * 12 + monthDiff; - + /* If date_a's (e.g. march 1st) day of the month is smaller than date_b (e.g. february 28th), adjust the month difference */ if (date_a.getDate() < date_b.getDate()) { months--; } - + // Calculate years based on actual months years = months / 12; diff --git a/src/index.js b/src/index.js index 9fc52ee..c38cd93 100644 --- a/src/index.js +++ b/src/index.js @@ -680,7 +680,7 @@ export default class Gantt { } } - return { x } + return { x }; } make_grid_highlights() { @@ -697,7 +697,8 @@ export default class Gantt { const { x: left, date } = this.computeGridHighlightDimensions( this.options.view_mode, ); - if (!date || !this.dates.find((d) => d.getTime() == date.getTime())) return; + if (!date || !this.dates.find((d) => d.getTime() == date.getTime())) + return; const top = this.options.header_height + this.options.padding / 2; const height = (this.options.bar_height + this.options.padding) * @@ -1297,7 +1298,7 @@ export default class Gantt { trigger_event(event, args) { if (this.options['on_' + event]) { - this.options['on_' + event].apply(this, args) + this.options['on_' + event].apply(this, args); } }