Skip to content

Calculated min date uses current date as a minimum instead of the actual task minimum date #355

Open
@Moult

Description

In this line of code, vDate defaults to the current date:

let vDate = new Date();

Also problematically, in this line of code, functions like getStart default to the current date if no date is found (such as when the task is a group and has no start/end):

if (pList[i].getStart().getTime() < vDate.getTime()) vDate.setTime(pList[i].getStart().getTime());
if (pList[i].getPlanStart() && pList[i].getPlanStart().getTime() < vDate.getTime()) vDate.setTime(pList[i].getPlanStart().getTime());

When these two behaviours are combined it means that when your first grouped task has a min date of sometime in the future, the gantt chat always begins at today, even if vMinDate is specified.

This can be very troublesome when doing projects where the project begins a few years in the future, as you will have many years of nothing happening.

2021-10-29-171420_1919x358_scrot

Sample code:

<link href="jsgantt.css" rel="stylesheet" type="text/css"/>
<script src="jsgantt.js" type="text/javascript"></script>
<div style="position:relative" class="gantt" id="GanttChartDIV"></div>
<script type="text/javascript">
var g = new JSGantt.GanttChart(document.getElementById('GanttChartDIV'), 'week');
g.setOptions({
    vCaptionType: 'Complete',  // Set to Show Caption : None,Caption,Resource,Duration,Complete,
    vQuarterColWidth: 36,
    vDateTaskDisplayFormat: 'day dd month yyyy', // Shown in tool tip box
    vDayMajorDateDisplayFormat: 'mon yyyy - Week ww',// Set format to dates in the "Major" header of the "Day" view
    vWeekMinorDateDisplayFormat: 'dd mon', // Set format to display dates in the "Minor" header of the "Week" view
    vLang: 'en',
    //vMinDate: new Date('2027-01-01'),
    vShowTaskInfoLink: 1, // Show link in tool tip (0/1)
    vShowEndWeekDate: 0,  // Show/Hide the date for the last day of the week in header for daily
    vUseSingleCell: 10000, // Set the threshold cell per table row (Helps performance for large data.
    vFormatArr: ['Day', 'Week', 'Month', 'Quarter'], // Even with setUseSingleCell using Hour format on such a large chart can cause issues in some browsers,
    vTotalHeight: 900,
});
var json_data = `
[{"pID": 540527, "pName": "foo", "pStart": "", "pEnd": "", "pPlanStart": "", "pPlanEnd": "", "pMile": 0, "pComp": 0, "pGroup": 1, "pParent": 540526, "pOpen": 1, "pCost": 1, "pClass": "ggroupblack", "pDepend": ""}, {"pID": 540529, "pName": "bar", "pStart": "2027-01-01T00:00:00", "pEnd": "2027-01-29T00:00:00", "pPlanStart": "2027-01-01T00:00:00", "pPlanEnd": "2027-01-29T00:00:00", "pMile": 0, "pComp": 0, "pGroup": 0, "pParent": 540527, "pOpen": 1, "pCost": 1, "pClass": "gtaskred", "pDepend": ""}, {"pID": 540535, "pName": "asdf", "pStart": "2027-01-15T00:00:00", "pEnd": "2027-01-29T00:00:00", "pPlanStart": "2027-01-15T00:00:00", "pPlanEnd": "2027-01-29T00:00:00", "pMile": 0, "pComp": 0, "pGroup": 0, "pParent": 540527, "pOpen": 1, "pCost": 1, "pClass": "gtaskred", "pDepend": "540529FS"}, {"pID": 540545, "pName": "asdf", "pStart": "2027-01-29T00:00:00", "pEnd": "2027-02-12T00:00:00", "pPlanStart": "2027-01-29T00:00:00", "pPlanEnd": "2027-02-12T00:00:00", "pMile": 0, "pComp": 0, "pGroup": 0, "pParent": 540527, "pOpen": 1, "pCost": 1, "pClass": "gtaskred", "pDepend": "540535FS"}, {"pID": 540554, "pName": "asdf", "pStart": "2027-02-12T00:00:00", "pEnd": "2027-02-26T00:00:00", "pPlanStart": "2027-02-12T00:00:00", "pPlanEnd": "2027-02-26T00:00:00", "pMile": 0, "pComp": 0, "pGroup": 0, "pParent": 540527, "pOpen": 1, "pCost": 1, "pClass": "gtaskred", "pDepend": "540545FS"}, {"pID": 540563, "pName": "asdf", "pStart": "2027-02-26T00:00:00", "pEnd": "2027-03-12T00:00:00", "pPlanStart": "2027-02-26T00:00:00", "pPlanEnd": "2027-03-12T00:00:00", "pMile": 0, "pComp": 0, "pGroup": 0, "pParent": 540527, "pOpen": 1, "pCost": 1, "pClass": "gtaskred", "pDepend": "540554FS"}, {"pID": 540572, "pName": "asdf", "pStart": "2027-03-12T00:00:00", "pEnd": "2027-03-26T00:00:00", "pPlanStart": "2027-03-12T00:00:00", "pPlanEnd": "2027-03-26T00:00:00", "pMile": 0, "pComp": 0, "pGroup": 0, "pParent": 540527, "pOpen": 1, "pCost": 1, "pClass": "gtaskred", "pDepend": "540563FS"}, {"pID": 540581, "pName": "asdf", "pStart": "2027-03-26T00:00:00", "pEnd": "2027-04-09T00:00:00", "pPlanStart": "2027-03-26T00:00:00", "pPlanEnd": "2027-04-09T00:00:00", "pMile": 0, "pComp": 0, "pGroup": 0, "pParent": 540527, "pOpen": 1, "pCost": 1, "pClass": "gtaskred", "pDepend": "540572FS"}, {"pID": 540590, "pName": "asdf", "pStart": "2027-04-09T00:00:00", "pEnd": "2027-04-23T00:00:00", "pPlanStart": "2027-04-09T00:00:00", "pPlanEnd": "2027-04-23T00:00:00", "pMile": 0, "pComp": 0, "pGroup": 0, "pParent": 540527, "pOpen": 1, "pCost": 1, "pClass": "gtaskred", "pDepend": "540581FS"}, {"pID": 540599, "pName": "asdf", "pStart": "2027-04-23T00:00:00", "pEnd": "2027-05-07T00:00:00", "pPlanStart": "2027-04-23T00:00:00", "pPlanEnd": "2027-05-07T00:00:00", "pMile": 0, "pComp": 0, "pGroup": 0, "pParent": 540527, "pOpen": 1, "pCost": 1, "pClass": "gtaskred", "pDepend": "540590FS"}, {"pID": 540608, "pName": "asdf", "pStart": "2027-05-07T00:00:00", "pEnd": "2027-05-21T00:00:00", "pPlanStart": "2027-05-07T00:00:00", "pPlanEnd": "2027-05-21T00:00:00", "pMile": 0, "pComp": 0, "pGroup": 0, "pParent": 540527, "pOpen": 1, "pCost": 1, "pClass": "gtaskred", "pDepend": "540599FS"}, {"pID": 540617, "pName": "Foo", "pStart": "2027-01-29T00:00:00", "pEnd": "2027-02-08T00:00:00", "pPlanStart": "2027-01-29T00:00:00", "pPlanEnd": "2027-02-08T00:00:00", "pMile": 0, "pComp": 0, "pGroup": 0, "pParent": 540527, "pOpen": 1, "pCost": 1, "pClass": "gtaskblue", "pDepend": "540529FS"}]
`;
JSGantt.parseJSONString(json_data, g);
g.Draw();
</script>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions