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

survey/classes/class.SurveyChart.php

Go to the documentation of this file.
00001 <?php
00002 require_once ("phplot/phplot.php");
00003 
00004 class SurveyChart
00005 {
00006         //IlliasCharts constructor
00007         /*
00008         * $GraphTyp = "bars" or "lines"
00009         */
00010 
00011         var $graph;
00012         var $graphData;
00013         function SurveyChart($GraphTyp,$XSize,$YSize,$Titel,$XLabel,$YLabel,$DataArray)
00014         {
00015                 $this->graphData = array();
00016                 $this->graph = new PHPlot($XSize,$YSize);
00017                 switch ($GraphTyp)
00018                 {
00019                         case "pie":
00020                                 $this->graph->SetDataType("text-data-single");
00021                                 break;
00022                         default:
00023                                 $this->graph->SetDataType("text-data");
00024                                 break;
00025                 }
00026                 $this->graph->SetPlotType($GraphTyp);
00027                 $this->graph->SetTitle($Titel);
00028                 $this->graph->SetXTitle($XLabel);
00029                 $this->graph->SetYTitle($YLabel);
00030                 $this->graph->SetXDataLabelPos("plotdown");
00031                 $this->makeDataForOneQuestion($DataArray, $GraphTyp);
00032                 $this->graph->SetDataValues($this->graphData);
00033                 $this->draw();
00034         }
00035 
00036         function makeDataForOneQuestion($Data, $GraphTyp)
00037         {
00038                 foreach ($Data as $value)
00039                 {
00040                         if (array_key_exists("title", $value))
00041                         {
00042                                 switch ($GraphTyp)
00043                                 {
00044                                         case "pie":
00045                                                 array_push($this->graphData, array($value["title"], $value["selected"], ""));
00046                                                 break;
00047                                         default:
00048                                                 array_push($this->graphData, array($value["title"], $value["selected"]));
00049                                                 break;
00050                                 }
00051                         }
00052                         else
00053                         {
00054                                 array_push($this->graphData, array($value["value"], $value["selected"]));
00055                         }
00056                 }
00057         }
00058 
00059         function draw()
00060         {
00061                 $this->graph->DrawGraph();
00062                 $this->graph->PrintImage();
00063         }
00064 }
00065 
00066 ?>

Generated on Fri Dec 13 2013 09:06:38 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1