more simplification

This commit is contained in:
safwansamsudeen 2024-12-02 13:07:05 +05:30
parent fc71da6550
commit 7ac5422950
2 changed files with 14 additions and 20 deletions

View File

@ -10,6 +10,7 @@ const DEFAULT_VIEW_MODES = [
d.getDate() !== ld.getDate() d.getDate() !== ld.getDate()
? date_utils.format(d, 'D MMMM', lang) ? date_utils.format(d, 'D MMMM', lang)
: '', : '',
upper_text_frequency: 24,
}, },
{ {
name: 'Quarter Day', name: 'Quarter Day',
@ -21,6 +22,7 @@ const DEFAULT_VIEW_MODES = [
d.getDate() !== ld.getDate() d.getDate() !== ld.getDate()
? date_utils.format(d, 'D MMM', lang) ? date_utils.format(d, 'D MMM', lang)
: '', : '',
upper_text_frequency: 4,
}, },
{ {
name: 'Half Day', name: 'Half Day',
@ -34,6 +36,7 @@ const DEFAULT_VIEW_MODES = [
? date_utils.format(d, 'D MMM', lang) ? date_utils.format(d, 'D MMM', lang)
: date_utils.format(d, 'D', lang) : date_utils.format(d, 'D', lang)
: '', : '',
upper_text_frequency: 2,
}, },
{ {
name: 'Day', name: 'Day',
@ -62,6 +65,7 @@ const DEFAULT_VIEW_MODES = [
? date_utils.format(d, 'MMMM', lang) ? date_utils.format(d, 'MMMM', lang)
: '', : '',
thick_line: (d) => d.getDate() >= 1 && d.getDate() <= 7, thick_line: (d) => d.getDate() >= 1 && d.getDate() <= 7,
upper_text_frequency: 4,
}, },
{ {
name: 'Month', name: 'Month',
@ -87,6 +91,7 @@ const DEFAULT_VIEW_MODES = [
d.getMonth() !== ld.getMonth() d.getMonth() !== ld.getMonth()
? date_utils.format(d, 'YYYY', lang) ? date_utils.format(d, 'YYYY', lang)
: '', : '',
upper_text_frequency: 30,
}, },
]; ];

View File

@ -669,24 +669,9 @@ export default class Gantt {
lower_y: this.options.header_height - 20, lower_y: this.options.header_height - 20,
upper_y: this.options.header_height - 50, upper_y: this.options.header_height - 50,
}; };
const x_pos = {
Hour_lower: column_width / 2, const upper_text = this.config.view_mode.upper_text;
Hour_upper: column_width * 12, const lower_text = this.config.view_mode.lower_text;
'Quarter Day_lower': column_width / 2,
'Quarter Day_upper': column_width * 2,
'Half Day_lower': column_width / 2,
'Half Day_upper': column_width,
Day_lower: column_width / 2,
Day_upper: column_width / 2,
Week_lower: column_width / 2,
Week_upper: (column_width * 4) / 2,
Month_lower: column_width / 2,
Month_upper: column_width / 2,
Year_lower: column_width / 2,
Year_upper: (column_width * 30) / 2,
};
let upper_text = this.config.view_mode.upper_text;
let lower_text = this.config.view_mode.lower_text;
return { return {
date, date,
@ -703,9 +688,13 @@ export default class Gantt {
typeof lower_text === 'string' typeof lower_text === 'string'
? date_utils.format(date, lower_text, this.options.language) ? date_utils.format(date, lower_text, this.options.language)
: lower_text(date, last_date, this.options.language), : lower_text(date, last_date, this.options.language),
upper_x: base_pos.x + x_pos[`${this.config.view_mode.name}_upper`], upper_x:
base_pos.x +
(column_width * this.config.view_mode.upper_text_frequency ||
1) /
2,
upper_y: base_pos.upper_y, upper_y: base_pos.upper_y,
lower_x: base_pos.x + x_pos[`${this.config.view_mode.name}_lower`], lower_x: base_pos.x + column_width / 2,
lower_y: base_pos.lower_y, lower_y: base_pos.lower_y,
}; };
} }