Plant UML Gantt Diagram: persentage completed determines color of task-bar

+1 vote
asked Sep 28, 2018 in Wanted features by Job

Hi,

It would be nice if we could use a syntax like 'completed x%' and that this results in a color change within the taskbar.

For example:

@startgantt

[Task 1] lasts 1 days completed 50%

[Task 2] lasts 5 days completed 21%

...

@endgantt

Gantt Chart Percentage Completed

1 Answer

0 votes
answered Jun 29, 2021 by The-Lu (63,920 points)

Hello J.,

FYI, from Janv. 2020 (See QA-10679)  you can now use:

@startgantt
[Task 1] lasts 4 days and is 50% completed 
[Task 2] lasts 5 days and is 21% completed 
'...
@endgantt

Then, awaiting a buildin function (Wanted feature on QA-14128), for change the color within the taskbar, you can create an user function as:

@startgantt
!function $completion_color($percent)
  !$r=white
  !if $percent < 25
    !$r=crimson
  !elseif $percent < 50
    !$r=orange
  !elseif $percent < 75
    !$r=gold
  !elseif $percent >= 75
    !$r=green
  !endif
  !return $r
!end function

[0%]   lasts 10 days and is   0% completed and is colored in $completion_color(0)
[20%]  lasts 10 days and is  20% completed and is colored in $completion_color(20)
[40%]  lasts 10 days and is  40% completed and is colored in $completion_color(40)
[60%]  lasts 10 days and is  60% completed and is colored in $completion_color(60)
[80%]  lasts 10 days and is  80% completed and is colored in $completion_color(80)
[100%] lasts 10 days and is 100% completed and is colored in $completion_color(100)
@endgantt

Enjoy,
If that can help,

Regards,
Th.

commented Jul 27, 2021 by plantuml (294,960 points)

With last beta http://beta.plantuml.net/plantuml.jar you can have:

@startgantt
[Prototype design] lasts 13 days
[Test prototype 0] lasts 4 days
[Test prototype 10] lasts 4 days
[Test prototype 20] lasts 4 days
[Test prototype 30] lasts 4 days
[Test prototype 40] lasts 4 days
[Test prototype 50] lasts 4 days
[Test prototype 60] lasts 4 days
[Test prototype 70] lasts 4 days
[Test prototype 80] lasts 4 days
[Test prototype 90] lasts 4 days
[Test prototype 100] lasts 4 days

[Test prototype 0] starts at [Prototype design]'s end
[Test prototype 10] starts at [Prototype design]'s end
[Test prototype 20] starts at [Prototype design]'s end
[Test prototype 30] starts at [Prototype design]'s end
[Test prototype 40] starts at [Prototype design]'s end
[Test prototype 50] starts at [Prototype design]'s end
[Test prototype 60] starts at [Prototype design]'s end
[Test prototype 70] starts at [Prototype design]'s end
[Test prototype 80] starts at [Prototype design]'s end
[Test prototype 90] starts at [Prototype design]'s end
[Test prototype 100] starts at [Prototype design]'s end

[Prototype design] is colored in Red/Blue 
[Test prototype 0] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green 
[Test prototype 10] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green 
[Test prototype 20] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green 
[Test prototype 30] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green 
[Test prototype 40] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green 
[Test prototype 50] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green 
[Test prototype 60] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green 
[Test prototype 70] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green 
[Test prototype 80] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green 
[Test prototype 90] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green 
[Test prototype 100] is colored for completion from Fuchsia/FireBrick to GreenYellow/Green 

[Test prototype 0] is 0% complete
[Test prototype 10] is 10% complete
[Test prototype 20] is 20% complete
[Test prototype 30] is 30% complete
[Test prototype 40] is 40% complete
[Test prototype 50] is 50% complete
[Test prototype 60] is 60% complete
[Test prototype 70] is 70% complete
[Test prototype 80] is 80% complete
[Test prototype 90] is 90% complete
[Test prototype 100] is 100% complete

