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 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); } }
<?php // Gantt example include "../jpgraph.php"; include "../jpgraph_gantt.php"; // Create the basic graph $graph = new GanttGraph(); $graph->title->Set("Example with multiple constrains"); $bar1 = new GanttBar(0, "Label 1", "2003-06-08", "2003-06-12"); $bar2 = new GanttBar(1, "Label 2", "2003-06-16", "2003-06-19"); $bar3 = new GanttBar(2, "Label 3", "2003-06-15", "2003-06-21"); //create constraints $bar1->SetConstrain(1, CONSTRAIN_ENDSTART); $bar1->SetConstrain(2, CONSTRAIN_ENDSTART); // Setup scale $graph->ShowHeaders(GANTT_HDAY | GANTT_HWEEK); $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAYWNBR); // Add the specified activities $graph->Add($bar1); $graph->Add($bar2); $graph->Add($bar3); // .. and stroke the graph $graph->Stroke();
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); } }
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 prj_paintProjectBar($testMonitor, $pid, $name, $startdate, $enddate, $parent_task, $progress, $status, $expanded, $userid, $nameIndent, &$graph, &$count, &$row, $sm, $stm) { global $_TABLES, $_CONF, $_PRJCONF; $name = html_entity_decode($name); if (strlen($name) > $_PRJCONF['project_name_length']) { $name = substr($name, 0, $_PRJCONF['project_name_length']); $name .= "..."; } $strdate = strftime("%Y/%m/%d", $startdate); $edate = strftime("%Y/%m/%d", $enddate); $sql = 'SELECT c.fullname '; $sql .= "FROM {$_TABLES['prj_users']} a "; $sql .= "INNER JOIN {$_TABLES['prj_projects']} b on a.pid=b.pid "; $sql .= "INNER JOIN {$_TABLES['users']} c on a.uid=c.uid "; $sql .= "WHERE a.role='o' AND a.pid={$pid}"; $result2 = DB_query($sql); list($owner) = DB_fetchArray($result2); $link = $_CONF['site_url'] . "/nexproject/viewproject.php?pid=" . $pid; $count = $count + 1; $doesAnyoneDependOnMe = DB_count($_TABLES['prj_projects'], 'parent_id', $pid); if (array_keys($expanded, $pid) != array()) { $sign = '[-]'; } else { $sign = '[+]'; } if ($doesAnyoneDependOnMe == 0) { $sign = ''; } if ($strdate == $edate) { $milestone = new Milestone($row, "{$nameIndent}{$name} {$sign}", $strdate); $milestone->mark->SetType(MARK_DIAMOND); //$milestone->title->SetFont(FF_ARIAL,FS_BOLD,10); if ($sign != '') { $tempval2 = $_SERVER['PHP_SELF']; $milestone->title->SetCSIMTarget("javascript:projectGanttClick('{$pid}','{$sign}','{$tempval}', '{$gdate1}', '{$gdate2}', '{$tempval2}');"); } $graph->Add($milestone); } else { $activity = new GanttBar($count, "{$nameIndent}{$name} {$sign}", "{$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"); $tempval2 = $_SERVER['PHP_SELF']; if ($sign != '') { $activity->title->SetCSIMTarget("javascript:projectGanttClick('{$pid}','{$sign}','{$tempval}', '{$gdate1}', '{$gdate2}', '{$tempval2}');"); } //$activity->title->SetFont(FF_ARIAL,FS_NORMAL,9); $activity->title->SetCSIMAlt($progress . "% completed"); $qconstraints = DB_query("SELECT pid FROM {$_TABLES['prj_projects']} WHERE parent_id='{$pid}' ORDER BY lhs ASC"); $numconstraints = DB_numRows($qconstraints); if ($sign == '[-]') { for ($c = 1; $c <= $numconstraints; $c++) { list($testingThisPID) = DB_fetchArray($qconstraints); $tempPerms = prj_getProjectPermissions($testingThisPID, $userid); $tempOwner = getProjectToken($testingThisPID, $userid, "{$_TABLES['prj_users']}"); $buffer = 0; if (array_keys($expanded, $pid) != array() && DB_count($_TABLES['prj_projects'], 'parent_id', $pid) > 0) { if ($showTasksForExpandedProjects == 'true') { if ($testMonitor == false) { //my projects if ($tempPerms['teammember'] == '1' || $tempPerms['full'] == '1' || $tempOwner != 0) { prj_drawProjectTasksGanttBar($tmpg, $buffer, $tmpcount, $pid, $nameIndent, 0, 1, $sm, $stm); } } else { //all projects if ($tempPerms['monitor'] == '1' || $tempPerms['teammember'] == '1' || $tempPerms['full'] == '1' || $tempOwner != 0) { prj_drawProjectTasksGanttBar($tmpg, $buffer, $tmpcount, $pid, $nameIndent, 0, 1, $sm, $stm); } } } } if ($testMonitor == false) { if ($tempPerms['teammember'] == '1' || $tempPerms['full'] == '1' || $tempOwner == '1') { $activity->SetConstrain($row + $c + $buffer, CONSTRAIN_STARTSTART, "maroon4"); } } else { if ($tempPerms['monitor'] == '1' || $tempPerms['teammember'] == '1' || $tempPerms['full'] == '1' || $tempOwner == '1') { $activity->SetConstrain($row + $c + $buffer, CONSTRAIN_STARTSTART, "maroon4"); } } } //end for } //end if $sign==[-] // Add line to Gantt Chart $graph->Add($activity); } //end else $row++; }
$bar->setColor('gray'); $bar->SetFillColor('gray'); $bar->SetPattern(BAND_SOLID,'gray'); $bar->progress->SetFillColor('gray'); $bar->progress->SetPattern(BAND_SOLID,'gray',98); } */ $q->addTable('task_dependencies'); $q->addQuery('dependencies_task_id'); $q->addWhere('dependencies_req_task_id=' . $a['task_id']); $query = $q->loadList(); foreach ($query as $dep) { // find row num of dependencies for ($d = 0; $d < count($gts); $d++) { if ($gts[$d][0]['task_id'] == $dep['dependencies_task_id']) { $bar->SetConstrain($d, CONSTRAIN_ENDSTART); } } } unset($query); $q->clear(); $graph->Add($bar); } unset($gts); $today = date('y-m-d'); $vline = new GanttVLine($today, $AppUI->_('Today', UI_OUTPUT_RAW)); if ($monospacefont) { $vline->title->SetFont(FF_DEJAVUMONO, FS_BOLD, $printpdfhr == '1' ? 12 : 8); //16); //8); //specify the use of VeraMono } else { $vline->title->SetFont(FF_DEJAVU, FS_BOLD, $printpdfhr == '1' ? 12 : 8);
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); } } }
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(); } }