Hello,
in the nearest weeks we plan to release update of the Gantt chart, you may check the beta.
Main changes are
- Enhanced customization of time scales
- Working time support
- Milestone support and custom task types
1)Customizable time scales.
Certain time units can be skipped from the time scale. Practically this means that now you can display days only in working hours (e.g. 9-17 instead of 0-23), or skip weekends from the scale.
Skipped columns can be defined with gantt.ignore_scale function. It is called for each column of the scale (if multiple scales defined - for each column of the lowest scale), column date is passed as a first argument. Returning boolean true will skip column.
By default, the duration of skipped columns is still counted.gantt.ignore_time = function(date){
if(date.getDay() == 0 || date.getDay() == 6)
return true;
return false;
};
Related examples can be found at /samples/03_scales and /samples/09_worktime
2) Ability to set the duration of tasks in work days or work hours, instead of calendar days.
This functionality can be used with time scale configuration from the previous paragraph.
By default checking of a work time is disabled.
Enable:
gantt.config.work_time = true;
Predefined settings - work hours - 8-17, work days - Monday-Friday
Can be configured with gantt.setWorkTime function. The method takes settings object with following properties
- day: Number of day of week(0-6),
- hours: array of working hours as ‘from’-‘to’ pairs, can define several intervals - [9, 17], or [9,12, 13, 17]; ‘false’ - define not working day, ‘true’(default value) - make working day using global hours
- date : Date object
}[code]//global working hours
gantt.setWorkTime({hours : [8,17]});
// make Tuesdays day-off
gantt.setWorkTime({day : 2, hours : false});
//Fridays and Saturdays are short days
gantt.setWorkTime({day : 5, hours : [8,12]});
gantt.setWorkTime({day : 6, hours : [8,12]});
// Make specific date a work day
gantt.setWorkTime({date : new Date(2013, 2, 31)});[/code]
Programmatically check if certain time is working time:
gantt.isWorkTime(date)
//OR
gantt.isWorkTime(date, timeUnit);
If second argument is not specified, gantt.config.duration_unit is used instead
Sample of usage:[code]gantt.templates.task_cell_class = function(task, date){
var css = [];
if(!gantt.isWorkTime(date, 'day')){
css.push("week_end");
}else if(!gantt.isWorkTime(date, 'hour')){
css.push("no_work_hour");
}
return css.join(" ");
};[/code]
Related examples: /samples/09_worktime
3) Milestone support and custom task types
Described here viewtopic.php?f=15&t=20507&start=10
If you encountered any bugs or incompatibilities with dthmlxGantt 2.0, please post in this topic
dhtmlxGantt_v2.1.0_gpl.zip (599 KB)