Ejemplo n.º 1
0
 private function createBarGraph($xdata, $data1, $ytitle)
 {
     // Create the graph.
     $graph = new Graph($this->width, $this->height, "auto");
     $graph->SetScale("textlin");
     $graph->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->SetFrame(false);
     if ($this->shadow) {
         $graph->SetShadow();
     }
     // Create the bar plot
     $arrPos = array();
     $arrNeg = array();
     foreach ($data1 as &$value) {
         if ($value >= 0) {
             array_push($arrPos, $value);
             array_push($arrNeg, 0);
         } else {
             array_push($arrPos, 0);
             array_push($arrNeg, $value);
         }
     }
     $bplotPos = new BarPlot($arrPos);
     // First group positive
     $bplotPos->SetFillColor('#ababab');
     // color for positive '#ababab' Kulturplanner #8aa571
     $bplotNeg = new BarPlot($arrNeg);
     // second group negative
     $bplotNeg->SetFillColor("#cc00cc");
     //color for negative prologiq "#cc00cc"
     $gbplot = new AccBarPlot(array($bplotPos, $bplotNeg));
     $gbplot->value->Show();
     $gbplot->value->SetFormat('%d');
     $gbplot->value->SetColor("black");
     $gbplot->SetValuePos('center');
     //$gbplot->SetLegend(Prado::localize($this->legend));
     // ... and add it to the graph
     $graph->Add($gbplot);
     $graph->xaxis->title->Set($this->title);
     $graph->xaxis->SetTickLabels($xdata);
     $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->yaxis->title->Set($ytitle);
     $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->yaxis->SetLabelMargin(5);
     $graph->yaxis->scale->SetGrace(10);
     $graph->yaxis->HideZeroLabel();
     $graph->ygrid->SetFill(true, '#f2f2f2@0.6', '#cacaca@0.6');
     return $graph;
 }