• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Modules/SurveyQuestionPool/classes/class.SurveyChart.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00033 class SurveyChart
00034 {
00035         var $graph;
00036         var $graphData;
00037         
00038         function SurveyChart($GraphTyp,$XSize,$YSize,$Titel,$XLabel,$YLabel,$DataArray)
00039         {
00040                 $this->graphData = array();
00041                 include_once ("./Modules/SurveyQuestionPool/phplot/phplot.php");
00042                 $this->graph = new PHPlot($XSize,$YSize);
00043                 switch ($GraphTyp)
00044                 {
00045                         case "pie":
00046                                 $this->graph->SetDataType("text-data-single");
00047                                 break;
00048                         default:
00049                                 $this->graph->SetDataType("text-data");
00050                                 break;
00051                 }
00052                 $this->graph->SetPlotType($GraphTyp);
00053                 if (strlen($Titel) > 40)
00054                 {
00055                         $this->graph->SetFont("title", "benjamingothic.ttf", 6);
00056                 }
00057                 if (strlen($Titel) > 80)
00058                 {
00059                         $Titel = substr($Titel, 0, 80) . "...";
00060                 }
00061                 $this->graph->SetTitle($Titel);
00062                 $this->graph->SetXTitle($XLabel);
00063                 $this->graph->SetYTitle($YLabel);
00064                 $this->graph->SetXDataLabelPos("plotdown");
00065                 $this->makeDataForOneQuestion($DataArray, $GraphTyp);
00066                 $max = 0;
00067                 foreach ($this->graphData as $value)
00068                 {
00069                         if ($value[1] > $max) $max = $value[1];
00070                 }
00071                 $this->graph->SetYTickIncrement(ceil($max / 4));
00072                 $this->graph->SetDataValues($this->graphData);
00073                 $this->graph->SetPlotAreaWorld(NULL, 0, NULL, NULL);
00074                 $this->draw();
00075         }
00076 
00077         function makeDataForOneQuestion($Data, $GraphTyp)
00078         {
00079                 foreach ($Data as $value)
00080                 {
00081                         if (array_key_exists("title", $value))
00082                         {
00083                                 switch ($GraphTyp)
00084                                 {
00085                                         case "pie":
00086                                                 array_push($this->graphData, array($value["title"], $value["selected"], ""));
00087                                                 break;
00088                                         default:
00089                                                 array_push($this->graphData, array($value["title"], $value["selected"]));
00090                                                 break;
00091                                 }
00092                         }
00093                         else
00094                         {
00095                                 array_push($this->graphData, array($value["value"], $value["selected"]));
00096                         }
00097                 }
00098         }
00099 
00100         function draw()
00101         {
00102                 $this->graph->DrawGraph();
00103                 $this->graph->PrintImage();
00104         }
00105 }
00106 
00107 ?>

Generated on Fri Dec 13 2013 17:56:52 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1