Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 ?>