/** * 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(); }