Hello Jochen,
Timeline and scales start from a date. In the sample, there is the month scale with the step parameter. With that combination, Gantt covers 3 months instead of one. And there is a template that shows the first and third months.
You can use the month scale without the step parameter and calculate the quarter number. Here is an example of how it might be implemented: http://snippet.dhtmlx.com/f5307157c
If you need the quarter scale to cover 3 months, you need to create a custom scale unit. Here is an example of how it might be implemented: http://snippet.dhtmlx.com/500601ea1
And here is an explanation of how it works.
We don’t modify the initial date, so we return it as it is:
All calculations are made in the gantt.date.add_year_quarter function.
The year quarter scale means that all cells should be equal (3 months). But most likely, the first and last scale cells will differ from others. It happens because they start on a date that is different from the quarter start date.
So, we calculate the quarter dates, check which quarter the cell belongs to and return the quarter date.
Hi, I tested the second snippet and it works great. I want to show years and quarters only, not months, but if I remove the month line (check it in the snippet), the gantt only shows the last two quarters, but miss the first two ones. Is there any way of fix it? Thanks!
which is fairly simple, you just need to define two method:
gantt.date.semester_start = function(date){
// define start dates for each semester
if(date.getMonth() < 6){
//the first semester - 1st of January
return new Date(date.getFullYear(), 0, 1);
}else{
//the second semester - 1st of July
return new Date(date.getFullYear(), 6, 1);
}
};
gantt.date.add_semester = function(date, inc){
var start = gantt.date.semester_start(new Date(date));
return gantt.date.add(start, 6*inc, "month");
};
Then you’ll be able to use the semester unit in code: