Search code examples
oracle-apex

How to paint tasks with different colors in Gantt chart based on some user defined criteria in Oracle APEX?


I was wondering is it possible to paint tasks with different colors in a Gantt chart based on some criteria in Oracle APEX? I read tasks from 2 different tables combined with union in the query, and was wondering if i can paint them based on the table they are read from?


Solution

  • Sure you can!

    You can leverage any or all of the three attribute fields here for managing the CSS styling of the tasks.

    enter image description here

    If you check the help for these fields, the help mentions the following:

    Enter CSS classes to be applied to baseline bars on the Gantt chart. You may add multiple classes by separating them with spaces. You can utilize &COLUMN_VALUE. substitutions.

    So instead of hard-coding it, you can use a column you can add to your query with your logic with a case-when clause. For example:

    SELECT ..., 
      CASE 
        when criteria_column = 'value1' then 'u-color-22' 
        when criteria_column = 'value2' then 'u-color-23'
        when criteria_column = 'value3' then 'u-color-24'
        else 'u-color-25'
      END AS task_color
    from my_union