Hi,
I am using the scaling with a switch/case to be able changing the “zoom”. Until now it kinda worked well but since you’ve deprecated subscales i now have to use the gantt.config.scales but it does not work as expected.
The parameters i’m adding are not working and the gantt does not render with the updated scales. I would like to know if there is any thing like a config to make it work.
I figured out it looks like the property scales does not work in angular, i saw a post about it from december 2019.
Do you know if it has been fixed or else ?
As i said in my comment on this page https://docs.dhtmlx.com/gantt/desktop__configuring_time_scale.html
I even tried copy paste the code from the scaling guide page and it does not work at all. Below, the code i’m using to do my scaling :
public setScaleConfig(level: string) {
let year = new Date().getFullYear();
this.translate.get('date').subscribe((locale: any) => {
const weekScaleTemplate = (date: any) => {
const dateToStr = gantt.date.date_to_str(locale.format.ganttShortScaleDate);
const endDate = gantt.date.add(gantt.date.add(date, 1, 'week'), -1, 'day');
return dateToStr(date) + ' - ' + dateToStr(endDate);
};
const quarterTemplate = (date: any) => {
const quarterStr = locale.format.ganttShortQuarter +
(Math.floor((date.getMonth() / 3)) + 1) + ' ' + date.getFullYear();
return quarterStr;
};
switch (level) {
case 'day':
this.zoomString = 'day';
gantt.config.scales = [ {unit: 'day', step: 1, date: locale.format.ganttShortScaleDate}];
gantt.config.scale_height = 27;
gantt.config.start_date = this.ganttActualStartDate;
gantt.config.end_date = this.ganttActualEndDate;
break;
case 'week':
this.zoomString = 'week';
gantt.config.scales = [ { unit: 'week', step: 7, format: weekScaleTemplate}];
gantt.config.scale_height = 50;
gantt.config.subscales = [
{unit: 'day', step: 1, date: '%D'}
];
gantt.config.start_date = this.ganttActualStartDate;
gantt.config.end_date = this.ganttActualEndDate;
break;
case 'month':
this.zoomString = 'month';
gantt.config.scales = [{ unit: 'month', step: 1, format: '%F %Y'}];
gantt.config.scale_height = 50;
gantt.config.subscales = [{ unit: 'month', step: 1, format: '%F %Y'},
{unit: 'week', step: 1, format: weekScaleTemplate}
];
gantt.config.start_date = this.ganttActualStartDate;
gantt.config.end_date = this.ganttActualEndDate;
break;
case 'quarter':
this.zoomString = 'quarter';
gantt.config.scales = [ { unit: 'quarter', step: 1, format: quarterTemplate} ];
gantt.config.subscales = [
{unit: 'month', step: 1, date: '%F, %Y'}
];
gantt.config.scale_height = 50;
this.quarterZoom(this.quarterZoomString);
break;
case 'year':
this.zoomString = 'year';
gantt.config.scales = [ { unit: 'year', step: 1, format: '%Y'} ];
gantt.config.min_column_width = 50;
gantt.config.scale_height = 90;
gantt.config.subscales = [
{unit: 'month', step: 1, date: '%M'},
];
gantt.config.start_date = moment('01-01' + this.ganttActualStartDate.getFullYear(), 'DD-MM-YYYY')
.toDate();
gantt.config.end_date = moment('31-12' + this.ganttActualEndDate.getFullYear(), 'DD-MM-YYYY')
.toDate();
break;
}
});
}
(this code is not working properly in my gantt, i tried removing the subscales and put the code in the scales but it changed nothing). my gantt version is 7.0.2
I don’t see anything that could be the reason why it does not work before using gantt.config.scale i used the gantt.config.scale_unit and all and the gantt.config.subscales which were working pretty nicely.
So if you have any idea to help me please !
Thanks !