Skip to content

Commit

Permalink
upper text issues
Browse files Browse the repository at this point in the history
  • Loading branch information
safwansamsudeen committed Dec 2, 2024
1 parent e20c7e0 commit 268d82a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
13 changes: 4 additions & 9 deletions src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,25 @@ const DEFAULT_VIEW_MODES = [
},
{
name: 'Month',
padding: '1m',
padding: '2m',
step: '1m',
column_width: 120,
format_string: 'YYYY-MM',
lower_text: 'MMMM',
upper_text: (d, ld, lang) =>
d.getMonth() !== ld.getMonth()
!ld || d.getFullYear() !== ld.getFullYear()
? date_utils.format(d, 'YYYY', lang)
: '',
thick_line: (d) => d.getMonth() % 3 === 0,
default_snap: '7d',
},
{
name: 'Year',
padding: '1m',
padding: '2y',
step: '1y',
column_width: 120,
format_string: 'YYYY',
lower_text: 'YYYY',
upper_text: (d, ld, lang) =>
d.getMonth() !== ld.getMonth()
? date_utils.format(d, 'YYYY', lang)
: '',
upper_text_frequency: 30,
upper_text: 'YYYY',
default_snap: '30d',
},
];
Expand Down
17 changes: 7 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ export default class Gantt {
* @returns Object containing the x-axis distance and date of the current date, or null if the current date is out of the gantt range.
*/
computeGridHighlightDimensions(view_mode) {

const today = new Date();
if (today < this.gantt_start || today > this.gantt_end) return null;
let diff_in_units = date_utils.diff(
Expand Down Expand Up @@ -611,7 +610,6 @@ export default class Gantt {
if ($today) {
$today.classList.add('current-date-highlight');
$today.style.top = +$today.style.top.slice(0, -2) - 4 + 'px';

}
}

Expand Down Expand Up @@ -660,26 +658,25 @@ export default class Gantt {
}

get_dates_to_draw() {
let last_date = null;
let last_date_info = null;
const dates = this.dates.map((date, i) => {
const d = this.get_date_info(date, last_date, i);
last_date = d;
console.log('starting', date, last_date_info);
const d = this.get_date_info(date, last_date_info, i);
last_date_info = d;
return d;
});
return dates;
}

get_date_info(date, last_date_info) {
let last_date = last_date_info
? last_date_info.date
: date_utils.add(date, 1, 'day');
let last_date = last_date_info ? last_date_info.date : null;

let column_width = this.config.column_width;

const base_pos = {
x: last_date_info
? last_date_info.base_pos_x + last_date_info.column_width
: 0,
: 20,
lower_y: this.options.header_height - 20,
upper_y: this.options.header_height - 50,
};
Expand Down Expand Up @@ -710,7 +707,7 @@ export default class Gantt {
1) /
2,
upper_y: base_pos.upper_y,
lower_x: base_pos.x + column_width / 2,
lower_x: base_pos.x + column_width / 2 - 20,
lower_y: base_pos.lower_y,
};
}
Expand Down

0 comments on commit 268d82a

Please sign in to comment.