cellcolor for task in resourcereport

403 views
Skip to first unread message

Jean-Jacques Merillon

unread,
Jul 13, 2011, 7:53:17 PM7/13/11
to TaskJuggler Users
Is there a way to generate resourcereport with different color for task ?
I try the following test, but I don't have colored cell

task T1 "T1" {

task SubT11 "SubT11" {
.../...
}
task SubT12 "SubT12" {
.../...
}
}

task T2 "T2" {

task SubT21 "SubT21" {
.../...
}
task SubT22 "SubT22" {
.../...
}
}


macro CustomCellColor [
cellcolor ischildof(T1) "#FFFF00" # color for subtask of t1
cellcolor ischildof(T2) "#00FFFF" # color for subtask of t2
]

resourcereport resourceGraph "" {
headline "Resource Allocation Graph"
columns name , weekly { ${CustomCellColor}}
loadunit shortauto
sorttasks plan.start.up
}


JJay

Chris Schlaeger

unread,
Jul 14, 2011, 2:20:42 PM7/14/11
to taskjugg...@googlegroups.com
On Thu, Jul 14, 2011 at 1:53 AM, Jean-Jacques Merillon
<jjmer...@gmail.com> wrote:
> macro CustomCellColor [
>        cellcolor ischildof(T1) "#FFFF00" # color for subtask of t1
>        cellcolor ischildof(T2) "#00FFFF" # color for subtask of t2
> ]
>
> resourcereport resourceGraph "" {
>  headline "Resource Allocation Graph"
>  columns name , weekly { ${CustomCellColor}}
>  loadunit shortauto
>  sorttasks plan.start.up
> }

Custom background colors don't work with 'weekly' as it already uses
background colors. The custom color is only effective for task lines,
the report only contains resource lines. The report does not have a
name nor a formats option, so nothing will ever be generated.

Chris

Jean-Jacques Merillon

unread,
Jul 17, 2011, 1:14:12 PM7/17/11
to taskjugg...@googlegroups.com


Ok. I tried this customization taskreport development of TJ3 tutoriel but I don't have color on my chart :(
Is there a sample with cellColor ?

macro CustomCellColor [
cellcolor istask() "#FF00FF"
cellcolor 1 "#FFFF00"
cellcolor ischildof(software) "#00FFFF"
cellcolor ischildof(AcSo) "#FF00FF"
]

# A list of tasks showing the resources assigned to each task.
taskreport development "" {
scenarios delayed
headline "Development - Resource Allocation Report"
columns hierarchindex, name, start, end, effort { title "Work" }, duration, chart { ${CustomCellColor} ${TaskTip} scale day width 800 }
timeformat "%Y-%m-%d"
hideresource ~(isleaf() & isleaf_())
sortresources name.up
}


JJay

Chris Schlaeger

