public function getJPGraphBar($issueActivityMapping) { $user = UserCache::getInstance()->getUser($this->userid); $issue = IssueCache::getInstance()->getIssue($this->bugid); if (NULL != $issue->getTcId()) { $formatedActivityName = substr($this->bugid . " [" . $issue->getTcId() . "] - " . $issue->getSummary(), 0, 50); } else { $formatedActivityName = substr($this->bugid . " - " . $issue->getSummary(), 0, 50); } $formatedActivityInfo = $user->getName(); if ($issue->getCurrentStatus() < $issue->getBugResolvedStatusThreshold()) { $formatedActivityInfo .= " (" . Constants::$statusNames[$issue->getCurrentStatus()] . ")"; } $bar = new GanttBar($this->activityIdx, utf8_decode($formatedActivityName), date('Y-m-d', $this->startTimestamp), date('Y-m-d', $this->endTimestamp), $formatedActivityInfo, 10); // --- colors $bar->SetPattern(GANTT_SOLID, $this->color); $bar->progress->Set($this->progress); $bar->progress->SetPattern(GANTT_SOLID, 'slateblue'); // --- add constrains $relationships = $issue->getRelationships(); $relationships = $relationships['' . Constants::$relationship_constrains]; if (is_array($relationships)) { foreach ($relationships as $bugid) { // Add a constrain from the end of this activity to the start of the activity $bugid $bar->SetConstrain($issueActivityMapping[$bugid], CONSTRAIN_ENDSTART); } } if (self::$logger->isDebugEnabled()) { self::$logger->debug("JPGraphBar bugid={$this->bugid} prj=" . $issue->getProjectId() . " activityIdx={$this->activityIdx}" . " progress={$this->progress} [" . date('Y-m-d', $this->startTimestamp) . " -> " . date('Y-m-d', $this->endTimestamp) . "]"); self::$logger->debug("JPGraphBar bugid={$this->bugid} GanttBar = " . var_export($bar, TRUE)); } return $bar; }
function parse($input, $parser) { foreach (split("\n", $input) as $line) { // skip empty line or comments if (preg_match("/^(\\s*)#.*\$|^(\\s*)\$/", $line)) { continue; } # 1ID>, 2P%, 3DEP, 4TASKNAME ,5DATE>, 6DATE, 7Tag if (preg_match("/(\\d+),(\\d+)%,([\\d:]*),([^,]+),([\\d\\s\\-]+),([\\d\\s\\-]+),?([^,]+)?/", $line, $parse_result)) { # $bar = new GanttBar(ID, Comment, start, end, tag, height); $bar = new GanttBar($parse_result[1], $parse_result[4], $parse_result[5], $parse_result[6]); foreach (split(",", $parse_result[3]) as $dep) { if (!$dep) { continue; } $bar->SetConstrain($dep, CONSTRAIN_STARTEND); } if ($this->min_date) { if (strtotime($parse_result[5]) < strtotime($this->min_date)) { $this->min_date = $parse_result[5]; } } else { $this->min_date = $parse_result[5]; } if ($this->max_date) { if (strtotime($parse_result[6]) > strtotime($this->max_date)) { $this->max_date = $parse_result[6]; } } else { $this->max_date = $parse_result[6]; } $bar->SetPattern(BAND_RDIAG, "yellow"); $bar->SetFillColor("gray"); //$bar->progress->Set($parse_result[2]/100); $bar->progress->SetPattern(GANTT_SOLID, "darkgreen"); $this->graph->Add($bar); } else { throw new Exception("Error while parsing line '{$line}': expected 'ID,PURCENT%,DEPENDENCY,TASK NAME,DATE,DATE'"); } } }
function prj_drawGanttBar(&$graph, $pid, $tid = 0, &$row, &$count) { global $_TABLES, $_CONF, $_PRJCONF; $sql = "SELECT tid,name,start_date, estimated_end_date,parent_task, progress, progress_id "; $sql .= "FROM {$_TABLES['prj_tasks']} "; if ($tid == 0) { $sql .= "WHERE pid={$pid} AND parent_task=0 ORDER BY lhs ASC"; } else { $sql .= "WHERE parent_task='{$tid}' ORDER BY lhs ASC"; } $result = DB_query($sql); for ($j = 0; $j < DB_numrows($result); $j++) { list($tid, $name, $startdate, $enddate, $parent_task, $progress, $status) = DB_fetchArray($result); $name = html_entity_decode($name); $strdate = strftime("%Y/%m/%d", $startdate); $edate = strftime("%Y/%m/%d", $enddate); $sql = "SELECT fullname FROM {$_TABLES['users']}, {$_TABLES['prj_task_users']} "; $sql .= "WHERE {$_TABLES['prj_task_users']}.tid={$tid} AND {$_TABLES['prj_task_users']}.uid={$_TABLES['users']}.uid"; $result2 = DB_query($sql); list($owner) = DB_fetchArray($result2); $link = $_CONF['site_url'] . "/nexproject/viewproject.php?mode=view&id=" . $tid; $count = $count + 1; //echo "<br>Count:$count, row:$row"; //$constrains[$j]=array($count, $parentcount, "CONSTRAIN_STARTEND"); if (strlen($name) > $_PRJCONF['project_name_length']) { $name = substr($name, 0, $_PRJCONF['project_name_length']); $name .= "..."; } if ($strdate == $edate) { $milestone = new Milestone($row, $name, $strdate); $milestone->mark->SetType(MARK_DIAMOND); $graph->Add($milestone); } else { $activity = new GanttBar($count, "{$name}", "{$strdate}", "{$edate}", "{$owner}"); if ($status == 0) { // Yellow diagonal line pattern on a red background $activity->SetPattern(GANTT_SOLID, "darkgreen"); $activity->progress->SetPattern(GANTT_RDIAG, "black"); $activity->progress->SetFillColor("white"); } elseif ($status == 1) { $activity->SetPattern(GANTT_SOLID, "yellow"); $activity->progress->SetPattern(GANTT_RDIAG, "black"); $activity->progress->SetFillColor("white"); } else { $activity->SetPattern(GANTT_SOLID, "red"); $activity->progress->SetPattern(GANTT_RDIAG, "black"); $activity->progress->SetFillColor("white"); } // Set absolute height $activity->SetHeight(10); $activity->progress->Set($progress / 100); // Specify progress $activity->SetCSIMTarget("{$link}"); $activity->SetCSIMAlt($progress . "% completed"); $activity->title->SetCSIMTarget("{$link}"); $activity->title->SetCSIMAlt($progress . "% completed"); $qconstraints = DB_query("SELECT tid FROM {$_TABLES['prj_tasks']} WHERE parent_task='{$tid}' ORDER BY lhs ASC"); $numconstraints = DB_numRows($qconstraints); for ($c = 1; $c <= $numconstraints; $c++) { $activity->SetConstrain($row + $c, CONSTRAIN_STARTSTART, "maroon4"); } // Add line to Gnatt Chart $graph->Add($activity); } $row++; if (DB_count($_TABLES['prj_tasks'], 'parent_task', $tid) > 0) { prj_drawGanttBar($graph, $pid, $tid, $row, $count); } } }
if ($showLabels) { $caption .= $AppUI->_($projectStatus[$p['project_status']]) . ', '; $caption .= $p['project_status'] != 7 ? $AppUI->_('active') : $AppUI->_('archived'); } $enddate = new CDate($end); $startdate = new CDate($start); $actual_end = $p['project_actual_end_date'] ? $p['project_actual_end_date'] : $end; $actual_enddate = new CDate($actual_end); $actual_enddate = $actual_enddate->after($startdate) ? $actual_enddate : $enddate; $bar = new GanttBar($row++, array($name, $startdate->format($df), $enddate->format($df), $actual_enddate->format($df)), $start, $actual_end, $cap, 0.6); $bar->progress->Set(min($progress / 100, 1)); if (is_file(TTF_DIR . "FreeSans.ttf")) { $bar->title->SetFont(FF_CUSTOM, FS_NORMAL, 9); } $bar->SetFillColor('#' . $p['project_color_identifier']); $bar->SetPattern(BAND_SOLID, '#' . $p['project_color_identifier']); //adding captions $bar->caption = new TextProperty($caption); $bar->caption->Align('left', 'center'); $bar->caption->SetFont(FF_CUSTOM, FS_NORMAL, 8); // gray out templates, completes, on ice, on hold if ($p['project_status'] != '3' || $p['project_status'] == '7') { $bar->caption->SetColor('darkgray'); $bar->title->SetColor('darkgray'); $bar->SetColor('darkgray'); $bar->SetFillColor('gray'); //$bar->SetPattern(BAND_SOLID,'gray'); $bar->progress->SetFillColor('darkgray'); $bar->progress->SetPattern(BAND_SOLID, 'darkgray', 98); } $graph->Add($bar);
} if ($a['task_dynamic'] == 1) { if (is_file(TTF_DIR . 'FreeSans.ttf')) { $bar->title->SetFont(FF_CUSTOM, FS_BOLD, 8); } $bar->rightMark->Show(); $bar->rightMark->SetType(MARK_RIGHTTRIANGLE); $bar->rightMark->SetWidth(3); $bar->rightMark->SetColor('black'); $bar->rightMark->SetFillColor('black'); $bar->leftMark->Show(); $bar->leftMark->SetType(MARK_LEFTTRIANGLE); $bar->leftMark->SetWidth(3); $bar->leftMark->SetColor('black'); $bar->leftMark->SetFillColor('black'); $bar->SetPattern(BAND_SOLID, 'black'); } } //adding captions $bar->caption = new TextProperty($caption); $bar->caption->Align('left', 'center'); if (is_file(TTF_DIR . 'FreeSans.ttf')) { $bar->caption->SetFont(FF_CUSTOM, FS_NORMAL, 8); } // show tasks which are both finished and past in (dark)gray if ($progress >= 100 && $end_date->isPast() && get_class($bar) == 'ganttbar') { $bar->caption->SetColor('darkgray'); $bar->title->SetColor('darkgray'); $bar->setColor('darkgray'); $bar->SetFillColor('darkgray'); $bar->SetPattern(BAND_SOLID, 'gray');
$graph->SetColor("white"); $graph->title->Set($strings["task"] . " " . $taskDetail->tas_name[0]); $graph->subtitle->Set("(" . $strings["created"] . ": " . $taskDetail->tas_created[0] . ")"); $graph->title->SetFont(FF_FONT1); $graph->SetColor("white"); $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK); $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY); $graph->scale->week->SetFont(FF_FONT0); $graph->scale->year->SetFont(FF_FONT1); $tmpquery = "WHERE subtas.task = '{$task}' AND subtas.start_date != '--' AND subtas.due_date != '--' AND tas.published != '1' ORDER BY subtas.due_date"; $listTasks = new request(); $listTasks->openSubtasks($tmpquery); $comptListTasks = count($listTasks->subtas_id); for ($i = 0; $i < $comptListTasks; $i++) { $listTasks->subtas_name[$i] = str_replace('"', '"', $listTasks->subtas_name[$i]); $listTasks->subtas_name[$i] = str_replace("'", "'", $listTasks->subtas_name[$i]); $progress = round($listTasks->subtas_completion[$i] / 10, 2); $printProgress = $listTasks->subtas_completion[$i] * 10; $activity = new GanttBar($i, $listTasks->subtas_name[$i], $listTasks->subtas_start_date[$i], $listTasks->subtas_due_date[$i]); $activity->SetPattern(BAND_LDIAG, "yellow"); $activity->caption->Set($listTasks->subtas_mem_login[$i] . " (" . $printProgress . "%)"); $activity->SetFillColor("gray"); if ($listTasks->subtas_priority[$i] == "4" || $listTasks->subtas_priority[$i] == "5") { $activity->progress->SetPattern(BAND_SOLID, "#BB0000"); } else { $activity->progress->SetPattern(BAND_SOLID, "#0000BB"); } $activity->progress->Set($progress); $graph->Add($activity); } $graph->Stroke();
// Format and add the Gantt bars to the chart $n = count($data); for ($i = 0; $i < $n; ++$i) { if ($i === 0 || $i === 3) { // Format the group bars $bar = new GanttBar($data[$i][0], array($data[$i][1], $data[$i][2], $data[$i][3]), $data[$i][2], $data[$i][3], '', 0.35); // For each group make the name bold but keep the dates as the default font $bar->title->SetColumnFonts(array(array(FF_ARIAL, FS_BOLD, 11))); // Add group markers $bar->leftMark->SetType(MARK_LEFTTRIANGLE); $bar->leftMark->Show(); $bar->rightMark->SetType(MARK_RIGHTTRIANGLE); $bar->rightMark->Show(); $bar->SetFillColor('black'); $bar->SetPattern(BAND_SOLID, 'black'); } else { // Format the activity bars $bar = new GanttBar($data[$i][0], array($data[$i][1], $data[$i][2], $data[$i][3]), $data[$i][2], $data[$i][3], '', 0.45); $bar->SetPattern(BAND_RDIAG, 'black'); $bar->SetFillColor('orange'); } // Default font $bar->title->SetFont(FF_ARIAL, FS_NORMAL, 10); $graph->Add($bar); } // Send back the graph to the client $graph->Stroke(); ?>
public function addSubBar($label, $start, $end, $caption = '', $height = '0.6', $barcolor = 'FFFFFF', $progress = 0) { $startDate = new CDate($start); $endDate = new CDate($end); $bar = new GanttBar($this->rowCount++, array($label, $startDate->format($this->df), $endDate->format($this->df), ' '), $start, $end, $caption, $height); $bar->progress->Set(min($progress / 100, 1)); $bar->title->SetFont(FF_CUSTOM, FS_NORMAL, 9); $bar->title->SetColor(bestColor('#ffffff', '#' . $barcolor, '#000000')); $bar->SetFillColor('#' . $barcolor); $bar->SetPattern(BAND_SOLID, '#' . $barcolor); //adding captions $bar->caption = new TextProperty($caption); $bar->caption->Align('left', 'center'); $this->graph->Add($bar); }
// match the weekend settings ... $graph->scale->hour->SetFontColor($styles->val('image.session.header.color', 'black', true)); $graph->scale->hour->SetBackgroundColor($styles->val('image.session.header.bgcolor', 'lightyellow:1.5', true)); $graph->scale->hour->SetFont(constant($styles->val('image.session.font', 'FF_FONT0', true))); $graph->scale->hour->SetIntervall($styles->val('image.session.interval', 2, true)); $graph->scale->hour->SetStyle(constant($styles->val('image.session.header.hourstyle', 'HOURSTYLE_H24', true))); /** $graph->scale->actinfo->SetBackgroundColor('lightyellow:1.5'); $graph->scale->actinfo->SetFont(FF_FONT0); $graph->scale->actinfo->SetColTitles(array("")); /**/ $show = (bool) $styles->val('image.session.hgrid.show', true, true); $graph->hgrid->Show($show); if ($show) { $graph->hgrid->SetRowFillColor($styles->val('image.session.hgrid.color1', 'whitesmoke@0.9', true), $styles->val('image.session.hgrid.color2', 'darkblue@0.9', true)); } for ($i = 0; $i < count($data); ++$i) { $bar = new GanttBar($data[$i][0], $data[$i][1], $data[$i][2], $data[$i][3]); $bar->SetPattern(constant($styles->val('image.session.bar.pattern', 'BAND_RDIAG', true)), $styles->val('image.session.bar.patternfill', 'lightblue', true)); $bar->SetFillColor($styles->val('image.session.bar.fill', 'BAND_SOLID', true)); $shadow = $styles->val('image.session.bar.shadow', '', true); if ($shadow) { $bar->SetShadow(true, $shadow); } $graph->Add($bar); } $graph->SetVMarginFactor($styles->val('image.session.bar.vmargin', 0.4, true)); if ($styles->val('image.session.showfooter', 'image.common.footer.show')) { stdImgFooter($graph); } $graph->Stroke();
public function graficar($filename) { $graph = new GanttGraph(); $graph->SetShadow(); $graph->SetBox(); // Only show part of the Gantt $graph = new GanttGraph(1000); /* $graph->title->Set('Proceso '.$this->dataSource->getParameter('desc_proceso_macro')."\n". 'Seguimiento de Solicitud '.$this->dataSource->getParameter('numero')."\n". 'Unidad '.$this->dataSource->getParameter('desc_uo')); $graph->title->SetFont(FF_ARIAL,FS_BOLD,6); */ define('UTF-8', $locale_char_set); // Setup some "very" nonstandard colors $graph->SetMarginColor('lightgreen@0.8'); $graph->SetBox(true, 'yellow:0.6', 2); $graph->SetFrame(true, 'darkgreen', 4); $graph->scale->divider->SetColor('yellow:0.6'); $graph->scale->dividerh->SetColor('yellow:0.6'); // Explicitely set the date range // (Autoscaling will of course also work) // Display month and year scale with the gridlines $graph->ShowHeaders(GANTT_HMONTH | GANTT_HYEAR | GANTT_HDAY); $graph->scale->month->grid->SetColor('gray'); $graph->scale->month->grid->Show(true); $graph->scale->year->grid->SetColor('gray'); $graph->scale->year->grid->Show(true); // Setup a horizontal grid $graph->hgrid->Show(); $graph->hgrid->SetRowFillColor('darkblue@0.9'); // Setup activity info // For the titles we also add a minimum width of 100 pixels for the Task name column $graph->scale->actinfo->SetColTitles(array('Tipo', 'Estado', 'Responsable', 'Duracion', 'Inicio', 'Fin'), array(40, 100)); $graph->scale->actinfo->SetBackgroundColor('green:0.5@0.5'); $graph->scale->actinfo->SetFont(FF_ARIAL, FS_NORMAL, 10); $data = array(); $dataset = $this->dataSource->getDataset(); $tamanioDataset = count($dataset); $fechaInicio = 0; $fechaFin = 0; for ($i = 0; $i < $tamanioDataset; $i++) { if ($i == 0) { $fechaInicio = $dataset[$i]['fecha_reg']; } /* if($dataset[$i]['nombre_estado']=='En_Proceso'||$dataset[$i]['nombre_estado']=='Habilitado para pagar'||$dataset[$i]['nombre_estado']=='En Pago'){ $milestone = new MileStone($i,$dataset[$i]['nombre_estado'],$dataset[$i]['fecha_reg'],$dataset[$i]['fecha_reg']); $milestone->title->SetColor("black"); $milestone->title->SetFont(FF_FONT1,FS_BOLD); $graph->Add($milestone); continue; } */ $actividad = array(); array_push($actividad, $i); if ($i == $tamanioDataset - 1) { $fechaFin = $dataset[$i]['fecha_reg']; } else { $fechaFin = $dataset[$i + 1]['fecha_reg']; } $startLiteral = new DateTime($dataset[$i]['fecha_reg']); $endLiteral = new DateTime($fechaFin); $start = strtotime($dataset[$i]['fecha_reg']); $end = strtotime($fechaFin); $days_between = round(($end - $start) / 86400); $cabecera = array($dataset[$i]['proceso'], $dataset[$i]['estado'], $dataset[$i]['funcionario'] != '-' ? $dataset[$i]['func'] : $dataset[$i]['depto'], "{$days_between}" . ' dias', $startLiteral->format('d M Y'), $endLiteral->format('d M Y')); array_push($actividad, $cabecera); array_push($actividad, $dataset[$i]['fecha_reg']); array_push($actividad, $fechaFin); array_push($actividad, FF_ARIAL); array_push($actividad, FS_NORMAL); array_push($actividad, 8); array_push($data, $actividad); } // Create the bars and add them to the gantt chart for ($i = 0; $i < count($data); $i++) { $bar = new GanttBar($data[$i][0], $data[$i][1], $data[$i][2], $data[$i][3], "[100%]", 10); if (count($data[$i]) > 4) { $bar->title->SetFont($data[$i][4], $data[$i][5], $data[$i][6]); } $bar->SetPattern(BAND_RDIAG, "yellow"); $bar->SetFillColor("gray"); $bar->progress->Set(1); $bar->progress->SetPattern(GANTT_SOLID, "darkgreen"); $graph->Add($bar); } //$graph->SetDateRange($fechaInicio,$fechaFin); $archivo = dirname(__FILE__) . '/../../../reportes_generados/' . $filename; //$graph->StrokeCSIM(); //exit; $graph->Stroke($archivo); }
/** * @param $task Task * @param $start_date string * @param $end_date string * @param $position * @return GanttBar * * Create a Gantt bar that represents a task with subtasks, this gives it 'wings' at each end to * represent it spanning the subtasks. * $start_date and $end_date should be YYYY-MM-DD formatted dates */ private function makeGroup(Task $task, $start_date, $end_date, $position) { $bar = new GanttBar($position, $task->name, $start_date, $end_date, $task->getField('duration')->formatted, 8); $bar->rightMark->Show(); $bar->rightMark->SetType(MARK_RIGHTTRIANGLE); $bar->rightMark->SetWidth(8); $bar->rightMark->SetColor('#0077BD'); $bar->rightMark->SetFillColor('#0077BD'); $bar->leftMark->Show(); $bar->leftMark->SetType(MARK_LEFTTRIANGLE); $bar->leftMark->SetWidth(8); $bar->leftMark->SetColor('#0077BD'); $bar->leftMark->SetFillColor('#0077BD'); $bar->setColor('#0077BD'); $bar->SetPattern(BAND_SOLID, '#0077BD'); return $bar; }
function prj_drawProjectTasksGanttBar(&$graph, &$row, &$count, $pid = 0, $nameIndent = '', $tid = 0, $sampleCounting = 0, $sm, $stm) { global $_TABLES, $_CONF, $showMonitor, $showTeamMember, $userid, $_PRJCONF, $filterCSV; $sql = 'SELECT tid,name,start_date, estimated_end_date,parent_task, progress, progress_id '; $sql .= "FROM {$_TABLES['prj_tasks']} "; if ($pid == 0) { $sql .= 'WHERE pid=0 '; } else { $sql .= "WHERE pid='{$pid}' "; } $sql .= "and parent_task={$tid} "; if ($filterCSV != '') { $sql .= "AND {$_TABLES['prj_tasks']}.pid in ({$filterCSV}) "; } $sql .= ' ORDER BY lhs ASC'; $result = DB_query($sql, true); $testnumrows = DB_numRows($result); if ($testnumrows == 0) { //this is to help overcome any COOKIE issues with the filtercsv $sql = 'SELECT tid,name,start_date, estimated_end_date,parent_task, progress, progress_id '; $sql .= "FROM {$_TABLES['prj_tasks']} "; if ($pid == 0) { $sql .= 'WHERE pid=0 '; } else { $sql .= "WHERE pid='{$pid}' "; } $sql .= "and parent_task={$tid} "; $sql .= ' ORDER BY lhs ASC'; $result = DB_query($sql); } for ($j = 0; $j < DB_numrows($result); $j++) { list($tid, $name, $startdate, $enddate, $parent_task, $progress, $status) = DB_fetchArray($result); $permsArray = prj_getProjectPermissions($pid, $userid, $tid); $ownertoken = getTaskToken($tid, $userid, "{$_TABLES['prj_task_users']}", "{$_TABLES['prj_tasks']}"); if ($sm == '1' && $stm == '1') { // all projects if ($permsArray['monitor'] == '1' || $permsArray['teammember'] == '1' || $ownertoken != 0) { $name = html_entity_decode($name); $strdate = strftime("%Y/%m/%d", $startdate); $edate = strftime("%Y/%m/%d", $enddate); $sql = "SELECT c.fullname "; $sql .= "FROM {$_TABLES['prj_task_users']} a "; $sql .= "INNER JOIN {$_TABLES['prj_tasks']} b on a.tid=b.tid "; $sql .= "INNER JOIN {$_TABLES['users']} c on a.uid=c.uid "; $sql .= "WHERE a.role='o' AND a.tid={$tid} "; $result2 = DB_query($sql); list($owner) = DB_fetchArray($result2); $link = $_CONF['site_url'] . "/nexproject/viewproject.php?mode=view&id=" . $tid; $count = $count + 1; if (strlen($name) > $_PRJCONF['project_name_length']) { $name = substr($name, 0, $_PRJCONF['project_name_length']); $name .= "..."; } $name = $nameIndent . $name; if ($strdate == $edate) { $milestone = new Milestone($row, $name, $strdate); $milestone->mark->SetType(MARK_DIAMOND); $graph->Add($milestone); } else { $taskActivity = new GanttBar($count, $name, "{$strdate}", "{$edate}", ""); if ($status == 0) { // Yellow diagonal line pattern on a red background $taskActivity->SetPattern(BAND_RDIAG, "green"); $taskActivity->progress->SetPattern(GANTT_RDIAG, "black"); $taskActivity->progress->SetFillColor("white"); } elseif ($status == 1) { $taskActivity->SetPattern(BAND_RDIAG, "yellow"); $taskActivity->progress->SetPattern(GANTT_RDIAG, "black"); $taskActivity->progress->SetFillColor("white"); } else { $taskActivity->SetPattern(BAND_RDIAG, "red"); $taskActivity->progress->SetPattern(GANTT_RDIAG, "black"); $taskActivity->progress->SetFillColor("white"); } $taskActivity->caption->SetFont(FF_FONT1, FS_NORMAL, 10); $taskActivity->caption->SetColor('black'); $taskActivity->caption->Set($name); // Set absolute height $taskActivity->SetHeight(10); $taskActivity->progress->Set($progress / 100); // Specify progress $taskActivity->SetCSIMTarget("{$link}"); $taskActivity->SetCSIMAlt($progress . "% completed"); $tempval = $_GET['expanded']; $tempval2 = $_SERVER['PHP_SELF']; $taskActivity->title->SetCSIMTarget(""); $taskActivity->title->SetCSIMAlt($progress . "% completed"); $qconstraints = DB_query("SELECT tid FROM {$_TABLES['prj_tasks']} WHERE parent_task='{$tid}' ORDER BY lhs ASC"); $numconstraints = DB_numRows($qconstraints); for ($c = 1; $c <= $numconstraints; $c++) { //$taskActivity->SetConstrain($row+$c,CONSTRAIN_STARTSTART,"maroon4"); } // Add line to Gantt Chart if (!$sampleCounting) { $graph->Add($taskActivity); } } $row++; } } else { // my projects if ($ownertoken != 0) { $name = html_entity_decode($name); $strdate = strftime("%Y/%m/%d", $startdate); $edate = strftime("%Y/%m/%d", $enddate); $sql = "SELECT c.fullname "; $sql .= "FROM {$_TABLES['prj_task_users']} a "; $sql .= "INNER JOIN {$_TABLES['prj_tasks']} b on a.tid=b.tid "; $sql .= "INNER JOIN {$_TABLES['users']} c on a.uid=c.uid "; $sql .= "WHERE a.role='o' AND a.tid={$tid}"; $result2 = DB_query($sql); list($owner) = DB_fetchArray($result2); $link = $_CONF['site_url'] . "/nexproject/viewproject.php?mode=view&id=" . $tid; $count = $count + 1; if (strlen($name) > $_PRJCONF['project_name_length']) { $name = substr($name, 0, $_PRJCONF['project_name_length']); $name .= "..."; } $name = $nameIndent . $name; if ($strdate == $edate) { $milestone = new Milestone($row, $name, $strdate); $milestone->mark->SetType(MARK_DIAMOND); $graph->Add($milestone); } else { $taskActivity = new GanttBar($count, $name, "{$strdate}", "{$edate}", ""); if ($status == 0) { // Yellow diagonal line pattern on a red background $taskActivity->SetPattern(BAND_RDIAG, "green"); $taskActivity->progress->SetPattern(GANTT_RDIAG, "black"); $taskActivity->progress->SetFillColor("white"); } elseif ($status == 1) { $taskActivity->SetPattern(BAND_RDIAG, "yellow"); $taskActivity->progress->SetPattern(GANTT_RDIAG, "black"); $taskActivity->progress->SetFillColor("white"); } else { $taskActivity->SetPattern(BAND_RDIAG, "red"); $taskActivity->progress->SetPattern(GANTT_RDIAG, "black"); $taskActivity->progress->SetFillColor("white"); } $taskActivity->caption->SetFont(FF_FONT1, FS_NORMAL, 10); $taskActivity->caption->SetColor('black'); $taskActivity->caption->Set($name); // Set absolute height $taskActivity->SetHeight(10); $taskActivity->progress->Set($progress / 100); // Specify progress $taskActivity->SetCSIMTarget("{$link}"); $taskActivity->SetCSIMAlt($progress . "% completed"); $tempval = $_GET['expanded']; $tempval2 = $_SERVER['PHP_SELF']; $taskActivity->title->SetCSIMTarget(""); $taskActivity->title->SetCSIMAlt($progress . "% completed"); $qconstraints = DB_query("SELECT tid FROM {$_TABLES['prj_tasks']} WHERE parent_task='{$tid}' ORDER BY lhs ASC"); $numconstraints = DB_numRows($qconstraints); for ($c = 1; $c <= $numconstraints; $c++) { //$taskActivity->SetConstrain($row+$c,CONSTRAIN_STARTSTART,"maroon4"); } // Add line to Gantt Chart if (!$sampleCounting) { $graph->Add($taskActivity); } } $row++; } } if (DB_count($_TABLES['prj_tasks'], 'parent_task', $tid) > 0) { prj_drawProjectTasksGanttBar($graph, $row, $count, $pid, $nameIndent . " ", $tid, $sampleCounting, $sm, $stm); } } //end for }
function ganttPDF($reportName, $listTasks) { include "../includes/jpgraph/jpgraph.php"; include "../includes/jpgraph/jpgraph_gantt.php"; $graph = new GanttGraph(); $graph->SetBox(); $graph->SetMarginColor("white"); $graph->SetColor("white"); $graph->title->Set($strings["project"] . " " . $reportName); // $graph->subtitle->Set("(".$strings["created"].": "..")"); $graph->title->SetFont(FF_FONT1); $graph->SetColor("white"); $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK); $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY); $graph->scale->week->SetFont(FF_FONT0); $graph->scale->year->SetFont(FF_FONT1); $comptListTasks = count($listTasks->tas_id); $posGantt = 0; for ($i = 0; $i < $comptListTasks; $i++) { $listTasks->tas_name[$i] = str_replace('"', '"', $listTasks->tas_name[$i]); $listTasks->tas_name[$i] = str_replace("'", "'", $listTasks->tas_name[$i]); $progress = round($listTasks->tas_completion[$i] / 10, 2); $printProgress = $listTasks->tas_completion[$i] * 10; $activity = new GanttBar($posGantt, $listTasks->tas_pro_name[$i] . " / " . $listTasks->tas_name[$i], $listTasks->tas_start_date[$i], $listTasks->tas_due_date[$i]); $activity->SetPattern(BAND_LDIAG, "yellow"); $activity->caption->Set($listTasks->tas_mem_login[$i] . " (" . $printProgress . "%)"); $activity->SetFillColor("gray"); if ($listTasks->tas_priority[$i] == "4" || $listTasks->tas_priority[$i] == "5") { $activity->progress->SetPattern(BAND_SOLID, "#BB0000"); } else { $activity->progress->SetPattern(BAND_SOLID, "#0000BB"); } $activity->progress->Set($progress); $graph->Add($activity); // begin if subtask $tmpquery = "WHERE task = " . $listTasks->tas_id[$i]; $listSubTasks = new request(); $listSubTasks->openSubtasks($tmpquery); $comptListSubTasks = count($listSubTasks->subtas_id); if ($comptListSubTasks >= 1) { // list subtasks for ($j = 0; $j < $comptListSubTasks; $j++) { $listSubTasks->subtas_name[$j] = str_replace('"', '"', $listSubTasks->subtas_name[$j]); $listSubTasks->subtas_name[$j] = str_replace("'", "'", $listSubTasks->subtas_name[$j]); $progress = round($listSubTasks->subtas_completion[$j] / 10, 2); $printProgress = $listSubTasks->subtas_completion[$j] * 10; $posGantt += 1; // $activity = new GanttBar($posGantt,$listTasks->tas_pro_name[$i]." / ".$listSubTasks->subtas_name[$j],$listSubTasks->subtas_start_date[$j],$listSubTasks->subtas_due_date[$j]); // change name of project for name of parent task $activity = new GanttBar($posGantt, $listSubTasks->subtas_tas_name[$j] . " / " . $listSubTasks->subtas_name[$j], $listSubTasks->subtas_start_date[$j], $listSubTasks->subtas_due_date[$j]); //$activity = new GanttBar($j,$strings["project"].": ".$listSubTasks->subtas_pro_name[$j]." / ".$strings["task"].": ".$listSubTasks->subtas_name[$j],$listSubTasks->subtas_start_date[$j],$listSubTasks->subtas_due_date[$j]); $activity->SetPattern(BAND_LDIAG, "yellow"); $activity->caption->Set($listSubTasks->subtas_mem_login[$j] . " (" . $printProgress . "%)"); $activity->SetFillColor("gray"); if ($listSubTasks->subtas_priority[$j] == "4" || $listSubTasks->subtas_priority[$j] == "5") { $activity->progress->SetPattern(BAND_SOLID, "#BB0000"); } else { $activity->progress->SetPattern(BAND_SOLID, "#0000BB"); } $activity->progress->Set($progress); $graph->Add($activity); } // end for comptListSubTasks } // end if subtask $posGantt += 1; } // end for complisttask $tmpGantt = "../files/" . md5(uniqid(rand())); $graph->Stroke($tmpGantt); return $tmpGantt; }
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_gantt.php'; $graph = new GanttGraph(); $graph->SetShadow(); // Add title and subtitle $graph->title->Set('A main title'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12); $graph->subtitle->Set('(Draft version)'); // Show day, week and month scale $graph->ShowHeaders(GANTT_HDAY | GANTT_HWEEK | GANTT_HMONTH); // Instead of week number show the date for the first day in the week // on the week scale $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY); // Make the week scale font smaller than the default $graph->scale->week->SetFont(FF_FONT0); // Use the short name of the month together with a 2 digit year // on the month scale $graph->scale->month->SetStyle(MONTHSTYLE_SHORTNAMEYEAR2); // Format the bar for the first activity // ($row,$title,$startdate,$enddate) $activity = new GanttBar(0, 'Activity 1', '2001-12-21', '2002-01-18'); // Yellow diagonal line pattern on a red background $activity->SetPattern(BAND_LDIAG, 'yellow'); $activity->SetFillColor('red'); // Finally add the bar to the graph $graph->Add($activity); // ... and display it $graph->Stroke();
/** * Executes ganttChart action * */ public function executeGanttChart() { //@todo change color according to status, and add a legend $this->forward404Unless($project = ProjectPeer::retrieveBySlug($this->getRequestParameter('project'))); $w = 450; $graph = new sfJpGraph('gantt', 0, 0); $graph = $graph->getJpGraph(); $graph->SetShadow(); // Add title and subtitle $graph->title->Set($project->getTitle()); //$graph->title-> SetFont( FF_ARIAL, FS_BOLD,12); $graph->subtitle->Set("(Gantt Chart)"); // Show day, week and month scale $graph->ShowHeaders(GANTT_HDAY | GANTT_HWEEK | GANTT_HMONTH); // Instead of week number show the date for the first day in the week // on the week scale $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY); // Make the week scale font smaller than the default $graph->scale->week->SetFont(FF_FONT0); // Use the short name of the month together with a 2 digit year // on the month scale $graph->scale->month->SetStyle(MONTHSTYLE_SHORTNAMEYEAR2); // Use the short name of the month together with a 4 digit year // on the month scale $graph->scale->month->SetStyle(MONTHSTYLE_SHORTNAMEYEAR4); //$graph->scale-> month-> SetTextColor( "white"); $graph->scale->month->SetBackgroundColor("blue"); $row = 0; foreach ($project->getTasks() as $task) { $activity = new GanttBar($row, $task->getName(), $task->getBegin('Y-m-d'), $task->getFinish('Y-m-d')); $activity->SetPattern(BAND_RDIAG, "red"); $activity->setFillColor("blue"); // Finally add the bar to the graph $graph->Add($activity); $row++; } // ... and display it $graph->Stroke(); }
$caption .= " (no end date)"; } else { $cap = ""; } if ($showLabels) { $caption .= $t['project_name'] . " (" . $t['perc_assignment'] . "%)"; // $caption .= $p['project_active'] <> 0 ? $AppUI->_('active') : $AppUI->_('inactive'); } if ($t["task_milestone"] != 1) { $enddate = new CDate($end); $startdate = new CDate($start); $bar = new GanttBar($row++, array($name, $startdate->format($df), $enddate->format($df), " "), $start, $actual_end, $cap, 0.6); // $bar->progress->Set($progress/100); $bar->title->SetFont(FF_FONT1, FS_NORMAL, 10); $bar->SetFillColor("#" . $t['project_color_identifier']); $bar->SetPattern(BAND_SOLID, "#" . $t['project_color_identifier']); //adding captions $bar->caption = new TextProperty($caption); $bar->caption->Align("left", "center"); } else { $bar = new MileStone($row++, $name, $start, substr($start, 0, 10)); $bar->title->SetColor("#CC0000"); } $graph2->Add($bar); // If showAllGant checkbox is checked } } // End of check for valid projects array. $today = date("y-m-d"); $vline = new GanttVLine($today, $AppUI->_('Today', UI_OUTPUT_RAW)); $graph->Add($vline);
$pattern = 'orange'; // Not Started break; case 3: $pattern = 'green'; // Open break; case 4: $pattern = 'yellow'; // Suspended break; default: $pattern = 'yellow'; // default color } $activity->SetPattern(BAND_RDIAG, $pattern); $activity->caption->Set($listTasks->tas_mem_login[$i] . ' (' . $printProgress . '%)'); $activity->caption->SetFont(FF_FONT0); $activity->SetFillColor($pattern); if ($listTasks->tas_priority[$i] == 4 || $listTasks->tas_priority[$i] == 5) { $activity->progress->SetPattern(BAND_SOLID, 'red'); } else { $activity->progress->SetPattern(BAND_SOLID, 'darkred'); } $activity->progress->Set($progress); $graph->Add($activity); } else { // build a milestone $ms_cnt++; $ms = new MileStone($i, $listTasks->tas_name[$i], $listTasks->tas_start_date[$i], 'M' . $ms_cnt); $ms->title->SetFont(FF_FONT1, FS_BOLD);
function grafica($fecha_max, $fecha_min, $datos) { $graph = new GanttGraph(); $graph->title->Set(""); // Rango de fechas a presentar $graph->SetDateRange($fecha_min, $fecha_max); // linea de espaciado vertical entre los elementos $graph->SetVMarginFactor(2); // configuracion de colores $graph->SetMarginColor('lightgreen@0.8'); // color del fondo $graph->SetBox(true, 'yellow:0.6', 2); // contorno del marco interior $graph->SetFrame(true, 'darkgreen', 4); // contorno del marco exterior $graph->scale->divider->SetColor('yellow:0.6'); // linea divisora de datos y grafico $graph->scale->dividerh->SetColor('red:0.6'); //liena que divide el tiempo con las barras de la grafica // Ponemos la medida de tiempo que queremos usar, por ejemplo años, meses, dias, hors o minutos //por ejemplo, si queremos solamente la division por meses y semanas en lugar de tener //GANTT_HWEEK | GANTT_HMONTH | GANTT_HYEAR | GANTT_HDAY //dejamos //GANTT_HWEEK | GANTT_HMONTH // para mas opciones de division de tiempo ver comentarios abajo $graph->ShowHeaders(GANTT_HWEEK | GANTT_HMONTH | GANTT_HYEAR | GANTT_HDAY); $graph->scale->month->grid->SetColor('gray'); //lineas verticales que dividen los meses $graph->scale->month->grid->Show(true); $graph->scale->year->grid->SetColor('gray'); // linea verticales que dividen los años $graph->scale->year->grid->Show(true); $graph->scale->actinfo->SetColTitles(array('Acción', 'Duracion', 'Inicio', 'Final', 'Porcentaje'), array(30, 100)); $graph->scale->actinfo->SetBackgroundColor('blue:0.5@0.5'); //color de fondo de los titulos de la tabla $graph->scale->actinfo->SetFont(FF_ARIAL, FS_NORMAL, 12); //tipografia // division vertical de los datos a la izquierda, posibles valores 'solid', 'dotted', 'dashed' $graph->scale->actinfo->vgrid->SetStyle('solid'); $graph->scale->actinfo->vgrid->SetColor('red'); // color de las divisiones puestas en el renglon anterior // Configuración de los iconos que queremos usar //para poner algun icono no definido podemos usarlo de la siguiente manera //$icon = new IconImage("imagen.png",0.7); //en el ejemplo estoy usando una omagen desde blogspot //el numero que es el segundo parametro de IconImage es el porcentaje de la imagen, en este caso esta al 20% $erricon = new IconImage("logo-copia.png", 0.2); $startconicon = new IconImage(GICON_FOLDEROPEN, 0.6); $endconicon = new IconImage(GICON_TEXTIMPORTANT, 0.5); //ahora ponemos los datos de la tabla e iniciamos los datos de las barras // $data = array( // //valores del arreglo: // //indice del arreglo, arreglo de datos para la informacion a la izquierda, fecha de inicio de la barra, fecha final de la barra, tipografia, estilo,tamaño tipografia,% de progreso en la barra // array(0,array("Pre-study","17 days","1 Nov '2011","1 Mar '2012") // , "2011-11-01","2012-01-1",FF_ARIAL,FS_NORMAL,8, 0.5),//el 0.5 indica el 50%, que ocuparemos en la linea 74, dando su posicion en el arreglo // array(1,array("Prototype","10 days","26 Oct '2011","16 Nov '2011"), // "2011-10-26","2011-11-01",FF_ARIAL,FS_NORMAL,8, 0.12), // array(2,array("Report","12 days","1 Mar '2012","13 Mar '2012"), // "2012-03-01","2012-03-13",FF_ARIAL,FS_NORMAL,8, 1) // ); $data = $datos; // Crea las barras y las añade a la grafica gantt for ($i = 0; $i < count($data); ++$i) { $bar = new GanttBar($data[$i][0], $data[$i][1], $data[$i][2], $data[$i][3], '', 10); if (count($data[$i]) > 4) { $bar->title->SetFont($data[$i][4], $data[$i][5], $data[$i][6]); } $bar->SetPattern(BAND_RDIAG, "yellow"); $bar->SetFillColor("gray"); $bar->progress->Set($data[$i][7]); // ocupamos el % de adelanto en la actividad $bar->progress->SetPattern(GANTT_SOLID, "darkgreen"); //$bar->title->SetCSIMTarget(array('#1'.$i,'#2'.$i,'#3'.$i,'#4'.$i,'#5'.$i),array('11'.$i,'22'.$i,'33'.$i)); $graph->Add($bar); //echo "<br>--> ".$data[$i][7]; } // Creamos la imagen y le damos nombre, la imagen se guarda donde estan estos archivos $graph->Stroke('imagenprueba.jpg'); }
$graph->scale->day->SetSundayFontColor('black'); $graph->scale->hour->SetFont(FF_FONT1); $graph->scale->hour->SetIntervall(1); $graph->scale->hour->SetStyle(HOURSTYLE_H24); $graph->hgrid->SetRowFillColor('whitesmoke@0.9', 'darkblue@0.9'); $graph->setMargin(0, 0, 0, 20); $graph->scale->hour->SetFont(FF_FONT1); $graph->scale->day->SetFont(FF_FONT1, FS_BOLD); $graph->title->SetColor('white'); $graph->scale->UseWeekendBackground(false); $graph->scale->day->SetWeekendColor('lightyellow:1.5'); $graph->scale->week->SetFont(FF_FONT1); $graph->hgrid->Show(true); $graph->hgrid->SetRowFillColor('whitesmoke@0.9', 'darkblue@0.9'); if ($suma > 0) { for ($i = 0; $i < count($data); ++$i) { $bar = new GanttBar($data[$i][0], $data[$i][1], $data[$i][2], $data[$i][3]); $bar->SetPattern(BAND_RDIAG, 'lightgray'); $bar->SetFillColor('brown'); $bar->SetShadow(true, 'black@0.5'); $graph->Add($bar); } } else { $bar = new GanttBar(0, $text["noactivity"], "23:59", "00:00"); $bar->SetPattern(BAND_RDIAG, 'white@1'); $graph->Add($bar); } $graph->footer->left->Set($text["totalingame"] . " " . formatTD($suma)); $graph->footer->left->SetColor('black@0.5'); $graph->footer->left->SetFont(FF_FONT2, FS_BOLD); $graph->Stroke();
/** * creates the image for the gantt chart * * @param $_params array containing projectdata, start- and enddate * @param $_filename filename for the image, if empty image gets printed to browser * @author Lars Kneschke / Bettina Gille * @returns nothing - writes image to disk */ function show_graph($params, $_filename = '') { $modernJPGraph = false; // no gd support if (!function_exists('imagecopyresampled')) { return false; } DEFINE("TTF_DIR", PHPGW_SERVER_ROOT . "/projects/ttf-bitstream-vera-1.10/"); if (file_exists(PHPGW_SERVER_ROOT . '/../jpgraph/src/jpgraph.php')) { include PHPGW_SERVER_ROOT . '/../jpgraph/src/jpgraph.php'; include PHPGW_SERVER_ROOT . '/../jpgraph/src/jpgraph_gantt.php'; } else { include PHPGW_SERVER_ROOT . '/projects/inc/jpgraph-1.5.2/src/jpgraph.php'; include PHPGW_SERVER_ROOT . '/projects/inc/jpgraph-1.5.2/src/jpgraph_gantt.php'; } //_debug_array($params); $project_array = $params['project_array']; $sdate = $params['sdate']; $edate = $params['edate']; $showMilestones = $params['showMilestones']; $showResources = $params['showResources']; $bocalendar = CreateObject('calendar.bocalendar'); $this->graph = CreateObject('phpgwapi.gdgraph', $this->debug); $bolink = CreateObject('infolog.bolink'); //$this->boprojects->order = 'parent'; $this->boprojects->limit = False; $this->boprojects->html_output = False; if (is_array($project_array)) { $projects = array(); foreach ($project_array as $pro) { $project = $this->boprojects->list_projects(array('action' => 'mainsubsorted', 'project_id' => $pro, 'mstones_stat' => True)); if (is_array($project)) { $i = count($projects); for ($k = 0; $k < count($project); $k++) { $projects[$i + $k] = $project[$k]; } } } } if (is_array($projects)) { $modernJPGraph = version_compare('1.13', JPG_VERSION); $sdate = $sdate + 60 * 60 * $GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']; $sdateout = $GLOBALS['phpgw']->common->show_date($sdate, $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); $edate = $edate + 60 * 60 * $GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']; $edateout = $GLOBALS['phpgw']->common->show_date($edate, $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); # $this->graph->title = lang('Gantt chart from %1 to %2',$sdateout,$edateout); // Standard calls to create a new graph if ($modernJPGraph) { $graph = new GanttGraph(940, -1, "auto"); } else { $graph = new GanttGraph(-1, -1, "auto"); } $graph->SetShadow(); $graph->SetBox(); $duration = $edate - $sdate; if ($duration < 5958000) { $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK); if ($modernJPGraph) { $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAYWNBR); } else { $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY); } } elseif ($duration < 13820400) { $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY); $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HWEEK); } else { $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH); } // For the week we choose to show the start date of the week // the default is to show week number (according to ISO 8601) #$graph->scale->SetDateLocale('de_DE'); // Change the scale font $graph->scale->week->SetFont(FF_VERA, FS_NORMAL, 8); $graph->scale->year->SetFont(FF_VERA, FS_BOLD, 10); // Titles for chart $graph->title->Set(lang('project overview')); $graph->subtitle->Set(lang('from %1 to %2', $sdateout, $edateout)); $graph->title->SetFont(FF_VERA, FS_BOLD, 12); $graph->subtitle->SetFont(FF_VERA, FS_BOLD, 10); // set the start and end date // add one day to the end is needed internaly by jpgraph $graph->SetDateRange(date('Y-m-d 00:00:00', $sdate), date('Y-m-d', $edate + 86400)); foreach ($projects as $pro) { $ptime_pro = $this->boprojects->return_value('ptime', $pro[project_id]); $acc = $this->boprojects->get_budget(array('project_id' => $pro[project_id], 'ptime' => $ptime_pro)); if ($ptime_pro > 0) { $finnishedPercent = 100 / $ptime_pro * $acc[uhours_jobs_wminutes]; } else { $finnishedPercent = 0; } $previous = ''; if ($pro['previous'] > 0) { $previous = $this->boprojects->read_single_project($pro['previous']); $spro[] = array('title' => str_repeat(' ', $spro['level']) . '[!]' . $previous['title'], 'extracolor' => 'darkorange', 'sdate' => $previous['sdate'], 'edate' => $previous['edate'], 'pro_id' => $previous['project_id'], 'f_sdate' => $pro['sdate']); $color_legend['previous'] = array('title' => '[!]' . lang('previous project'), 'extracolor' => 'darkorange'); } // add a empty row before new project if ($pro['level'] == 0 && $counter > 0) { $counter++; } $spro = array('title' => $pro['title'], 'sdate' => $pro['sdate'], 'edate' => $pro['edate'] ? $pro['edate'] : mktime(0, 0, 0, date('m'), date('d'), date('Y')), 'color' => $pro['level'], 'pro_id' => $pro['project_id'], 'previous' => $pro['previous']); // convert title to iso-8859-1 $spro[title] = $this->botranslation->convert($spro[title], $this->displayCharset, 'iso-8859-1'); if ($spro[edate] < $sdate) { continue; } if ($spro[edate] > $edate) { $spro[edate] = $edate; } if ($spro[sdate] < $sdate) { $spro[sdate] = $sdate; } $bar = new GanttBar($counter, $spro[title], date('Y-m-d', $spro[sdate]), date('Y-m-d', $spro[edate]), round($finnishedPercent) . '%', 0.5); // mark beginn of new project bold if ($pro['level'] == 0) { $bar->title->SetFont(FF_VERA, FS_BOLD, 9); #$bar->title->SetColor("#9999FF"); $bar->SetPattern(BAND_SOLID, "#9999FF"); } else { // For illustration lets make each bar be red with yellow diagonal stripes $bar->SetPattern(BAND_SOLID, "#ccccFF"); #$bar->title->SetColor("#ccccFF"); } // To indicate progress each bar can have a smaller bar within // For illustrative purpose just set the progress to 50% for each bar $bar->progress->SetHeight(0.2); $bar->SetColor('#777777'); if ($finnishedPercent > 100) { $bar->progress->Set(1); #$bar->progress->SetPattern(GANTT_SOLID,"darkred",98); $bar->caption->SetColor("red"); } else { $bar->progress->Set($finnishedPercent / 100); #$bar->progress->SetPattern(GANTT_SOLID,"darkgreen",98); } $bar->caption->SetFont(FF_VERA, FS_NORMAL, 8); // ... and add the bar to the gantt chart $graphs['bars'][] = $bar; #$graph->Add($bar); $counter++; // check for Resources if ($showResources == 'true') { $linkedObjects = $bolink->get_links('projects', $pro[project_id]); $projectACL = $this->boprojects->get_acl_for_project($pro[project_id]); if (is_array($projectACL)) { // if beginn foreach ($projectACL as $accountID) { #_debug_array($projectData); $accountData = CreateObject('phpgwapi.accounts', $accountID); $accountData->read_repository(); $accountName = $GLOBALS['phpgw']->common->display_fullname($accountData->data['account_lid'], $accountData->data['firstname'], $accountData->data['lastname']); $calData = array('syear' => date('Y', $sdate), 'smonth' => date('m', $sdate), 'sday' => date('d', $sdate), 'eyear' => date('Y', $edate), 'emonth' => date('m', $edate), 'eday' => date('d', $edate), 'owner' => array($accountID)); $calEntries = $bocalendar->store_to_cache($calData); $bocalendar->remove_doubles_in_cache(date('Y', $sdate) . date('m', $sdate) . date('d', $sdate), date('Y', $edate) . date('m', $edate) . date('d', $edate)); $calEntries = $bocalendar->cached_events; #_debug_array($calEntries); if (is_array($calEntries) && count($calEntries)) { #_debug_array($calEntries); foreach ($calEntries as $calDayDate => $calDayEntries) { foreach ($calDayEntries as $calDayEntry) { if ($calDayEntry['recur_type']) { $bocalendar->set_recur_date($calDayEntry, $calDayDate); } #_debug_array($calDayEntry); if (!$bocalendar->rejected_no_show($calDayEntry)) { $startDate = date('Y-m-d H:i:s', mktime($calDayEntry['start']['hour'], $calDayEntry['start']['min'], $calDayEntry['start']['sec'], $calDayEntry['start']['month'], $calDayEntry['start']['mday'], $calDayEntry['start']['year'])); $endDate = date('Y-m-d H:i:s', mktime($calDayEntry['end']['hour'], $calDayEntry['end']['min'], $calDayEntry['end']['sec'], $calDayEntry['end']['month'], $calDayEntry['end']['mday'], $calDayEntry['end']['year'])); #$endDate = $startDate+1000; #_debug_array($startDate); $bar = new GanttBar($counter, str_repeat(' ', $pro['level'] + 1) . $accountName, $startDate, $endDate, '', 0.5); $bar->SetPattern(BAND_SOLID, "#DDDDDD"); $bar->SetColor('#CCCCCC'); #$bar->SetShadow(true,"darkgray"); if (count($projectLinks = $bolink->get_links('calendar', $calDayEntry['id'], 'projects'))) { $projectLinks = array_flip($projectLinks); #_debug_array($projectLinks); if (isset($projectLinks[$pro[project_id]])) { $bar->SetPattern(BAND_SOLID, "#33FF33"); $bar->SetColor('#33FF33'); } } $graphs['bars'][] = $bar; #$graph->Add($bar); } else { print "rejected<br>"; } } } $counter++; } } } // if end } // check for milstones if (is_array($pro['mstones']) && $showMilestones == 'true') { $msColor = "#999999"; foreach ($pro['mstones'] as $ms) { if ($sdate < $ms['edate'] && $ms['edate'] <= $edate) { $ms[title] = $this->botranslation->convert($ms[title], $this->displayCharset, 'iso-8859-1'); $msData = array('title' => $ms['title'], 'extracolor' => 'yellow', 'edate' => $ms['edate'], 'pro_id' => $pro['project_id']); // Create a milestone mark $ms = new MileStone($counter, str_repeat(' ', $pro['level'] + 1) . lang('Milestone'), date('Y-m-d', $msData['edate']), $msData['title']); $ms->caption->SetFont(FF_VERA, FS_NORMAL, 8); $ms->title->SetFont(FF_VERA, FS_NORMAL, 8); $ms->mark->SetColor($msColor); $ms->mark->SetFillColor('#EEEEEE'); $graphs['ms'][$counter] = $ms; // Create a vertical line to emphasize the milestone $vl = new GanttVLine(date('Y-m-d', $msData[edate]), '', $msColor, 2); $vl->SetDayOffset(0.5); // Center the line in the day $graphs['vl'][$counter] = $vl; $counter++; } } } } // add the vertical lines if (is_array($graphs['vl'])) { foreach ($graphs['vl'] as $graphCounter => $graphPointer) { $graph->Add($graphPointer); } } // add the milestones if (is_array($graphs['ms'])) { foreach ($graphs['ms'] as $graphCounter => $graphPointer) { $graph->Add($graphPointer); } } // add the resources if (is_array($graphs['bars'])) { foreach ($graphs['bars'] as $graphCounter => $graphPointer) { $graph->Add($graphPointer); } } #$graph->Stroke(PHPGW_SERVER_ROOT . SEP . 'phpgwapi' . SEP . 'images' . SEP . 'draw_tmp.png'); $graph->Stroke($_filename); } }
function graph_schedule($data, $title, $show_day) { require_once "jpgraph/jpgraph.php"; require_once "jpgraph/jpgraph_gantt.php"; // Some sample Gantt data /* $data = array( array(0, " Bryce", "2009-08-28 11:00","2009-08-28 15:30"), array(1, " Kyla", "2009-08-28 08:00","2009-08-28 15:30"), array(2, " Nathan", "2009-08-28 08:00","2009-08-28 17:00") ); */ // Basic graph parameters $graph = new GanttGraph(700); $graph->SetMarginColor('darkgreen@0.8'); $graph->SetColor('white'); $graph->title->Set("{$title}'s Schedule"); $graph->title->SetColor('darkgray'); // We want to display day, hour and minute scales if ($show_day) { $graph->ShowHeaders(GANTT_HDAY | GANTT_HHOUR); } else { $graph->ShowHeaders(GANTT_HHOUR); } #$graph->ShowHeaders(GANTT_HDAY | GANTT_HHOUR); #$graph->ShowHeaders(GANTT_HHOUR); // Setup day format $graph->scale->day->SetBackgroundColor('lightyellow:1.5'); $graph->scale->day->SetStyle(DAYSTYLE_LONG); $graph->scale->day->SetFont(FF_FONT1, FS_NORMAL, 16); // Setup hour format $graph->scale->hour->SetIntervall(1); $graph->scale->hour->SetBackgroundColor('lightyellow:1.5'); $graph->scale->hour->SetStyle(HOURSTYLE_HAMPM); $graph->scale->hour->grid->SetColor('gray:0.8'); $graph->scale->hour->SetFont(FF_FONT1, FS_NORMAL, 13); for ($i = 0; $i < count($data); ++$i) { $bar = new GanttBar($data[$i][0], $data[$i][1], $data[$i][2], $data[$i][3], $data[$i][4]); $bar->SetPattern(BAND_RDIAG, "yellow"); $bar->SetFillColor("gray"); $graph->Add($bar); } // Draw graph $graph->Stroke(); }
public function addBar(array $columnValues, $caption = '', $height = '0.6', $barcolor = 'FFFFFF', $active = true, $progress = 0, $identifier = 0) { foreach ($columnValues as $name => $value) { switch ($name) { case 'start_date': $start = $value; $startDate = new w2p_Utilities_Date($value); $rowValues[] = $startDate->format($this->df); break; case 'end_date': $endDate = new w2p_Utilities_Date($value); $rowValues[] = $endDate->format($this->df); break; case 'actual_end': if ('' == $value) { $actual_end = $columnValues['end_date']; $rowValues[] = $value; } else { $actual_end = $value; $actual_endDate = new w2p_Utilities_Date($value); $rowValues[] = $actual_endDate->format($this->df); } break; default: $rowValues[] = $value; } } $bar = new GanttBar($this->rowCount++, $rowValues, $start, $actual_end, $caption, $height); $this->rowMap[$identifier] = $this->rowCount; $bar->progress->Set(min($progress / 100, 1)); $bar->title->SetFont(FF_CUSTOM, FS_NORMAL, 10); $bar->title->SetColor(bestColor('#ffffff', '#' . $barcolor, '#000000')); $bar->SetFillColor('#' . $barcolor); $bar->SetPattern(BAND_SOLID, '#' . $barcolor); if (0.1 == $height) { $bar->rightMark->Show(); $bar->rightMark->SetType(MARK_RIGHTTRIANGLE); $bar->rightMark->SetWidth(3); $bar->rightMark->SetColor('black'); $bar->rightMark->SetFillColor('black'); $bar->leftMark->Show(); $bar->leftMark->SetType(MARK_LEFTTRIANGLE); $bar->leftMark->SetWidth(3); $bar->leftMark->SetColor('black'); $bar->leftMark->SetFillColor('black'); $bar->SetPattern(BAND_SOLID, 'black'); $bar->title->SetFont(FF_CUSTOM, FS_BOLD, 9); } //adding captions $bar->caption = new TextProperty($caption); $bar->caption->Align('left', 'center'); if (is_file(TTF_DIR . 'FreeSans.ttf')) { $bar->caption->SetFont(FF_CUSTOM, FS_NORMAL, 8); } // gray out templates, completes, on ice, on hold if (!$active) { $bar->caption->SetColor('darkgray'); $bar->title->SetColor('darkgray'); $bar->SetColor('darkgray'); $bar->SetFillColor('gray'); $bar->progress->SetFillColor('darkgray'); $bar->progress->SetPattern(BAND_SOLID, 'darkgray', 98); } $this->graph->Add($this->addDependencies($bar, $identifier)); }
function CreateSimple($data, $constrains = array(), $progress = array()) { $num = count($data); for ($i = 0; $i < $num; ++$i) { switch ($data[$i][1]) { case ACTYPE_GROUP: // Create a slightly smaller height bar since the // "wings" at the end will make it look taller $a = new GanttBar($data[$i][0], $data[$i][2], $data[$i][3], $data[$i][4], '', 8); $a->title->SetFont($this->iSimpleFont, FS_BOLD, $this->iSimpleFontSize); $a->rightMark->Show(); $a->rightMark->SetType(MARK_RIGHTTRIANGLE); $a->rightMark->SetWidth(8); $a->rightMark->SetColor('black'); $a->rightMark->SetFillColor('black'); $a->leftMark->Show(); $a->leftMark->SetType(MARK_LEFTTRIANGLE); $a->leftMark->SetWidth(8); $a->leftMark->SetColor('black'); $a->leftMark->SetFillColor('black'); $a->SetPattern(BAND_SOLID, 'black'); $csimpos = 6; break; case ACTYPE_NORMAL: $a = new GanttBar($data[$i][0], $data[$i][2], $data[$i][3], $data[$i][4], '', 10); $a->title->SetFont($this->iSimpleFont, FS_NORMAL, $this->iSimpleFontSize); $a->SetPattern($this->iSimpleStyle, $this->iSimpleColor); $a->SetFillColor($this->iSimpleBkgColor); // Check if this activity should have a constrain line $n = count($constrains); for ($j = 0; $j < $n; ++$j) { if (empty($constrains[$j]) || count($constrains[$j]) != 3) { JpGraphError::RaiseL(6003, $j); //("Invalid format for Constrain parameter at index=$j in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Constrain-To,Constrain-Type)"); } if ($constrains[$j][0] == $data[$i][0]) { $a->SetConstrain($constrains[$j][1], $constrains[$j][2], 'black', ARROW_S2, ARROWT_SOLID); } } // Check if this activity have a progress bar $n = count($progress); for ($j = 0; $j < $n; ++$j) { if (empty($progress[$j]) || count($progress[$j]) != 2) { JpGraphError::RaiseL(6004, $j); //("Invalid format for Progress parameter at index=$j in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Progress)"); } if ($progress[$j][0] == $data[$i][0]) { $a->progress->Set($progress[$j][1]); $a->progress->SetPattern($this->iSimpleProgressStyle, $this->iSimpleProgressColor); $a->progress->SetFillColor($this->iSimpleProgressBkgColor); //$a->progress->SetPattern($progress[$j][2],$progress[$j][3]); break; } } $csimpos = 6; break; case ACTYPE_MILESTONE: $a = new MileStone($data[$i][0], $data[$i][2], $data[$i][3]); $a->title->SetFont($this->iSimpleFont, FS_NORMAL, $this->iSimpleFontSize); $a->caption->SetFont($this->iSimpleFont, FS_NORMAL, $this->iSimpleFontSize); $csimpos = 5; break; default: die('Unknown activity type'); break; } // Setup caption $a->caption->Set($data[$i][$csimpos - 1]); // Check if this activity should have a CSIM target�? if (!empty($data[$i][$csimpos])) { $a->SetCSIMTarget($data[$i][$csimpos]); $a->SetCSIMAlt($data[$i][$csimpos + 1]); } if (!empty($data[$i][$csimpos + 2])) { $a->title->SetCSIMTarget($data[$i][$csimpos + 2]); $a->title->SetCSIMAlt($data[$i][$csimpos + 3]); } $this->Add($a); } }
function CreateSimple($data, $constrains = array(), $progress = array()) { $num = count($data); for ($i = 0; $i < $num; ++$i) { switch ($data[$i][1]) { case ACTYPE_GROUP: $a = new GanttBar($data[$i][0], $data[$i][2], $data[$i][3], $data[$i][4], '', 8); $a->title->SetFont($this->iSimpleFont, FS_BOLD, $this->iSimpleFontSize); $a->rightMark->Show(); $a->rightMark->SetType(MARK_RIGHTTRIANGLE); $a->rightMark->SetWidth(8); $a->rightMark->SetColor('black'); $a->rightMark->SetFillColor('black'); $a->leftMark->Show(); $a->leftMark->SetType(MARK_LEFTTRIANGLE); $a->leftMark->SetWidth(8); $a->leftMark->SetColor('black'); $a->leftMark->SetFillColor('black'); $a->SetPattern(BAND_SOLID, 'black'); $csimpos = 6; break; case ACTYPE_NORMAL: $a = new GanttBar($data[$i][0], $data[$i][2], $data[$i][3], $data[$i][4], '', 10); $a->title->SetFont($this->iSimpleFont, FS_NORMAL, $this->iSimpleFontSize); $a->SetPattern($this->iSimpleStyle, $this->iSimpleColor); $a->SetFillColor($this->iSimpleBkgColor); $n = count($constrains); for ($j = 0; $j < $n; ++$j) { if (empty($constrains[$j]) || count($constrains[$j]) != 3) { JpGraphError::RaiseL(6003, $j); } if ($constrains[$j][0] == $data[$i][0]) { $a->SetConstrain($constrains[$j][1], $constrains[$j][2], 'black', ARROW_S2, ARROWT_SOLID); } } $n = count($progress); for ($j = 0; $j < $n; ++$j) { if (empty($progress[$j]) || count($progress[$j]) != 2) { JpGraphError::RaiseL(6004, $j); } if ($progress[$j][0] == $data[$i][0]) { $a->progress->Set($progress[$j][1]); $a->progress->SetHeight(0.5); $a->progress->SetPattern($this->iSimpleProgressStyle, $this->iSimpleProgressColor); $a->progress->SetFillColor($this->iSimpleProgressBkgColor); break; } } $csimpos = 6; break; case ACTYPE_MILESTONE: $a = new MileStone($data[$i][0], $data[$i][2], $data[$i][3]); $a->title->SetFont($this->iSimpleFont, FS_NORMAL, $this->iSimpleFontSize); $a->caption->SetFont($this->iSimpleFont, FS_NORMAL, $this->iSimpleFontSize); $csimpos = 5; break; default: die('Unknown activity type'); break; } $a->caption->Set($data[$i][$csimpos - 1]); if (!empty($data[$i][$csimpos])) { $a->SetCSIMTarget($data[$i][$csimpos]); $a->SetCSIMAlt($data[$i][$csimpos + 1]); } if (!empty($data[$i][$csimpos + 2])) { $a->title->SetCSIMTarget($data[$i][$csimpos + 2]); $a->title->SetCSIMAlt($data[$i][$csimpos + 3]); } $this->Add($a); } }
// 0 % vertical label margin $graph->SetLabelVMarginFactor(1); // Format the bar for the first activity // ($row,$title,$startdate,$enddate) $activity = new GanttBar(0, "Project", "2001-12-21", "2002-01-07", "[50%]"); // Yellow diagonal line pattern on a red background $activity->SetPattern(BAND_RDIAG, "yellow"); $activity->SetFillColor("red"); // Set absolute height $activity->SetHeight(10); // Specify progress to 60% $activity->progress->Set(0.6); // Format the bar for the second activity // ($row,$title,$startdate,$enddate) $activity2 = new GanttBar(1, "Project", "2001-12-21", "2002-01-02", "[30%]"); // Yellow diagonal line pattern on a red background $activity2->SetPattern(BAND_RDIAG, "yellow"); $activity2->SetFillColor("red"); // Set absolute height $activity2->SetHeight(10); // Specify progress to 30% $activity2->progress->Set(0.3); // Finally add the bar to the graph $graph->Add($activity); $graph->Add($activity2); // Add a vertical line $vline = new GanttVLine("2001-12-24", "Phase 1"); $vline->SetDayOffset(0.5); //$graph->Add($vline); // ... and display it $graph->Stroke();
// Format the bar for the first activity // ($row,$title,$startdate,$enddate) $activity = new GanttBar(0, 'Project', '2001-12-21', '2002-01-07', '[50%]'); // Yellow diagonal line pattern on a red background $activity->SetPattern(BAND_RDIAG, 'yellow'); $activity->SetFillColor('red'); // Set absolute height $activity->SetHeight(10); // Specify progress to 60% $activity->progress->Set(0.6); $activity->progress->SetPattern(BAND_HVCROSS, 'blue'); // Format the bar for the second activity // ($row,$title,$startdate,$enddate) $activity2 = new GanttBar(1, 'Project', '2001-12-21', '2002-01-02', '[30%]'); // Yellow diagonal line pattern on a red background $activity2->SetPattern(BAND_RDIAG, 'yellow'); $activity2->SetFillColor('red'); // Set absolute height $activity2->SetHeight(10); // Specify progress to 30% $activity2->progress->Set(0.3); $activity2->progress->SetPattern(BAND_HVCROSS, 'blue'); // Finally add the bar to the graph $graph->Add($activity); $graph->Add($activity2); // Add a vertical line $vline = new GanttVLine('2001-12-24', 'Phase 1'); $vline->SetDayOffset(0.5); //$graph->Add($vline); // ... and display it $graph->Stroke();
$graph->scale->month->grid->SetColor('gray'); $graph->scale->month->grid->Show(true); $graph->scale->year->grid->SetColor('gray'); $graph->scale->year->grid->Show(true); // Setup activity info // For the titles we also add a minimum width of 100 pixels for the Task name column $graph->scale->actinfo->SetColTitles(array('Name', 'Duration', 'Start', 'Finish'), array(100)); $graph->scale->actinfo->SetBackgroundColor('green:0.5@0.5'); $graph->scale->actinfo->SetFont(FF_ARIAL, FS_NORMAL, 10); $graph->scale->actinfo->vgrid->SetStyle('solid'); $graph->scale->actinfo->vgrid->SetColor('gray'); // Data for our example activities $data = array(array(0, array("Pre-study", "102 days", "23 Nov '01", "1 Mar '02"), "2001-11-23", "2002-03-1", FF_ARIAL, FS_NORMAL, 8), array(1, array("Prototype", "21 days", "26 Oct '01", "16 Nov '01"), "2001-10-26", "2001-11-16", FF_ARIAL, FS_NORMAL, 8), array(2, array("Report", "12 days", "1 Mar '02", "13 Mar '02"), "2002-03-01", "2002-03-13", FF_ARIAL, FS_NORMAL, 8)); // Create the bars and add them to the gantt chart for ($i = 0; $i < count($data); ++$i) { $bar = new GanttBar($data[$i][0], $data[$i][1], $data[$i][2], $data[$i][3], "[50%]", 10); if (count($data[$i]) > 4) { $bar->title->SetFont($data[$i][4], $data[$i][5], $data[$i][6]); } $bar->SetPattern(BAND_RDIAG, "yellow"); $bar->SetFillColor("gray"); $bar->progress->Set(0.5); $bar->progress->SetPattern(GANTT_SOLID, "darkgreen"); $graph->Add($bar); } // Output the chart $graph->Stroke(); ?>
function gantt_chart($p_metrics, $p_title, $p_subtitle, $p_graph_width = 300, $p_graph_height = 380) { $t_graph_font = graph_get_font(); $t_metrics = $p_metrics['metrics']; $t_range = $p_metrics['range']; // Diff in weeks of the range: $t_60s = 60; // 1 minute $t_60min = 60; // 1 hour $t_24h = 24; // 1 day $t_7d = 7; // 1 week $t_minute = $t_60s; $t_hour = $t_60min * $t_minute; $t_day = $t_24h * $t_hour; $t_week = $t_7d * $t_day; $t_gantt_chart_max_rows = plugin_config_get('rows_max'); error_check(is_array($t_metrics) ? count($t_metrics) : 0, $p_title . " (" . $p_subtitle . ")"); if (plugin_config_get('eczlibrary') == ON) { // DO NOTHING SINCE eczlibrary DOES NOT SUPPORT GANTT CHART } else { // A new graph with automatic size $graph = new GanttGraph(0, 0, "auto"); $graph->SetShadow(); // Add title and subtitle $graph->title->Set($p_title); $graph->title->SetFont($t_graph_font, FS_BOLD, 12); $graph->subtitle->Set($p_subtitle); // Show day, week and month scale $graph->ShowHeaders(GANTT_HDAY | GANTT_HWEEK | GANTT_HMONTH); // Instead of week number show the date for the first day in the week // on the week scale $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY); // Make the week scale font smaller than the default $graph->scale->week->SetFont($t_graph_font, FS_NORMAL, 8); // Use the short name of the month together with a 2 digit year // on the month scale $graph->scale->month->SetStyle(MONTHSTYLE_SHORTNAMEYEAR4); $graph->scale->month->SetFontColor("white"); $graph->scale->month->SetBackgroundColor("blue"); // Setup a horizontal grid $graph->hgrid->Show(); $graph->hgrid->SetRowFillColor('darkblue@0.9'); // Setup a vertical grid // $graph->vgrid->Show(); //Setup the divider display $graph->scale->divider->SetWeight(3); $graph->scale->divider->SetColor("darkblue"); $graph->scale->dividerh->SetWeight(3); $graph->scale->dividerh->SetColor("darkblue"); $graph->scale->dividerh->Show(); $graph->scale->actinfo->vgrid->SetStyle('solid'); $graph->scale->actinfo->vgrid->SetColor('darkblue'); $graph->scale->actinfo->vgrid->Show(); // // Set the column headers and font // $graph->scale->actinfo->SetColTitles( array('Task','Start','End'),array(100)); // $graph->scale->actinfo->SetFont( $t_graph_font, FS_BOLD, 10 ); //Adding columns: //The following is an example: 1st element, an array of the columns, // 2nd element an optional array of min width of the columns (here the min width of the 2 first columns) //$graph->scale->actinfo->SetColTitles( // array('Note','Task','Duration','Start','Finish'),array(30,100)); //Adding a table title $graph->scale->tableTitle->Set("{$p_subtitle}"); $graph->scale->tableTitle->SetFont($t_graph_font, FS_NORMAL, 8); $graph->scale->SetTableTitleBackground('darkblue@0.6'); $graph->scale->tableTitle->Show(); // if ( null != $t_constrain ){ // $t_activity->SetConstrain( $t_constrain, CONSTRAIN_ENDSTART ); // } // if ( null != $t_constrain ){ // $t_activity->SetConstrain( $t_constrain['row'], $t_constrain['type'] ); // } // We first need to get the list of rows, in order to know whether to // display the constraint or not (in case of missing referenced row) $t_row_list = array(); foreach ($t_metrics as $t_metric_row) { $t_row_list[] = $t_metric_row[0]; } foreach ($t_metrics as $t_metric_row) { $t_row = $t_metric_row[0] % $t_gantt_chart_max_rows; $t_activity_type = $t_metric_row[1]; $t_bug_id = $t_metric_row[2]; $t_start_date = $t_metric_row[3]; $t_end_date = $t_metric_row[4]; $t_extra = " {$t_bug_id}" . $t_metric_row[5]; $t_level = $t_metric_row[6]; $t_constraints = $t_metric_row[7]; if (isset($t_level)) { $t_row_label = utf8_str_pad('', $t_level * 2, ' ') . htmlspecialchars_decode(bug_format_summary($t_bug_id, SUMMARY_FIELD)); } else { $t_row_label = htmlspecialchars_decode(bug_format_summary($t_bug_id, SUMMARY_FIELD)); } // Limit the label to max defined $t_row_label = strlen($t_row_label) > plugin_config_get('label_max') ? substr($t_row_label, 0, plugin_config_get('label_max') - 3) . '...' : $t_row_label; $t_activity_arr = array('left' => null, 'main' => array('row' => $t_row, 'label' => $t_row_label, 'start' => $t_start_date, 'end' => $t_end_date, 'info' => $t_extra), 'right' => null); if ($t_end_date < $t_range['min']) { // complete left bar // ** | o[ ]-[ ]o $t_activity_arr = array('left' => array('row' => $t_row, 'label' => $t_row_label, 'start' => $t_range['min'], 'end' => $t_range['min'], 'info' => "<- " . graph_date_format($t_start_date)), 'main' => null, 'right' => array('row' => $t_row, 'label' => "", 'start' => $t_range['min'] + $t_day, 'end' => $t_range['min'] + $t_day, 'info' => "<<- [" . graph_date_format($t_start_date) . " / " . graph_date_format($t_end_date) . "]" . $t_extra)); } else { if ($t_range['max'] < $t_start_date) { // complete right bar // o[ ]-[ ]o | ** $t_activity_arr = array('left' => array('row' => $t_row, 'label' => $t_row_label, 'start' => $t_range['max'] - $t_day, 'end' => $t_range['max'] - $t_day, 'info' => ""), 'main' => null, 'right' => array('row' => $t_row, 'label' => "", 'start' => $t_range['max'], 'end' => $t_range['max'], 'info' => "[" . graph_date_format($t_start_date) . " / " . graph_date_format($t_end_date) . "] ->>" . $t_extra)); } else { if ($t_start_date < $t_range['min']) { // left bar // * | o[ ]-[ ] $t_activity_arr['left'] = array('row' => $t_row, 'label' => '', 'start' => $t_range['min'], 'end' => $t_range['min'], 'info' => "<- " . graph_date_format($t_start_date)); $t_activity_arr['main']['start'] = $t_range['min'] + $t_day; //4 * $t_day;// @TODO: what happens if duration is less than that } if ($t_range['max'] < $t_end_date) { // right bar // [ ]-[ ]o | * $t_activity_arr['main']['end'] = $t_range['max'] - $t_day; //4 * $t_day; $t_activity_arr['main']['info'] = ""; $t_activity_arr['right'] = array('row' => $t_row, 'label' => "", 'start' => $t_range['max'], 'end' => $t_range['max'], 'info' => graph_date_format($t_end_date) . " ->" . $t_extra); } } } switch ($t_activity_type) { case ACTYPE_NORMAL: if (null != $t_activity_arr['left']) { $t_activity_left = new GanttBar($t_activity_arr['left']['row'], $t_activity_arr['left']['label'], graph_date_format($t_activity_arr['left']['start']), graph_date_format($t_activity_arr['left']['end']), $t_activity_arr['left']['info']); // Add a left marker $t_activity_left->leftMark->Show(); $t_activity_left->leftMark->SetType(MARK_FILLEDCIRCLE); $t_activity_left->leftMark->SetWidth(8); // $t_activity_left->leftMark->SetColor( 'red' ); $t_activity_left->leftMark->SetFillColor('red'); $t_activity_left->leftMark->title->Set(''); $t_activity_left->leftMark->title->SetFont($t_graph_font, FS_NORMAL, 8); $t_activity_left->leftMark->title->SetColor('white'); if (null != gantt_get_resolution_date($t_bug_id)) { $t_activity_left->SetPattern(BAND_RDIAG, get_status_color(bug_get_field($t_bug_id, 'status'))); } $t_activity_left->SetFillColor(get_status_color(bug_get_field($t_bug_id, 'status'))); } if (null != $t_activity_arr['main']) { $t_activity_main = new GanttBar($t_activity_arr['main']['row'], $t_activity_arr['main']['label'], graph_date_format($t_activity_arr['main']['start']), graph_date_format($t_activity_arr['main']['end']), $t_activity_arr['main']['info']); if (null != gantt_get_resolution_date($t_bug_id)) { $t_activity_main->SetPattern(BAND_RDIAG, get_status_color(bug_get_field($t_bug_id, 'status'))); } $t_activity_main->SetFillColor(get_status_color(bug_get_field($t_bug_id, 'status'))); $t_activity_main->title->SetFont($t_graph_font, FS_NORMAL, 8); // Set the constraint if any... foreach ($t_constraints as $t_constraint) { // ... and if possible if (in_array($t_constraint['row'], $t_row_list)) { $t_activity_main->SetConstrain($t_constraint['row'], $t_constraint['type']); } } $graph->add($t_activity_main); } if (null != $t_activity_arr['right']) { $t_activity_right = new GanttBar($t_activity_arr['right']['row'], $t_activity_arr['right']['label'], graph_date_format($t_activity_arr['right']['start']), graph_date_format($t_activity_arr['right']['end']), $t_activity_arr['right']['info']); // Add a left marker $t_activity_right->rightMark->Show(); $t_activity_right->rightMark->SetType(MARK_FILLEDCIRCLE); $t_activity_right->rightMark->SetWidth(8); $t_activity_right->rightMark->SetColor('red'); $t_activity_right->rightMark->SetFillColor('red'); $t_activity_right->rightMark->title->Set(''); $t_activity_right->rightMark->title->SetFont($t_graph_font, FS_NORMAL, 8); $t_activity_right->rightMark->title->SetColor('white'); if (null != gantt_get_resolution_date($t_bug_id)) { $t_activity_right->SetPattern(BAND_RDIAG, get_status_color(bug_get_field($t_bug_id, 'status'))); } $t_activity_right->SetFillColor(get_status_color(bug_get_field($t_bug_id, 'status'))); } if (isset($t_activity_left)) { $graph->add($t_activity_left); } if (isset($t_activity_right)) { $graph->add($t_activity_right); } break; case ACTYPE_MILESTONE: $t_size = 5; if ($t_start_date < $t_range['min']) { $t_extra = "(<-- " . graph_date_format($t_start_date) . ")" . $t_extra; $t_start_date = $t_range['min']; $t_size = 8; } else { if ($t_range['max'] < $t_start_date) { $t_extra = "(--> " . graph_date_format($t_start_date) . ")" . $t_extra; $t_start_date = $t_range['max']; $t_size = 8; } } $t_milestone = new MileStone($t_row, $t_row_label, graph_date_format($t_start_date), $t_extra); $t_milestone->title->SetFont($t_graph_font, FS_NORMAL, 8); $t_milestone->mark->SetType(MARK_FILLEDCIRCLE); $t_milestone->mark->SetWidth($t_size); if (5 != $t_size) { $t_milestone->mark->SetFillColor('red'); } // foreach( $t_constraints as $t_constraint){ // $t_milestone->SetConstrain( $t_constraint['row'], $t_constraint['type'] ); // } $graph->add($t_milestone); break; } } // Setting the min and max date: $t_minmax = $graph->GetBarMinMax(); $t_week_in_seconds = 7 * 24 * 3600; // 1 week offset min: if ($t_minmax[0] - $t_week_in_seconds > 0) { $t_graph_offset_min = $t_minmax[0] - $t_week_in_seconds; } else { $t_graph_offset_min = $t_minmax[0]; } // 2 weeks offset max: $t_graph_offset_max = $t_minmax[1] + 3 * $t_week_in_seconds; $graph->SetDateRange(graph_date_format($t_graph_offset_min), graph_date_format($t_graph_offset_max)); // Add a vertical line for today if in the range of GetBarMinMax() (retruns an arry ($min, $max) ): $t_minmax = $graph->GetBarMinMax(); $t_now = date(config_get('short_date_format')); if ($t_now >= graph_date_format($t_graph_offset_min) && $t_now <= graph_date_format($t_graph_offset_max)) { $t_today = new GanttVLine($t_now, "Today", "darkred", 2, "solid"); $t_today->SetDayOffset(0.5); $graph->add($t_today); } // $t_today = new GanttVLine( "2011-03-01" , "" , "darkred", 2, "solid");// // $t_today->SetDayOffset(0.5); // $graph->add( $t_today ); $t_gantt_chart_height = gantt_chart_get_height($graph); $t_legend = gantt_chart_legend(false); $t_legend_height = 60; // Display the Gantt chart // $graph->Stroke(); //-------------------------------------- // Create a combined graph //-------------------------------------- $mgraph = new MGraph(); $mgraph->Add($graph, 0, 0); $mgraph->Add($t_legend, 0, $t_gantt_chart_height + $t_legend_height); $mgraph->Stroke(); } }