[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/telephonie/stats/graph/ -> bar.class.php (source)

   1  <?PHP
   2  /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   *
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program is distributed in the hope that it will be useful,
  10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   * GNU General Public License for more details.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: bar.class.php,v 1.8 2005/11/14 08:35:36 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/stats/graph/bar.class.php,v $
  20   *
  21   */
  22  
  23  require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/graph.class.php");
  24  
  25  class GraphBar extends DolibarrGraph {
  26  
  27    Function GraphBar($DB, $file)
  28    {
  29      $this->db = $DB;
  30      $this->file = $file;
  31      $this->bgcolor = "#DEE7EC";
  32      $this->barcolor = "green";
  33      $this->client = 0;
  34      $this->showframe = true;
  35    }
  36    
  37    Function GraphDraw($file, $datas, $labels)
  38    {
  39      // Create the graph. These two calls are always required
  40  
  41      $height = 240;
  42      $width = 320;
  43  
  44      if ($this->width <> $width && $this->width > 0)
  45        $width = $this->width;
  46      
  47      if ($this->height <> $height && $this->height > 0)
  48        $height = $this->height;
  49  
  50      if (sizeof($datas) && sizeof($labels))
  51        {
  52      $graph = new Graph($width, $height,"auto");    
  53      $graph->SetScale("textlin");
  54  
  55      $graph->yaxis->scale->SetGrace(20);
  56  
  57      $graph->SetFrame($this->showframe);
  58      
  59      $graph->img->SetMargin(50,20,20,35);
  60      
  61      if ($this->type == 'LinePlot')
  62        {
  63          $b2plot = new LinePlot($datas);
  64        }
  65      else
  66        {
  67          $b2plot = new BarPlot($datas);
  68        }
  69  
  70      $b2plot->SetFillColor($this->barcolor);
  71      
  72      $graph->xaxis->scale->SetGrace(20);
  73      /*
  74      $LabelAngle = 0;
  75  
  76      if ($this->LabelAngle <> $LabelAngle && strlen($this->LabelAngle) > 0)
  77        $LabelAngle = $this->LabelAngle;
  78  
  79      if ($this->LabelAngle > 0)
  80        {
  81          $graph->xaxis->SetLabelAngle($LabelAngle);
  82          $graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,7);
  83        }
  84      */
  85      $graph->title->Set($this->titre);
  86          $graph->xaxis->SetTickLabels($labels);
  87      //$graph->title->SetFont(FF_VERDANA,FS_NORMAL);
  88  
  89      if (!$this->no_xaxis_title)
  90        {
  91      $graph->xaxis->title->Set(strftime("%d/%m/%y %H:%M:%S", time()));
  92        }
  93  
  94      $graph->Add($b2plot);
  95  
  96      // Display the graph
  97      
  98      $graph->img->SetImgFormat("png");
  99      $graph->Stroke($file);
 100        }
 101      else
 102        {
 103      // Setup a basic canvas we can work
 104      $g = new CanvasGraph($width,$height,'auto');
 105      $g->SetMargin(5,11,6,11);
 106      $g->SetShadow();
 107      $g->SetMarginColor("teal");
 108      
 109      // We need to stroke the plotarea and margin before we add the
 110      // text since we otherwise would overwrite the text.
 111      //$g->InitFrame();
 112  
 113      // Draw a text box in the middle
 114      $txt = "Données manquantes !";
 115      $t = new Text($txt,ceil($width / 2),ceil($height/2));
 116      //$t->SetFont(FF_VERDANA, FS_BOLD, 10);
 117      
 118      // How should the text box interpret the coordinates?
 119      $t->Align('center','top');
 120      $t->SetBox("white","black","gray");    
 121      $t->ParagraphAlign('center');
 122      
 123      // Stroke the text
 124      $t->Stroke($g->img);
 125      
 126      // Stroke the graph
 127      $g->Stroke($file);
 128        }
 129    }
 130  }   
 131  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics