Beispiel #1
0
 public function executeChartEmployees()
 {
     $data = array();
     foreach (JobPeer::doSelect(new Criteria()) as $job) {
         $c = new Criteria();
         $c->add(EmployeePeer::JOB_ID, $job->getId());
         $data[$job->getName()] = EmployeePeer::doCount($c);
     }
     //To create a bar chart we need to create a stBarOutline Object
     $bar = new stBarOutline(80, '#78B9EC', '#3495FE');
     $bar->key('', 10);
     //Passing the random data to bar chart
     $bar->data = $data;
     //Creating a stGraph object
     $g = new stGraph();
     $g->title('Employee Job Type Break-Down', '{font-size: 20px;}');
     $g->bg_colour = '#FFFFFF';
     $g->set_inner_background('#E3F0FD', '#CBD7E6', 90);
     $g->x_axis_colour('#8499A4', '#E4F5FC');
     $g->y_axis_colour('#8499A4', '#E4F5FC');
     //Pass stBarOutline object i.e. $bar to graph
     $g->data_sets[] = $bar;
     //Setting labels for X-Axis
     $g->set_x_labels(array_keys($data));
     // to set the format of labels on x-axis e.g. font, color, step
     $g->set_x_label_style(10, '#18A6FF', 0, 2);
     // To tick the values on x-axis
     // 2 means tick every 2nd value
     $g->set_x_axis_steps(2);
     //set maximum value for y-axis
     //we can fix the value as 20, 10 etc.
     //but its better to use max of data
     $g->set_y_max(max($data));
     $g->y_label_steps(4);
     $g->set_y_legend('# Employees', 12, '#18A6FF');
     echo $g->render();
     return sfView::NONE;
 }
 /**
  * Creates a bar chart from random data
  *
  */
 public function executeBarChartData()
 {
     $chartData = array();
     //Array with sample random data
     for ($i = 0; $i < 7; $i++) {
         $chartData[] = rand(1, 20);
     }
     //To create a bar chart we need to create a stBarOutline Object
     $bar = new stBarOutline(80, '#78B9EC', '#3495FE');
     $bar->key('Number of downloads per day', 10);
     //Passing the random data to bar chart
     $bar->data = $chartData;
     //Creating a stGraph object
     $g = new stGraph();
     $g->title('stOfcPlugin example', '{font-size: 20px;}');
     $g->bg_colour = '#E4F5FC';
     $g->set_inner_background('#E3F0FD', '#CBD7E6', 90);
     $g->x_axis_colour('#8499A4', '#E4F5FC');
     $g->y_axis_colour('#8499A4', '#E4F5FC');
     //Pass stBarOutline object i.e. $bar to graph
     $g->data_sets[] = $bar;
     //Setting labels for X-Axis
     $g->set_x_labels(array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'));
     // to set the format of labels on x-axis e.g. font, color, step
     $g->set_x_label_style(10, '#18A6FF', 0, 2);
     // To tick the values on x-axis
     // 2 means tick every 2nd value
     $g->set_x_axis_steps(2);
     //set maximum value for y-axis
     //we can fix the value as 20, 10 etc.
     //but its better to use max of data
     $g->set_y_max(max($chartData));
     $g->y_label_steps(4);
     $g->set_y_legend('stOfcPlugin', 12, '#18A6FF');
     echo $g->render();
     return sfView::NONE;
 }
 public function executeGraficos(sfWebRequest $request)
 {
     $estatus = $request->getParameter('estatus');
     $tipo = $request->getParameter('tipografico');
     $opcion = $request->getParameter('opcion');
     $estado = $request->getParameter('estado');
     $area_formacion = $request->getParameter('area_formacion');
     echo $estatus;
     echo $tipo;
     echo $opcion;
     echo $estado;
     echo $area_formacion;
     $eje_x = array();
     $porcentajes = array();
     if ($opcion == 1) {
         $porcentaje_referencia = Doctrine_Core::getTable('Identificacion')->obtenerEstPorEstados($estatus, "");
     }
     if ($opcion == 2) {
         $porcentaje_referencia = Doctrine_Core::getTable('Identificacion')->obtenerEstPorEspecialidad($estado, $estatus);
     }
     if ($opcion == 3) {
         $porcentaje_referencia = Doctrine_Core::getTable('Identificacion')->obtenerEstPorEntes($estado, $estatus, $area_formacion);
     }
     foreach ($porcentaje_referencia as $referencia => $porcentaje) {
         $eje_x[] = $referencia;
         $porcentajes[] = $porcentaje;
     }
     if ($tipo == 'barra') {
         $bar = new stBarOutline(80, '#78B9EC', '#3495FE');
         $bar->key('Porcentaje por Estado', 10);
         //Passing the estados data to bar chart
         $bar->data = $porcentajes;
         //Creating a stGraph object
         $g = new stGraph();
         $g->title('% Facilitadores por Estados', '{font-size: 20px;}');
         $g->bg_colour = '#E4F5FC';
         $g->set_inner_background('#E3F0FD', '#CBD7E6', 150);
         $g->x_axis_colour('#8499A4', '#E4F5FC');
         $g->y_axis_colour('#8499A4', '#E4F5FC');
         //Pass stBarOutline object i.e. $bar to graph
         $g->data_sets[] = $bar;
         //Setting labels for X-Axis
         $g->set_x_labels($eje_x);
         // to set the format of labels on x-axis e.g. font, color, step
         $g->set_x_label_style(10, '#18A6FF', 1);
         // To tick the values on x-axis
         // 2 means tick every 2nd value
         $g->set_x_axis_steps(1);
         //set maximum value for y-axis
         //we can fix the value as 20, 10 etc.
         //but its better to use max of data
         $g->set_y_max(max($porcentajes));
         $g->y_label_steps(10);
         $g->set_y_legend('Porcentaje', 12, '#18A6FF');
         echo $g->render();
         return sfView::NONE;
     }
     if ($opcion == 'circular') {
         //Creating a stGraph object
         $g = new stGraph();
         //set background color
         $g->bg_colour = '#E4F5FC';
         //Set the transparency, line colour to separate each slice etc.
         $g->pie(80, '#78B9EC', '{font-size: 12px; color: #78B9EC;');
         //array two arrray one containing data while other contaning labels
         $g->pie_values($porcentaje, $eje_x);
         //Set the colour for each slice. Here we are defining three colours
         //while we need 7 colours. So, the same colours will be
         //repeated for the all remaining slices in the same order
         $g->pie_slice_colours(array('#d01f3c', '#356aa0', '#c79810'));
         //To display value as tool tip
         $g->set_tool_tip('#val#%');
         $g->title('% de Facilitadores por Estado', '{font-size:18px; color: #18A6FF}');
         echo $g->render();
         return sfView::NONE;
     }
 }
Beispiel #4
0
 /**
  * Returns the data for a bar chart showing the amount of commits per author per hour of the day.
  *
  * @param sfWebRequest $request
  *
  * @return void
  */
 public function executeChartAuthorActivityHours(sfWebRequest $request)
 {
     $scm_id = $this->getUser()->getSelectedScmId();
     $username = $request->getParameter('param');
     $query = Doctrine::getTable('Commit')->createQuery()->addWhere('scm_id = ?', $scm_id)->addWhere('author = ?', $username);
     $result = $query->fetchArray();
     $hours = range(0, 23);
     $values = array_fill(0, 24, 0);
     foreach ($result as $item) {
         $hour = (int) date('H', strtotime($item['timestamp']));
         $values[$hour]++;
     }
     //To create a bar chart we need to create a stBarOutline Object
     $bar = new stBarOutline(80, '#78B9EC', '#3495FE');
     $bar->key('Commits per hour', 10);
     //Passing the random data to bar chart
     $bar->data = $values;
     //Creating a stGraph object
     $g = new stGraph();
     $g->set_inner_background('#E3F0FD', '#CBD7E6', 90);
     $g->x_axis_colour('#8499A4', '#E4F5FC');
     $g->y_axis_colour('#8499A4', '#E4F5FC');
     //set background color
     $g->bg_colour = '#eeeeee';
     //Set the transparency, line colour to separate each slice etc.
     $g->bar_filled(80, '#78B9EC', '#78B9EC', '{font-size: 12px; color: #78B9EC;');
     //Pass stBarOutline object i.e. $bar to graph
     $g->data_sets[] = $bar;
     //Setting labels for X-Axis
     $g->set_x_labels($hours);
     // To tick the values on x-axis
     // 2 means tick every 2nd value
     $g->set_x_axis_steps(2);
     //set maximum value for y-axis
     //we can fix the value as 20, 10 etc.
     //but its better to use max of data
     $g->set_y_max(max($values));
     $g->y_label_steps(4);
     $g->set_y_legend('# commits', 12, '#18A6FF');
     //To display value as tool tip
     $g->set_tool_tip('#x_label#: #val# commits');
     $g->title('Total commits per hour for ' . $username, '{font-size:18px; color: #18A6FF}');
     return $this->renderText($g->render());
 }