Scale in 'Phase format' possible?

Hello,

At the moment i am discovering dhtmlxGantt and i am wondering if it is possible to create a custom scale.

I would like to use a Scale based on Phases that occur during the realisation of a project.
Think of Initiative Phase -> Definition Phase -> Tender Phase -> Realisation Phase etc.

So i don’t use a scale format in Date or Time, but in Generic Phases.
I will use this for visualizing a standard schedule.

Hoping someone could help me :slight_smile:

Thanks in advance,
Dennis

Hello,
the public API allows you to define custom time units, and you can set a template for labels in a scale configuration.
In order to define a custom unit you need to define two functions:

Date gantt.date.<unit>_start(Date value); Date gantt.date.add_<unit>(Date value, Integer increment);
The first one should return a start of a time unit for a any given date (e.g. month_start for 14 Feb -> 1st Feb).
The second one increments the date by a given number of duration units (e.g. 'date minus 2 days)
Don’t have a ready example, but you may check how year quarters can be defined:

[code]gantt.date.quarter_start = function(date){
gantt.date.month_start(date);
var m = date.getMonth(),
res_month;

if(m >= 9){
	res_month = 9;
}else if(m >= 6){
	res_month = 6;
}else if(m >= 3){
	res_month = 3;
}else{
	res_month = 0;
}

date.setMonth(res_month);
return date;

};
gantt.date.add_quarter = function(date, inc){
return gantt.date.add(date, inc*3, “month”);
};[/code]
then usage:

[code] function quarterLabel(date){
var month = date.getMonth();
var q_num;

	if(month >= 9){ 
		q_num = 4;
	}else if(month >= 6){
		q_num = 3;
	}else if(month >= 3){
		q_num = 2;
	}else{
		q_num = 1;
	}

	return "Q" + q_num;
}

gantt.config.subscales = [
	{unit:"quarter", step:1, template:quarterLabel},
	{unit:"month", step:1, date:"%M" }
];[/code]

In case of Phases you probably need to define function that will operate several fixed dates

Thanks, i am going to give it try :stuck_out_tongue: