Search code examples
anychart

AnyGantt prevent calculating parent dates from children


AnyChart's documentation for AnyGantt Project Charts states:

Note that if you do not specify the actualStart and actualEnd dates of a parent task, they are calculated automatically from the dates of its children. (https://docs.anychart.com/Gantt_Chart/Project_Chart)

I would like to know if there's a way to prevent this from occurring. If there is no actualStart or actualEnd specified in the parent, I don't want a line to be added to the chart. I've tried setting actualStart and actualEnd dates values to " ", but now a marker is being placed on the chart in a location before the year 1970. Any suggestions?


Solution

  • I found a solution that works for me. I used fill and stroke functions on groupingTasks to hide the elements.

    timeline.groupingTasks().fill(function(){
        if (this.item.oa.actualStart && this.item.oa.actualEnd) return this.sourceColor;
        return this.sourceColor + ' 0.0';
    });
    
    timeline.groupingTasks().stroke(function(){
        if (this.item.oa.actualStart && this.item.oa.actualEnd) return anychart.color.setThickness(anychart.color.darken(this.sourceColor), 1);
        return anychart.color.setThickness(anychart.color.darken(this.sourceColor), 0);
    });