Our state of the art Gantt chart


Post by attila.posta »

Hi,

I can't find the proper way to change dependency lag duration unit, it always displayed in 'days'.
Can you tell me how to set it to 'hours'?
Gantt 2.1.9.

regards,
Norbi


Post by saki »

The unit for lag comes from the dependency data. You can change it there; for example:

  "dependencies" : {
    "rows" : [
      {
        "id"       : 1,
        "fromTask" : 11,
        "toTask"   : 15,
        "lag"      : 2,
        "lagUnit"  : "h"
      },

For more information on Gantt data consult please https://bryntum.com/docs/gantt/#guides/project_data.md


Post by attila.posta »

Thank you for your response. It works for pre-existing dependencies, but anytime I create a new one, it will be 'days' by default, until I change it. I think I was not clear, but I want to change the default setting for it, so no additional user action required.


Post by saki »

You can change the default by extending the DependencyModel class as described here https://bryntum.com/docs/gantt/#Gantt/model/DependencyModel in section Subclassing the Dependency class.

If you would apply it to Gantt basic demo, the beginning of app.js file could look like this:

import DependencyModel from '../../lib/Gantt/model/DependencyModel.js';

class MyDependencyModel extends DependencyModel {
    static get fields() {
        return [{
            name         : 'lagUnit',
            type         : 'string',
            defaultValue : 'h'
        }];
    }
}

const project = new ProjectModel({
    dependencyModelClass : MyDependencyModel,

    transport : {
        load : {
            url : '../_datasets/launch-saas.json'
        }
    }
});

new Gantt({
    // ...

Post Reply