Our state of the art Gantt chart


Post by greg »

Hi,

Is there a way I can get a project % done/complete value from the gantt or project model?

What I mean is lets say there is a project with two tasks first have percentageDone=50 and second have 0, then the project level % done value should be 25.

Is there also a way to be notify whenever this value change?

I know I can calculate it myself, but in case we have many tasks it would be more efficient to read the value from the property rather than manually calculate it every time the data changes.

Thanks.


Post by arcady »

Unlike TaskModel class that has HasPercentDoneMixin mixin applied ProjectModel class does not have it onboard. So it doesn't have that field. Yet you can subclass ProjectModel and add that mixin:

// extend standard ProjectModel w/ HasPercentDoneMixin mixin
class MyProject extends HasPercentDoneMixin.derive(ProjectModel) {}

const gantt = new Gantt({
    // tell the Gantt it should use MyProject class to instantiate project model
    projectModelClass : MyProject,

    project : {
        ...

After that the project will have percentDone field that will calculate its value based on contained tasks.

Is there also a way to be notify whenever this value change?

Yes you can use the Engine API for this:

project.getGraph().observe(
    function * () {
        // yield identifiers we react on changes of
        return yield project.$.percentDone;
    },
    (percentDone) => {
        // some code to run on percentDone change
        console.log(`Percent done is: ${percentDone}%`)
    }
);

Post by greg »

Hi Arcady,

Thanks for rapid answer.
Could you advise how can I get reference to HasPercentDoneMixin.
I installed scheduler pro and react wrapper, but it's not there.
Could you let me know which package I need to install to get access to this?

Thanks.


Post by arcady »

HasPercentDoneMixin class is shipped in the same bundle you export Gantt class from.
The only thing if you write your app in TypeScript then the class could be not represented in the shipped TS interface files. But the class should be in the bundle.


Post by greg »

I have tried to import it from different places, but with no luck:

import { HasPercentDoneMixin } from "@bryntum/gantt/gantt.umd.js";

has no exported member 'HasPercentDoneMixin'

import { HasPercentDoneMixin } from "@bryntum/gantt/gantt.module";

Simultaneous imports from ".module.js" and ".umd.js" bundles are not allowed.

I have quite a few imports using umd and I'd rather not to change this.

import { HasPercentDoneMixin } from "@bryntum/gantt/source/lib/Engine/quark/model/scheduler_pro/HasPercentDoneMixin";

Base class mismatch

Could you give me a further advise what I'm doing wrong, please?


Post by arcady »

Ok it seems we do not export the class. I've made a ticket for the problem: https://github.com/bryntum/support/issues/4172
Thank you for the feedback and sorry for the inconvenience!

If you have access to the customerzone you can try my solution w/ the upcoming Gantt v5.0.0 (it's on alpha-2 stage at the moment). It should export that class.


Post by greg »

Thank you Arcady


Post by paul.mather »

Hello,

We had this working in version 5.3.0 but since moving to version 5.6.0 of the Gantt, we can't find HasPercentDoneMixIn ?
Please can you advise
Thanks
Paul


Post by sergey.maltsev »

Hi!

Gantt module bundle has exported HasPercentDoneMixin.
Please use the correct mixin name.


Post by arcady »

If that's not the name typo as Sergey guessed please provide a test case so we could reproduce the issue.


Post Reply