In a Gantt diagram, is it possible to add a constraint to a task that has yet to be defined in the source file?

0 votes
asked Sep 7, 2020 in Question / help by ktn (120 points)
I am running a fairly complex project with several sub-projects. In the Gantt diagram I want to group Tasks within sub-projects. I am using Separators to visually distinguish between sub-projects. However if I try to express a constraint between a Task and one defined further down in the source file I get: "Some diagram description contains errors". I have created a very simple example below. As it stands, it won't compile. Comment out Task 1 and it compiles fine.

It would be simple in the example just to move "Sub-project One" down to resolve the error but as mentioned, my actual project is considerably more complex and I cannot move Tasks within the source file and still maintain their position relative to the "owning" separator.

Have I missed something obvious or should I be approaching this differently? I realise I can simply drop the constraint but I would like to maintain the visual connection if at all possible.

@startgantt
Project starts 2020-09-01
today is colored in #ff8080
saturday are closed
sunday are closed
'======================================================'
-- Sub-project One --
[Task 1] as [T1] starts at [T2]'s end and ends 2020-10-28
-- Sub-project Two --
[Task 2] as [T2] starts 2020-09-01 and ends 2020-09-28
-- Sub-project Three --
[Task 3] as [T3] starts at [T2]'s end and ends 2020-10-28
@endgantt

1 Answer

0 votes
answered Sep 7, 2020 by plantuml (295,000 points)

The issue comes from the fact that you have to define a task before using it.

We are going to think about a proper way to do this.

In the meantime, you can have some *ugly* turnaround :

@startgantt
Project starts 2020-09-01
today is colored in #ff8080
saturday are closed
sunday are closed
'======================================================'
-- Sub-project One --
[Task 1] as [T1] lasts 1 day
-- Sub-project Two --
[Task 2] as [T2] starts 2020-09-01 and ends 2020-09-28
[Task 1] as [T1] starts at [T2]'s end and ends 2020-10-28
-- Sub-project Three --
[Task 3] as [T3] starts at [T2]'s end and ends 2020-10-28
@endgantt

Really ugly as I said...

We have to find something here :-)

commented Sep 7, 2020 by ktn (120 points)
Ha! That's excellent. Thank you very much for the prompt reply. I've written a pre-processor that reads Task details from a simple CSV file to create the Gantt source file so it will be easy enough to add this workaround. The pre-processor also outputs Tasks as tables in Markdown format; having a single source file reduces errors.

Sub-project support using swimlanes might be a useful addition?
...