@endgantt

The syntax is not very convenient, because there is no way to declare a global setting for all tasks.

We are thinking about adding something like:

<style>
ganttDiagram {
task {
BackGroundColor GreenYellow
LineColor blue
}

unstartedTask {
BackGroundColor red
LineColor red
}

}
</style>

What do you think about it ?

commented Jul 28, 2021 by The-Lu (63,920 points)

Hello PlantUML team,

yes 

Yes, that's good:

<style>
ganttDiagram {
  unstartedTask {
    BackGroundColor Fuchsia 
    LineColor FireBrick
  }
  task {
    BackGroundColor GreenYellow
    LineColor Green 
  }
}
</style>

And with local style.

Regards,
Th.

commented Jul 31, 2021 by plantuml (294,960 points)

Ok, so with last beta http://beta.plantuml.net/plantuml.jar and on the online server you can now have :

@startgantt

<style>
ganttDiagram {
  unstartedTask {
    BackGroundColor Fuchsia 
    LineColor FireBrick
  }
  task {
    BackGroundColor GreenYellow
    LineColor Green 
  }
}
</style>

[Prototype design] lasts 13 days
[Test prototype 0] lasts 4 days
[Test prototype 10] lasts 4 days
[Test prototype 20] lasts 4 days
[Test prototype 30] lasts 4 days
[Test prototype 40] lasts 4 days
[Test prototype 50] lasts 4 days
[Test prototype 60] lasts 4 days
[Test prototype 70] lasts 4 days
[Test prototype 80] lasts 4 days
[Test prototype 90] lasts 4 days
[Test prototype 100] lasts 4 days

[Test prototype 0] starts at [Prototype design]'s end
[Test prototype 10] starts at [Prototype design]'s end
[Test prototype 20] starts at [Prototype design]'s end
[Test prototype 30] starts at [Prototype design]'s end
[Test prototype 40] starts at [Prototype design]'s end
[Test prototype 50] starts at [Prototype design]'s end
[Test prototype 60] starts at [Prototype design]'s end
[Test prototype 70] starts at [Prototype design]'s end
[Test prototype 80] starts at [Prototype design]'s end
[Test prototype 90] starts at [Prototype design]'s end
[Test prototype 100] starts at [Prototype design]'s end

[Test prototype 0] is 0% complete
[Test prototype 10] is 10% complete
[Test prototype 20] is 20% complete
[Test prototype 30] is 30% complete
[Test prototype 40] is 40% complete
[Test prototype 50] is 50% complete
[Test prototype 60] is 60% complete
[Test prototype 70] is 70% complete
[Test prototype 80] is 80% complete
[Test prototype 90] is 90% complete
[Test prototype 100] is 100% complete

@endgantt

This has not been widely tested...

commented Nov 15, 2023 by Eugenia
This has been very helpful. Thanks for it.

But I have a new challenge that I don't know how to resolve.

I have a group of tasks (Development) that I want to color based on the completion from Pink to Green (like the example above) and others (Test) that I want to color from Blue to Pink.

This is to easy identify Development from Test tasks.

Is there any way to create 2 styles and identify a single task to one of them?

In my case it is a very big Gantt, therefore I would like to have a simplified way of doing it.

Thanks in advance

--------------------------------

@startgantt

'Style A
<style>
ganttDiagram {
  task {
    BackGroundColor GreenYellow
    LineColor Green
    unstarted {
      BackGroundColor Fuchsia
      LineColor FireBrick
    }
  }
}
</style>

'Style B
<style>
ganttDiagram {
  task {
    BackGroundColor GreenYellow
    LineColor Green
    unstarted {
      BackGroundColor Blue
      LineColor Blue
    }
  }
}
</style>

[17 Implementation] lasts 1 day and is 50% complete <Style A>
[17. Test] lasts 1 day and is 0% complete <Style B>

@endgantt
...