WHERE id_tournoi = 3'; $query = new Query($database, $sql); if ($query->execute()) { $teamsTMNF = $query->getResult()[0]['nbr']; } $sql = 'SELECT COUNT(*) AS nbr FROM equipes_tournoi WHERE id_tournoi = 5'; $query = new Query($database, $sql); if ($query->execute()) { $teamsHS = $query->getResult()[0]['nbr']; } $data1y = array($playersHOTS, $playersCOD4, $playersTMNF, $playersHS); $data2y = array($teamsHOTS, $teamsCOD4, $teamsTMNF, $teamsHS); // Create the graph. These two calls are always required $graph = new Graph(300, 250); $graph->ClearTheme(); $graph->SetShadow(); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->img->SetMargin(40, 30, 20, 40); // Create the bar plots $b1plot = new BarPlot($data1y); $b1plot->SetFillColor("#222C43"); $b1plot->SetLegend("Players"); $b2plot = new BarPlot($data2y); $b2plot->SetFillColor("#366797"); $b2plot->SetLegend("Teams"); // Create the grouped bar plot $gbplot = new GroupBarPlot(array($b1plot, $b2plot)); // ...and add it to the graPH $graph->Add($gbplot);
public function generateRevenueGraph(&$data, $time_frame) { if (count($data) > 0) { foreach ($data as $k => $o) { $datax[] = "{$k}"; $datay[] = $o['revenue']; } } else { $datax[] = 0; $datay[] = 0; } $graph_files = array('orders' => array('title' => "Revenue Figures Report", 'x-title' => $time_frame, 'y-title' => "Revenue", 'file' => ONXSHOP_PROJECT_DIR . "var/cache/graph-revenue-{$time_frame}.png")); $this->tpl->assign('GRAPH', $graph); // Create the graph. These two calls are always required $graph = new Graph(1000, 600, "auto"); $graph->ClearTheme(); $graph->SetScale("textlin"); $graph->yaxis->scale->SetGrace(5); // Add some grace to y-axis so the bars doesn't go // all the way to the end of the plot area $graph->xaxis->SetTickLabels($datax); $graph->xaxis->SetLabelAngle(50); // Create a bar pot $color = '#61a9f3'; $bplot = new BarPlot($datay); $bplot->value->SetFormat('£%0.0f'); $bplot->value->SetColor('#3968a4'); $bplot->SetColor($color); $bplot->SetFillColor($color); $bplot->value->Show(); $gbplot = new GroupBarPlot(array($bplot)); $graph->Add($gbplot); // Setup the titles $graph->title->Set($graph_files['orders']['title']); $graph->xaxis->title->Set($graph_files['orders']['x-title']); $graph->yaxis->title->Set($graph_files['orders']['y-title']); switch ($time_frame) { case 'month': $graph->yaxis->SetTitleMargin(45); $graph->img->SetMargin(65, 30, 20, 40); $bplot->value->SetFont(FF_DEFAULT, FS_NORMAL, 7); break; case 'week': $graph->yaxis->SetTitleMargin(40); $graph->img->SetMargin(65, 30, 20, 40); $bplot->value->SetFont(FF_DEFAULT, FS_NORMAL, 8); break; case 'day': default: $graph->yaxis->SetTitleMargin(40); $graph->img->SetMargin(60, 30, 20, 40); $bplot->value->SetFont(FF_DEFAULT, FS_NORMAL, 8); break; } // Display the graph $graph->Stroke($graph_files['orders']['file']); }