Advanced Gannt + Histogram Split Task

Support for v6.x of our Scheduling components
Post Reply
User avatar
MaciejHillar
Posts: 68
Joined: Thu Oct 04, 2018 3:00 pm

Advanced Gannt + Histogram Split Task

Post by MaciejHillar » Fri Jan 11, 2019 6:26 pm

HI,
I try manualy split task,
my code:

Code: Select all

 
                    var converter = task.getUnitConverter();
                    

                   // var actualEffortMS = convertDurationToMs(actualEffort, 'h') 
                    var orginalDuration = converter.convertDurationToMs(task.getDuration(), 'h');
                    actualEffort = converter.convertDurationToMs(actualEffort, 'h');
                    var percentageDone = actualEffort / converter.convertDurationToMs(task.getEffort(),'h') * 100;
                    var duration1 = orginalDuration * (percentageDone / 100);
                    var duration2 = orginalDuration - duration1;
                    var startDate = task.getStartDate();


                    var date = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate(), startDate.getHours() + 1);

                    task.split(date, duration2, 'ms');//, true);
                 
                    var f = task.getFirstSegment();
                    var l = task.getLastSegment();
                    f.setDuration(duration1, 'ms');

                    l.setDuration(duration2, 'ms')

                    l.setStartDate(newDate.getValue(), true, true);

Intresting is that, when I set Actuall Effort on 50% working fine
If change on exp. 40% spli task is rendered but when I try move task on timeline,
duration is changing and after several move task is marge.

Do you have any idea?

2. Why if I not set duration in

Code: Select all

  task.split(date, duration2, 'ms')
I can't set

Code: Select all

 
 l.setDuration(duration2, 'ms')
Error:
Uncaught TypeError: Cannot read property 'length' of null
at constructor.getSegmentsDuration (gnt-all-debug.js?ver=6.0.6:21064)
at constructor.onSegmentsChanged (gnt-all-debug.js?ver=6.0.6:21122)
at constructor.endEdit (gnt-all-debug.js?ver=6.0.6:43751)
at constructor.setDurationWithoutPropagation (gnt-all-debug.js?ver=6.0.6:43726)
at constructor.<anonymous> (gnt-all-debug.js?ver=6.0.6:23465)
at constructor.propagateChanges (gnt-all-debug.js?ver=6.0.6:20070)
at constructor.callTask (gnt-all-debug.js?ver=6.0.6:43768)
at constructor.propagateChanges (gnt-all-debug.js?ver=6.0.6:43809)
at constructor.setDuration (gnt-all-debug.js?ver=6.0.6:23464)
at constructor.<anonymous> (MainViewportController.js?_dc=1547223849695:104)

thx,
Maciej

User avatar
MaciejHillar
Posts: 68
Joined: Thu Oct 04, 2018 3:00 pm

Re: Advanced Gannt + Histogram Split Task

Post by MaciejHillar » Fri Jan 11, 2019 10:13 pm

Hi,
I prepared test case in advanced Gantt demo,
exactly the same behaviore

https://www.bryntum.com/examples/gantt- ... vanced/#en

Code: Select all

var gant   = Ext.ComponentQuery.query('advanced-gantt')[0];

var t = gant.getTaskStore().getById(120);

t.split(new Date('2017/01/24'),1,'h');

 var f = t.getFirstSegment();
   
var l = t.getLastSegment();
var calendar = t.getCalendar();

 var endF = calendar.calculateEndDate(f.getStartDate(), 10, 'h');
var endL = calendar.calculateEndDate(new Date('2017/01/24'), 10, 'h');

 f.setStartDate(t.getStartDate(), true, true);
    
                l.setStartDate(new Date('2017/01/29'), true, true);

f.setDuration(10, 'h');

can you help me with this?
thx,
Maciej

User avatar
arcady
Core Developer
Core Developer
Posts: 2186
Joined: Wed Mar 20, 2013 6:57 am

Re: Advanced Gannt + Histogram Split Task

Post by arcady » Mon Jan 14, 2019 12:56 pm

Can you please give us instructions on steps that I should do to see results that confuse you given that I use your provided test case on our advanced demo?

BTW why do you do this in the test case code?

Code: Select all

f.setStartDate(t.getStartDate(), true, true);
Seems not needed.


Regarding your first snippet with your custom task splitting code. I have a feeling that it could look simpler:
Why do you need two further setDuration() calls after this call?

Code: Select all

                    task.split(date, duration2, 'ms');//, true);
When you call split() you provide a date (roughly end date of the 1st segment) and split duration (the date + split duration roughly gives you the next segment start date).
So just calling split() should be enough to set 1st segment duration and the next segment start date.

What is newDate? Where is it defined?

Code: Select all

                    l.setStartDate(newDate.getValue(), true, true);
And one more minor thing.. Why do you multiply by 100 if you divide by 100 in the next line?

Code: Select all

                    var percentageDone = actualEffort / converter.convertDurationToMs(task.getEffort(),'h') * 100;
                    var duration1 = orginalDuration * (percentageDone / 100);
Seems not needed unless we use percentageDone value somewhere else. :)

User avatar
MaciejHillar
Posts: 68
Joined: Thu Oct 04, 2018 3:00 pm

Re: Advanced Gannt + Histogram Split Task

Post by MaciejHillar » Mon Jan 14, 2019 1:07 pm

Hi,
BTW why do you do this in the test case code?
f.setStartDate(t.getStartDate(), true, true);
This just fragment of my code, I would like split and move task on new Date

What is newDate? Where is it defined?
CODE: SELECT ALL

l.setStartDate(newDate.getValue(), true, true);

This is Just some some new date(no matter)


And one more minor thing.. Why do you multiply by 100 if you divide by 100 in the next line?
forget about it :) its nothing to Post



task.split(date, duration2, 'ms');//, true);
When you call split() you provide a date (roughly end date of the 1st segment) and split duration (the date + split duration roughly gives you the next segment start date).
So just calling split() should be enough to set 1st segment duration and the next segment start date.
ok this is my code now:

Code: Select all

var gant   = Ext.ComponentQuery.query('advanced-gantt')[0];

var t = gant.getTaskStore().getById(120);
var actualEffort = t.getActualEffort();
 var orginalDuration = t.getDuration();
                 
   var percentageDone = actualEffort / t.getEffort() 
   var duration1 = orginalDuration * percentageDone 

 var calendar = t.getCalendar();


var startDate = t.getStartDate();

debugger;
var endF = calendar.calculateEndDate(startDate, duration1, 'h');
var duration = calendar.calculateDuration(endF,new Date('2017/01/26'),'h');
t.split(endF, duration, 'h');
To work this example set Effort and actualEffort columns
If you split task and move this task duration is change

Post Reply