public function executeChartOffices() { $data = array(); foreach (OfficePeer::doSelect(new Criteria()) as $office) { $c = new Criteria(); $c->add(ClientServicePeer::OFFICE_ID, $office->getId()); $data[$office->getName()] = ClientServicePeer::doCount(ClientServicePeer::addActive($c)); } //Creating a stGraph object $g = new stGraph(); //set background color $g->bg_colour = '#FFFFFF'; //Set the transparency, line colour to separate each slice etc. $g->pie(90, '#78B9EC', '{font-size: 12px; color: #000000;'); //array two arrray one containing data while other contaning labels $g->pie_values($data, array_keys($data)); //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# Services'); $g->title('Active Client Services At Location', '{font-size:18px;margin-bottom:20px}'); echo $g->render(); return sfView::NONE; }
/** * Creates a pie chart from random data */ public function executePieChartData() { $chatData = array(); for ($i = 0; $i < 7; $i++) { $data[] = rand(5, 20); } //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($data, array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')); //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('stOfcPlugin example', '{font-size:18px; color: #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; } }
/** * 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()); }