unread,
Jul 17, 2011, 1:48:32 PM7/17/11
to taskjugg...@googlegroups.com
On Sun, Jul 17, 2011 at 7:14 PM, Jean-Jacques Merillon
<jjmer...@free.fr> wrote:
> Ok. I tried this customization taskreport development  of TJ3 tutoriel but I don't have color on my chart :(
> Is there a sample with cellColor ?
>
> macro CustomCellColor [
>        cellcolor istask() "#FF00FF"
>        cellcolor 1 "#FFFF00"
>        cellcolor ischildof(software) "#00FFFF"
>        cellcolor ischildof(AcSo) "#FF00FF"
> ]
>
> # A list of tasks showing the resources assigned to each task.
> taskreport development "" {
>  scenarios delayed
>  headline "Development - Resource Allocation Report"
>  columns hierarchindex, name, start, end, effort { title "Work" }, duration, chart { ${CustomCellColor} ${TaskTip} scale day width 800 }

All the columns that already use background colors won't work. That
includes 'daily', 'weekly' and so on and 'chart'. Try name, start or
end.

Chris

Jean-Jacques Merillon

unread,
Jul 17, 2011, 1:58:51 PM7/17/11
to TaskJuggler Users
Ok, I just understood my mistake ! CellColor is not available for chart, daily, weekly (all columns with background color)

Here a modified sample Tutorial working on other columns :

macro CustomCellColor [
cellcolor ischildof(AcSo.software) "#00FFFF" 
cellcolor ischildof(AcSo.test) "#FF00FF" 
]

# A list of tasks showing the resources assigned to each task.
taskreport development "" {
  scenarios delayed
  headline "Development - Resource Allocation Report"
  columns hierarchindex, name { ${CustomCellColor}}, start{ ${CustomCellColor}}, end{ ${CustomCellColor}}, effort { ${CustomCellColor} title "Work" }, duration{ ${CustomCellColor}}, chart { ${TaskTip} scale day width 800 }
  timeformat "%Y-%m-%d"
  hideresource ~(isleaf() & isleaf_())
  sortresources name.up
}

# A graph showing resource allocation. It identifies whether each
# resource is under- or over-allocated for.
resourcereport resourceGraph "" {
  scenarios delayed
  headline "Resource Allocation Graph"
  columns no{ ${CustomCellColor}}, name{ ${CustomCellColor}}, effort{ ${CustomCellColor}}, rate{ ${CustomCellColor}}, daily { ${TaskTip} width 800 }
  loadunit shortauto
  # We only like to show leaf tasks for leaf resources.
  hidetask ~(isleaf() & isleaf_())
  sorttasks plan.start.up
}


But my need is to have different colors in detailed columns instead of blue, is it possible ?

JJay

Chris Schlaeger

unread,
Jul 17, 2011, 2:03:39 PM7/17/11
to taskjugg...@googlegroups.com
On Sun, Jul 17, 2011 at 7:58 PM, Jean-Jacques Merillon
<jjmer...@free.fr> wrote:
> But my need is to have different colors in detailed columns instead of blue,
> is it possible ?

What do you mean by 'detailed columns'? chart & co have hardcoded
colors. You could only change the stylesheet if you don't like the
color scheme.

Chris

Jean-Jacques Merillon

unread,
Jul 17, 2011, 2:26:35 PM7/17/11
to taskjugg...@googlegroups.com

I want have (in chart) yellow color for "Specification" task, orange color for "Database coupling" task, purple color for "Back-End Functions" task and so one.
But because chart & co have hardcoded colors, I am pretty sure it is not possible.


JJay

Jean-Jacques Merillon

unread,
Jul 17, 2011, 6:07:23 PM7/17/11
to TaskJuggler Users
In fact, it's possible, but I patched TableReport.rb. I added the following code after line 777 in TableReport.rb

          setCustomCellAttributes(cell, columnDef, query)


This is my patched genCalChartTaskCell method. Chris what is your opinion about my patch ?

    def genCalChartTaskCell(origQuery, line, columnDef, t, sameTimeNextFunc)
      task = line.property
      # Find out if we have an enclosing resource scope.
      if line.scopeLine && line.scopeLine.property.is_a?(Resource)
        resource = line.scopeLine.property
      else
        resource = nil
      end

      # Get the interval of the task. In case a date is invalid due to a
      # scheduling problem, we use the full project interval.
      taskStart = task['start', origQuery.scenarioIdx]
      taskEnd = task['end', origQuery.scenarioIdx]
      taskIv = TimeInterval.new(taskStart.nil? ?  @project['start'] : taskStart,
                                taskEnd.nil? ?  @project['end'] : taskEnd)

      firstCell = nil
      while t < @end
        # We modify the start and end dates to match the cell boundaries. So
        # we need to make sure we don't modify the original Query but our own
        # copies.
        query = origQuery.dup
        # call TjTime::sameTimeNext... function
        nextT = t.send(sameTimeNextFunc)
        cellIv = TimeInterval.new(t, nextT)
        case columnDef.content
        when 'empty'
          # Create a new cell
          cell = newCell(query, line)
          # We only generate cells will different background colors.
        when 'load'
          query.attributeId = 'effort'
          query.start = t
          query.end = nextT
          query.process

          # Create a new cell
          cell = newCell(query, line)

          # To increase readability, we don't show 0.0 values.
          cell.text = query.to_s if query.to_num != 0.0
        else
          raise "Unknown column content #{column.content}"
        end

        cdText = columnDef.cellText.getPattern(query)
        cell.text = cdText if cdText

        # Determine cell category (mostly the background color)
        if cellIv.overlaps?(taskIv)
          # The cell is either a container or leaf task
          cell.category = task.container? ? 'calconttask' : 'caltask'
          # If the user has requested a custom tooltip, add it to each task cell.
          cell.tooltip = columnDef.tooltip.getPattern(query) || nil
          cell.showTooltipHint = false
          setCustomCellAttributes(cell, columnDef, query)
        elsif !@project.isWorkingTime(cellIv)
          # The cell is a vacation cell.
          cell.category = 'offduty'
        else
          # The cell is just filled with the background color.
          cell.category = 'taskcell'
        end
        cell.category += line.property.get('index') % 2  == 1 ? '1' : '2'

        tryCellMerging(cell, line, firstCell)

        t = nextT
        firstCell = cell unless firstCell
      end

      legend.addCalendarItem('Container Task', 'calconttask1')
      legend.addCalendarItem('Task', 'caltask1')
      legend.addCalendarItem('Off duty time', 'offduty')
    end

Chris Schlaeger

unread,
Jul 18, 2011, 3:54:19 PM7/18/11
to taskjugg...@googlegroups.com
Can you please use github so I can easily review the changes?

Thanks,
Chris

Jean-Jacques Merillon

unread,
Jul 18, 2011, 6:30:38 PM7/18/11
to taskjugg...@googlegroups.com
I just send a pull request.

JJay

> --
> You received this message because you are subscribed to the "TaskJuggler Users" group.
> To post to this group, send email to taskjugg...@googlegroups.com
> To unsubscribe from this group, send email to
> taskjuggler-us...@googlegroups.com
> For more information about TaskJuggler visit http://www.taskjuggler.org

Chris Schlaeger

unread,
Jul 19, 2011, 1:51:43 PM7/19/11
to taskjugg...@googlegroups.com
On Tue, Jul 19, 2011 at 12:30 AM, Jean-Jacques Merillon
<jjmer...@free.fr> wrote:
> I just send a pull request.

Thanks a lot! I've applied your patch.

Chris

Reply all
Reply to author
Forward
0 new messages