Example #1
0
<?php

// content="text/plain; charset=utf-8"
// Gantt hour example
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_gantt.php';
$graph = new GanttGraph();
$graph->SetMarginColor('blue:1.7');
$graph->SetColor('white');
$graph->SetBackgroundGradient('navy', 'white', GRAD_HOR, BGRAD_MARGIN);
$graph->scale->hour->SetBackgroundColor('lightyellow:1.5');
$graph->scale->hour->SetFont(FF_FONT1);
$graph->scale->day->SetBackgroundColor('lightyellow:1.5');
$graph->scale->day->SetFont(FF_FONT1, FS_BOLD);
$graph->title->Set("Example of hours in scale");
$graph->title->SetColor('white');
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 14);
$graph->ShowHeaders(GANTT_HDAY | GANTT_HHOUR);
$graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
$graph->scale->week->SetFont(FF_FONT1);
$graph->scale->hour->SetIntervall(4);
$graph->scale->hour->SetStyle(HOURSTYLE_HM24);
$graph->scale->day->SetStyle(DAYSTYLE_SHORTDAYDATE3);
$data = array(array(0, "  Label 1", "2001-01-26 04:00", "2001-01-26 14:00"), array(1, "  Label 2", "2001-01-26 10:00", "2001-01-26 18:00"), array(2, "  Label 3", "2001-01-26", "2001-01-27 10:00"));
for ($i = 0; $i < count($data); ++$i) {
    $bar = new GanttBar($data[$i][0], $data[$i][1], $data[$i][2], $data[$i][3], "[5%]", 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("red");
Example #2
0
  /**
   *Make Gantt
   *@return image png & die
   */        
  function MakeGanttChart(){
      // is logged ?     
      if (!logged_user()->isProjectUser(active_project())) {
        die; 
      } // if
      // is user can view this project ??
      if (!ProjectFile::canView(logged_user(), active_project())) {
        die;
      } //if

      /*
      * Init gantt graph
      */
      $width = 850;      
      $graph = new GanttGraph($width);
      /*
      * here header must be set at end and during process catch all date to determine the difference max between start and end 
      * to present HDAY or not depend on information volume
      */
      //graph header
      $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HWEEK | GANTT_HDAY);
      // Instead of week number show the date for the first day in the week
      // on the week scale
      $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
      $graph->SetMarginColor('blue:1.7');
      $graph->SetColor('white');
      $graph->SetBackgroundGradient('#60A2BA','white',GRAD_HOR,BGRAD_MARGIN);
      //$graph->SetBackgroundGradient('#A01010','white',GRAD_HOR,BGRAD_MARGIN);
      $graph->title->SetColor('white');
      $graph->title->SetFont(FF_FONT2,FS_BOLD,18);
      //$graph->scale->actinfo->SetColTitles(array('Act','Duration','Start','Finish','Resp'));
      $graph->scale->actinfo->SetStyle(ACTINFO_3D);
      $graph->scale->actinfo->SetFont(FF_ARIAL,FS_NORMAL,10);
      $graph->scale->actinfo->vgrid->SetColor('gray');
      $graph->scale->actinfo->SetColor('darkgray');
      $locale_char_set = 'utf-8';
      //For french support
      //Localization::instance()->getLocale();
      //if (preg_match('/' . Localization::instance()->getLocale() . '/i', 'fr_fr')) $graph->scale->SetDateLocale("fr_FR.utf8");

      /*
      * data jpgraph construction gantt type for project
      */    
      $project = active_project();
      //Project title
      $project_name = $project->getName();
      $graph->title->Set(lang('project') . ': ' . substr(utf8_decode($project_name),0,40) );

      $rows = $this->displayProjectGantt($project, $graph, 0);
      $subprojects = $project->getSubprojects();
      if (is_array($subprojects)) {
        foreach($subprojects as $subproject) {
          $rows = $this->displayProjectGantt($subproject, $graph, $rows++);
        }
      }

      //send data
      $type = "image/png";
      $name = "projectpiergantt.png";
      header("Content-Type: $type");
      header("pragma: no-cache");
      header("Content-Disposition: attachment; filename=\"$name\"");
      $graph->Stroke();
      die(); //end process do not send other informations
  }  //MakeGantt