Exemplo n.º 1
0
 /**
  * @param int $teamid
  * @param int $startTimestamp
  * @param int $endTimestamp
  * @param int[] $projectIds
  * @return GanttGraph
  */
 private function getGanttGraph($teamid, $startTimestamp, $endTimestamp, array $projectIds)
 {
     $graph = new GanttGraph();
     // set graph title
     $team = TeamCache::getInstance()->getTeam($teamid);
     if (0 != count($projectIds)) {
         $pnameList = "";
         foreach ($projectIds as $pid) {
             if ("" != $pnameList) {
                 $pnameList .= ",";
             }
             $project = ProjectCache::getInstance()->getProject($pid);
             $pnameList .= $project->getName();
         }
         $graph->title->Set(T_('Team') . ' ' . $team->getName() . '    ' . T_('Project(s)') . ': ' . $pnameList);
     } else {
         $graph->title->Set(T_('Team') . ' ' . $team->getName() . '    (' . T_('All projects') . ')');
     }
     // Setup scale
     $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK);
     $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAYWNBR);
     $gantManager = new GanttManager($teamid, $startTimestamp, $endTimestamp);
     $teamActivities = $gantManager->getTeamActivities();
     // mapping to ease constrains building
     // Note: $issueActivityMapping must be completed before calling $a->getJPGraphBar()
     $issueActivityMapping = array();
     $activityIdx = 0;
     foreach ($teamActivities as $a) {
         $a->setActivityIdx($activityIdx);
         $issueActivityMapping[$a->bugid] = $activityIdx;
         ++$activityIdx;
     }
     // Add the specified activities
     foreach ($teamActivities as $a) {
         // FILTER on projects
         if (NULL != $projectIds && 0 != sizeof($projectIds)) {
             $issue = IssueCache::getInstance()->getIssue($a->bugid);
             if (!in_array($issue->getProjectId(), $projectIds)) {
                 // skip activity indexing
                 continue;
             }
         }
         $filterTeamActivities[] = $a;
         // Shorten bar depending on gantt startDate
         if (NULL != $startTimestamp && $a->startTimestamp < $startTimestamp) {
             // leave one day to insert prefixBar
             $newStartTimestamp = $startTimestamp + 60 * 60 * 24;
             if ($newStartTimestamp > $a->endTimestamp) {
                 // there is not enough space for a prefixBar
                 $newStartTimestamp = $startTimestamp;
                 self::$logger->debug("bugid=" . $a->bugid . ": Shorten bar to Gantt start date");
             } else {
                 $formattedStartDate = date('Y-m-d', $startTimestamp);
                 $prefixBar = new GanttBar($a->activityIdx, "", $formattedStartDate, $formattedStartDate, "", 10);
                 $prefixBar->SetBreakStyle(true, 'dotted', 1);
                 $graph->Add($prefixBar);
                 self::$logger->debug("bugid=" . $a->bugid . ": Shorten bar & add prefixBar");
             }
             self::$logger->debug("bugid=" . $a->bugid . ": Shorten bar from " . date('Y-m-d', $a->startTimestamp) . " to " . date('Y-m-d', $newStartTimestamp));
             $a->startTimestamp = $newStartTimestamp;
         }
         $bar = $a->getJPGraphBar($issueActivityMapping);
         $graph->Add($bar);
     }
     return $graph;
 }
Exemplo n.º 2
0
$graph->scale->month->SetStyle(MONTHSTYLE_SHORTNAMEYEAR4);
$graph->scale->month->SetFontColor("white");
$graph->scale->month->SetBackgroundColor("blue");
// 0 % vertical label margin
$graph->SetLabelVMarginFactor(1);
// 1=default value
// Format the bar for the first activity
// ($row,$title,$startdate,$enddate)
$activity1 = new GanttBar(0, "Activity 1", "2001-12-21", "2001-12-26", "");
// Yellow diagonal line pattern on a red background
$activity1->SetPattern(BAND_RDIAG, "yellow");
$activity1->SetFillColor("red");
// Format the bar for the first activity
// ($row,$title,$startdate,$enddate)
$break1 = new GanttBar(0, '', "2001-12-27", "2001-12-30", "");
$break1->SetBreakStyle(true, 'dotted', 2);
$break1->SetColor('red');
$graph->Add($break1);
// Format the bar for the second activity
// ($row,$title,$startdate,$enddate)
$activity2 = new GanttBar(0, "", "2001-12-31", "2002-01-2", "[BO]");
// ADjust font for caption
$activity2->caption->SetFont(FF_ARIAL, FS_BOLD);
$activity2->caption->SetColor("darkred");
// Yellow diagonal line pattern on a red background
$activity2->SetPattern(BAND_RDIAG, "yellow");
$activity2->SetFillColor("red");
// Finally add the bar to the graph
$graph->Add($activity1);
$graph->Add($activity2);
// ... and display it