/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { global $locale; $parameters['api_call'] = 'localizer'; $parameters['what'] = 'top_localizer'; $parameters['result_format'] = 'separate_result_arrays'; list($names, $values, $percent, $total) = phpOpenTracker::get($parameters); $title = $locale->get('admin_stat', 'field_top') . ' ' . $parameters['limit'] . ' ' . $locale->get('admin_stat', 'field_countries'); for ($i = 0, $numValues = sizeof($values); $i < $numValues; $i++) { $legend[$i] = sprintf('%s (%s, %s%%%%)', $names[$i], $values[$i], $percent[$i]); } $graph = new PieGraph($parameters['width'], $parameters['height'], 'auto'); $graph->SetShadow(); $graph->title->Set($title); $graph->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']); $graph->title->SetColor('black'); $graph->legend->Pos(0.1, 0.2); $plot = new PiePlot3d($values); $plot->SetTheme('sand'); $plot->SetCenter(0.4); $plot->SetAngle(30); $plot->value->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size'] - 2); $plot->SetLegends($legend); $graph->Add($plot); $graph->Stroke(); }
public static function pieChart($data, $legends) { $graph = new PieGraph(900, 550, 'auto'); $graph->SetShadow(); // $graph->title->Set($topic); $graph->title->SetFont(FF_VERDANA, FS_BOLD, 14); $graph->legend->Pos(0.1, 0.2); // Creating a 3D pie graphic $p1 = new PiePlot3d($data); $p1->SetTheme("sand"); $p1->SetLabels($legends); $p1->SetLabelPos(1); $p1->SetLabelType(PIE_VALUE_PER); $p1->value->Show(); $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 20); $p1->value->SetColor('darkgray'); $p1->SetCenter(0.45, 0.5); $p1->SetAngle(45); $p1->ExplodeAll(20); // $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 12); // $p1->SetLegends($legends); $graph->img->SetImgFormat('png'); $graph->Add($p1); // Showing graphic return $graph->Stroke('../graph/3DpieChart.png'); }
function render($imgType) { $this->graph->SetImgFormat($imgType); if ($this->chartType == 'piechart') { $plot = new PiePlot3d($this->value_r); $plot->SetTheme("sand"); $plot->SetCenter(0.35); $plot->SetAngle(50); $plot->SetLegends($this->display_r); $plot->SetLabelType(PIE_VALUE_ADJPER); } else { $this->graph->xaxis->SetTickLabels($this->display_r); $plot = new BarPlot($this->value_r); $plot->SetWidth(0.5); $plot->SetFillColor("orange@0.75"); } $this->graph->Add($plot); $this->graph->Stroke(); }
/** * @@生成三维饼图 * @param string $title * @param array $data * @param int $size * @param int $height * @param int $width * @param array $legend */ static function create3dpie($title, $data = array(), $size = 40, $height = 100, $width = 80, $legend = array(), $slice = 0) { //包含相关的文件 vendor("Jpgraph.jpgraph"); vendor("Jpgraph.jpgraph_pie"); vendor("Jpgraph.jpgraph_pie3d"); // 创建图表 $graph = new PieGraph($width, $height, "auto"); $graph->SetShadow(); // 设置标题 $graph->title->Set(iconv("utf-8", "gb2312", $title)); //$graph->title->SetFont(FF_VERDANA,FS_BOLD,18); $graph->title->SetFont(FF_SIMSUN, FS_BOLD, 18); $graph->title->SetColor("darkblue"); $graph->legend->Pos(0.1, 0.2); $graph->SetFrame(false, '#ffffff', 0); //去掉周围的边框 // Create 3D pie plot $p1 = new PiePlot3d($data); $p1->SetTheme("sand"); $p1->SetCenter(0.4); $p1->SetSize($size); // Adjust projection angle $p1->SetAngle(70); // As a shortcut you can easily explode one numbered slice with if ($slice == 0) { $p1->ExplodeSlice(3); } // Setup the slice values $p1->value->SetFont(FF_ARIAL, FS_BOLD, 10); //$p1->value->SetFont(FF_SIMSUN,FS_BOLD,11); $p1->value->SetColor("navy"); $graph->legend->SetFont(FF_SIMSUN, FS_BOLD, 8); //编码转化 foreach ($legend as $k => $v) { $legend[$k] = iconv('utf-8', 'gb2312', $v); } $p1->SetLegends($legend); $graph->Add($p1); $graph->Stroke(); }
include_once "./lib/jpgraph/src/jpgraph_pie3d.php"; $result = dbquery($sql); if (!mysql_num_rows($result) > 0) { die("Error: no rows retrieved from database\n"); } while ($row = mysql_fetch_object($result)) { $data[] = $row->count; $data_names[] = $row->from_domain; $data_size[] = round($row->size); } $graph = new PieGraph(800, 385, 0, false); $graph->SetShadow(); $graph->img->SetAntiAliasing(); $graph->title->Set("Top 10 Sender Domains by Volume"); $p1 = new PiePlot3d($data); $p1->SetTheme('sand'); $p1->SetLegends($data_names); $p1->SetCenter(0.73, 0.4); $graph->legend->SetLayout(LEGEND_VERT); $graph->legend->Pos(0.25, 0.2, 'center'); $graph->Add($p1); $graph->Stroke($filename); } // HTML code to display the graph echo "<TABLE BORDER=\"0\" CELLPADDING=\"10\" CELLSPACING=\"0\" WIDTH=\"100%\">"; echo "<TR>"; echo " <TD ALIGN=\"CENTER\"><IMG SRC=\"" . IMAGES_DIR . "mailscannerlogo.gif\" ALT=\"MailScannr Logo\"></TD>"; echo "</TR>"; echo "<TR>"; // Check Permissions to see if the file has been written and that apache to read it. if (is_readable($filename)) {
require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_pie.php'; require_once 'jpgraph/jpgraph_pie3d.php'; // Some data $data = array(20, 27, 45, 75, 90); // Create the Pie Graph. $graph = new PieGraph(350, 200); $graph->SetShadow(); // Set A title for the plot $graph->title->Set("Example 2 3D Pie plot"); $graph->title->SetFont(FF_VERDANA, FS_BOLD, 18); $graph->title->SetColor("darkblue"); $graph->legend->Pos(0.1, 0.2); // Create 3D pie plot $p1 = new PiePlot3d($data); $p1->SetTheme("sand"); $p1->SetCenter(0.4); $p1->SetSize(0.4); $p1->SetHeight(5); // Adjust projection angle $p1->SetAngle(45); // You can explode several slices by specifying the explode // distance for some slices in an array $p1->Explode(array(0, 40, 0, 30)); // As a shortcut you can easily explode one numbered slice with // $p1->ExplodeSlice(3); $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 10); $p1->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct")); $graph->Add($p1); $graph->Stroke(); ?>
function graph_pie($p_metrics, $p_title = '', $p_graph_width = 500, $p_graph_height = 350, $p_center = 0.4, $p_poshorizontal = 0.1, $p_posvertical = 0.09) { $t_graph_font = graph_get_font(); error_check(is_array($p_metrics) ? array_sum($p_metrics) : 0, $p_title); if (plugin_config_get('eczlibrary') == ON) { $graph = new ezcGraphPieChart(); $graph->title = $p_title; $graph->background->color = '#FFFFFF'; $graph->options->font = $t_graph_font; $graph->options->font->maxFontSize = 12; $graph->legend = false; $graph->data[0] = new ezcGraphArrayDataSet($p_metrics); $graph->data[0]->color = '#FFFF00'; $graph->renderer = new ezcGraphRenderer3d(); $graph->renderer->options->dataBorder = false; $graph->renderer->options->pieChartShadowSize = 10; $graph->renderer->options->pieChartGleam = 0.5; $graph->renderer->options->pieChartHeight = 16; $graph->renderer->options->legendSymbolGleam = 0.5; $graph->driver = new ezcGraphGdDriver(); //$graph->driver->options->supersampling = 1; $graph->driver->options->jpegQuality = 100; $graph->driver->options->imageFormat = IMG_JPEG; $graph->renderer->options->syncAxisFonts = false; $graph->renderToOutput($p_graph_width, $p_graph_height); } else { $graph = new PieGraph($p_graph_width, $p_graph_height); $graph->img->SetMargin(40, 40, 40, 100); $graph->title->Set($p_title); $graph->title->SetFont($t_graph_font, FS_BOLD); $graph->SetMarginColor('white'); $graph->SetFrame(false); $graph->legend->Pos($p_poshorizontal, $p_posvertical); $graph->legend->SetFont($t_graph_font); $p1 = new PiePlot3d(array_values($p_metrics)); // should be reversed? $p1->SetTheme('earth'); # $p1->SetTheme("sand"); $p1->SetCenter($p_center); $p1->SetAngle(60); $p1->SetLegends(array_keys($p_metrics)); # Label format $p1->value->SetFormat('%2.0f'); $p1->value->Show(); $p1->value->SetFont($t_graph_font); $graph->Add($p1); if (helper_show_query_count()) { $graph->subtitle->Set(db_count_queries() . ' queries (' . db_time_queries() . 'sec)'); $graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8); } $graph->Stroke(); } }
function graph_pie($p_metrics, $p_title = '', $p_graph_width = 500, $p_graph_height = 350, $p_center = 0.4, $p_poshorizontal = 0.1, $p_posvertical = 0.09) { $t_graph_font = graph_get_font(); error_check(is_array($p_metrics) ? array_sum($p_metrics) : 0, $p_title); $graph = new PieGraph($p_graph_width, $p_graph_height); $graph->img->SetMargin(40, 40, 40, 100); $graph->title->Set($p_title); $graph->title->SetFont($t_graph_font, FS_BOLD); $graph->SetMarginColor('white'); $graph->SetFrame(false); $graph->legend->Pos($p_poshorizontal, $p_posvertical); $graph->legend->SetFont($t_graph_font); $p1 = new PiePlot3d(array_values($p_metrics)); // should be reversed? $p1->SetTheme('earth'); #$p1->SetTheme("sand"); $p1->SetCenter($p_center); $p1->SetAngle(60); $p1->SetLegends(array_keys($p_metrics)); # Label format $p1->value->SetFormat('%2.0f'); $p1->value->Show(); $p1->value->SetFont($t_graph_font); $graph->Add($p1); if (helper_show_queries()) { $graph->subtitle->Set(db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique) (' . db_time_queries() . 'sec)'); $graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8); } $graph->Stroke(); }
function PIE_graph($module, $method, $type, $start, $extra_fields) { global $C_translate, $C_auth; include_once PATH_CORE . 'validate.inc.php'; $dt = new CORE_validate(); include PATH_GRAPH . "jpgraph.php"; #################################################################### ### Check if 'search' is authorized for this account #################################################################### # check the validation for this function if ($C_auth->auth_method_by_name($module, 'search')) { # validate this file exists, and include it. if (file_exists(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php')) { include_once PATH_MODULES . '/' . $module . '/' . $module . '.inc.php'; } else { ### Not exist! $error = $C_translate->translate('module_non_existant', '', ''); } } else { ### Not auth $error = $C_translate->translate('module_non_auth', '', ''); } if (isset($error)) { include PATH_GRAPH . "jpgraph_canvas.php"; // Create the graph. $graph = new CanvasGraph(460, 55, "auto"); $t1 = new Text($error); $t1->Pos(0.2, 0.5); $t1->SetOrientation("h"); $t1->SetBox("white", "black", 'gray'); $t1->SetFont(FF_FONT1, FS_NORMAL); $t1->SetColor("black"); $graph->AddText($t1); $graph->Stroke(); exit; } # initialize the module, if it has not already been initialized $eval = '$' . $module . ' = new ' . $module . '; '; $eval .= '$this_Obj = $' . $module . ';'; eval($eval); # run the function $array = call_user_func(array($module, $method), $start_str, $end_str, $constraint_array, $default_array, $extra_fields); include PATH_GRAPH . "jpgraph_pie.php"; include PATH_GRAPH . "jpgraph_pie3d.php"; $data = $array['data']; $legends = $array['legends']; // Create the Pie Graph. $graph = new PieGraph(500, 250, "auto"); $graph->SetScale("textlin"); $graph->SetMarginColor('#F9F9F9'); $graph->SetFrame(true, '#FFFFFF', 0); $graph->SetColor('#F9F9F9'); // Create pie plot $p1 = new PiePlot3d($data); $p1->SetTheme("water"); $p1->SetCenter(0.4); $p1->SetAngle(30); $p1->value->SetFont(FF_FONT1, FS_NORMAL, 8); $p1->SetLegends($legends); // Explode the larges slice: $largest = 0; for ($i = 0; $i < count($data); $i++) { if ($data[$i] > $largest) { $largest = $data[$i]; $explode = $i; } } if ($explode) { $p1->ExplodeSlice($explode); } $graph->Add($p1); $graph->Stroke(); }
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { $parameters['api_call'] = 'top'; $parameters['result_format'] = 'separate_result_arrays'; list($names, $values, $percent, $total) = phpOpenTracker::get($parameters); $title = 'Top ' . $parameters['limit'] . ' '; switch ($parameters['what']) { case 'document': $title .= 'Pages'; break; case 'entry_document': $title .= 'Entry Pages'; break; case 'exit_document': $title .= 'Exit Pages'; break; case 'exit_target': $title .= 'Exit Targets'; break; case 'host': $title .= 'Hosts'; break; case 'operating_system': $title .= 'Operating Systems'; break; case 'referer': $title .= 'Referers'; break; case 'user_agent': $title .= 'User Agents'; break; } $title .= " (Total: {$total})"; for ($i = 0, $numValues = sizeof($values); $i < $numValues; $i++) { $legend[$i] = sprintf('%s (%s, %s%%%%)', $names[$i], $values[$i], $percent[$i]); } $graph = new PieGraph($parameters['width'], $parameters['height'], 'auto'); $graph->SetShadow(); $graph->title->Set($title); $graph->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']); $graph->title->SetColor('black'); $graph->legend->Pos(0.1, 0.2); $plot = new PiePlot3d($values); $plot->SetTheme('sand'); $plot->SetCenter(0.4); $plot->SetAngle(30); $plot->value->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size'] - 2); $plot->SetLegends($legend); $graph->Add($plot); $graph->Stroke(); }
private function piePlot($question, $datax, $datay, $width, $height) { include_once BASE . "jpgraph.php"; include_once BASE . "jpgraph_pie.php"; include_once BASE . "jpgraph_pie3d.php"; // Create the Pie Graph. $graph = new PieGraph($width, $height, "auto"); $graph->SetShadow(); // Set A title for the plot $tFontSize = 11; $graph->title->Set($question); $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize); $graph->title->SetColor("darkblue"); $graph->SetAntiAliasing(true); $graph->legend->SetPos(0.02, 0.95, 'right', 'bottom'); $graph->legend->SetMarkAbsSize(5); $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); $tWidth = $graph->title->GetWidth($graph->img); //if ($graph->title->GetWidth($graph->img)>$width) $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize-2); if ($tWidth > $width) { $index = strrpos(substr($question, 0, ($len = strlen($question)) / 2 + 5), ' '); //echo $index; if ($index === false) { $index = $len / 2 - 3; } $question[$index] = "\n"; $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize -= 2); $graph->title->Set($question); } // Create pie plot $pie = new PiePlot3d($datay); $pie->SetTheme("sand"); $pie->SetCenter(0.5, 0.4); $pie->SetSize(($t = $height * 0.005 / $this->amountOfVariants) > 0.5 ? 0.5 : $t); $pie->SetAngle(30); $pie->ExplodeAll(5); $pie->value->SetFont(FF_ARIAL, FS_NORMAL, 10); $pie->SetLegends($datax); $graph->Add($pie); return $graph->Stroke("images/raporty/{$this->id_pytanie}P.png"); }
$data_array = array(); $label_array = array(); foreach($data as $key => $item){ $data_array[] = $item; $label_array[] = $labels[$key]; } debug_message(print_r($data_array, TRUE).print_r($label_array,TRUE)); // Create the Pie Graph. $graph = new PieGraph(500,325); $graph->SetShadow(); // Set A title for the plot $graph->title->Set($title); #$graph->title->SetFont(FF_VERDANA,FS_BOLD,18); $graph->title->SetColor("darkblue"); //$graph->legend->Pos(0.1,0.2); // Create pie plot $p1 = new PiePlot3d($data_array); $p1->SetTheme("earth"); $p1->SetCenter(0.35, 0.6); $p1->SetAngle(30); #$p1->SetFont(FF_ARIAL,FS_NORMAL,12); $p1->SetLegends($label_array); $graph->Add($p1); $graph->Stroke(); ?>
public function generarReportePastel() { $this->load->model('nivel_model'); $alumPorNivel = $this->nivel_model->alumnosPorNivel(); require_once APPPATH . "libraries/jpgraph/jpgraph.php"; require_once APPPATH . "libraries/jpgraph/jpgraph_pie.php"; require_once APPPATH . "libraries/jpgraph/jpgraph_pie3d.php"; // Pasando el nombre de los niveles a un arreglo llamado dato $i = 0; foreach ($alumPorNivel->result() as $a) { $dato[$i] = $a->nombre; $cuenta[] = $a->total; $exp[$i] = 5; $i++; } // Creando el Grafico de Pastel $graph = new PieGraph(550, 400); $graph->SetShadow(); // Estableciendo el titulo $graph->title->Set("Porcentaje de Alumnos por Nivel"); $graph->title->SetFont(FF_VERDANA, FS_BOLD, 18); $graph->title->SetColor("darkblue"); $graph->legend->Pos(0.3, 0.06); // Crear 3D pie plot $p1 = new PiePlot3d($cuenta); $p1->SetTheme("sand"); $p1->SetCenter(0.5); $p1->SetSize(0.5); $p1->SetHeight(20); #Ancho del pastel // Angulo de inclinación $p1->SetAngle(45); // Distancia entre las partes del pastel $p1->Explode($exp); $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 10); $p1->SetLegends($dato); $graph->Add($p1); $gdImgHandler = $graph->Stroke(_IMG_HANDLER); // Guardando imagen como archivo por default es .png $fileName = "assets/img/reportes/reporte.jpg"; $graph->img->Stream($fileName); redirect(base_url('Alumnos/verReportePastel')); }
<?php include "../jpgraph.php"; include "../jpgraph_pie.php"; include "../jpgraph_pie3d.php"; // Some data $data = array(200, 27, 45, 75, 90); // Create the Pie Graph. $graph = new PieGraph(400, 300, "auto"); $graph->SetFrame(true, 'darkblue', 0); //$theme_class= new VividTheme; //$graph->SetTheme($theme_class); // Set A title for the plot //$graph->title->Set("Example 1 3D Pie plot"); //$graph->title->SetFont(FF_VERDANA,FS_BOLD,18); //$graph->title->SetColor("darkblue"); //$graph->legend->Pos(0.1,0.2); // Create pie plot $p1 = new PiePlot3d($data); $p1->SetTheme("pastel"); $p1->SetCenter(0.5); $p1->SetAngle(60); $p1->SetSliceColors(array('red', 'blue', 'green', 'navy', 'orange')); //$p1->value->SetFont(FF_ARIAL,FS_NORMAL,12); //$p1->SetLegends(array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct")); $graph->Add($p1); $graph->Stroke(); ?>
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { global $lang, $c; $parameters['api_call'] = 'top'; $parameters['result_format'] = 'separate_result_arrays'; $apicall = array('api_call' => 'top', 'result_format' => 'separate_result_arrays', 'what' => $parameters["what"], 'start' => $parameters["start"], 'end' => $parameters["end"], 'client_id' => 1, 'limit' => $parameters["limit"]); list($names, $values, $percent, $total) = phpOpenTracker::get($apicall); $percent_others = 100.0; $values_others = 0; for ($j = 0; $j < $parameters['limit']; $j++) { $percent_others = $percent_others - $percent[$j]; $values_others = $values_others + $values[$j]; if (is_numeric($names[$j])) { $names[$j] = resolvePage($names[$j]); } } array_push($percent, $percent_others); array_push($names, $lang->get("others", "Others")); array_push($values, $values_others * $percent_others / 100); $title = 'Top ' . $parameters['limit'] . ' '; switch ($parameters['what']) { case 'document': $title .= 'Pages'; break; case 'entry_document': $title .= 'Entry Pages'; break; case 'exit_document': $title .= 'Exit Pages'; break; case 'exit_target': $title .= 'Exit Targets'; break; case 'host': $title .= 'Hosts'; break; case 'operating_system': $title .= 'Operating Systems'; break; case 'referer': $title .= 'Referers'; break; case 'user_agent': $title .= 'Browsers'; break; } $title .= " (Total: {$total})"; for ($i = 0, $numValues = sizeof($values); $i < $numValues; $i++) { $legend[$i] = sprintf('%s (%s, %s%%%%)', $names[$i], $values[$i], $percent[$i]); } $graph = new PieGraph($parameters['width'], $parameters['height'], 'auto'); $graph->title->Set($title); if ($c["usettf"]) { $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->title->SetColor('black'); $graph->legend->Pos(0.5, 0.6, "center", "top"); $graph->legend->SetFillColor("white"); $graph->legend->SetShadow(0); //$graph->legend->SetFrame(0); if ($c["usettf"]) { $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->SetFrame(0); $plot = new PiePlot3d($percent); $plot->SetTheme('nx'); $plot->SetCenter(0.5, 0.3); $plot->SetAngle(45); if ($c["usettf"]) { $plot->value->SetFont(FF_ARIAL, FS_NORMAL, 8); } $plot->SetLegends($legend); $graph->Add($plot); $graph->img->SetAntiAliasing("white"); $graph->Stroke(); }