require_once 'jpgraph/jpgraph_pie.php'; // Some data $data = array(50, 28, 25, 27, 31, 20); // A new pie graph $graph = new PieGraph(400, 400); // If you don't want any border just uncomment this line // $graph->SetFrame(false); // Uncomment this line to add a drop shadow to the border // $graph->SetShadow(); // Setup title $graph->title->Set("CSIM Center Pie plot ex 1"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 18); $graph->title->SetMargin(8); // Add a little bit more margin from the top // Create the pie plot $p1 = new PiePlotC($data); // Set the radius of pie (as fraction of image size) $p1->SetSize(0.32); // Move the center of the pie slightly to the top of the image $p1->SetCenter(0.5, 0.45); // Label font and color setup $p1->value->SetFont(FF_ARIAL, FS_BOLD, 12); $p1->value->SetColor('white'); // Setup the title on the center circle $p1->midtitle->Set("Test mid\nRow 1\nRow 2"); $p1->midtitle->SetFont(FF_ARIAL, FS_NORMAL, 14); // Set color for mid circle $p1->SetMidColor('yellow'); // Use percentage values in the legends values (This is also the default) $p1->SetLabelType(PIE_VALUE_PER); // The label array values may have printf() formatting in them. The argument to the
/** * 环形图 */ function createring($title, $data = array(), $size = 40, $height = 100, $width = 80, $legend = array()) { // Example of pie with center circle vendor("Jpgraph.jpgraph"); vendor("Jpgraph.jpgraph_pie"); // Some data //$data = array(50,28,25,27,30,30); // A new pie graph $graph = new PieGraph(700, 350, 'auto'); //$graph->SetShadow(); // Setup title $graph->title->Set(iconv("utf-8", "gb2312", "{$title}")); $graph->title->SetFont(FF_SIMSUN, FS_BOLD, 14); $graph->title->SetMargin(2); // Add a little bit more margin from the top $graph->legend->Pos(0.1, 0.1); $graph->SetFrame(false, '#ffffff', 0); //去掉周围的边框 // Create the pie plot $p1 = new PiePlotC($data); // Set size of pie $p1->SetTheme("sand"); $p1->SetCenter(0.4); $p1->SetSize(0.35); // Label font and color setup $p1->value->SetFont(FF_ARIAL, FS_BOLD, 10); $p1->value->SetColor('black'); // Setup the title on the center circle $p1->midtitle->Set(""); $p1->midtitle->SetFont(FF_SIMSUN, FS_NORMAL, 10); // Set color for mid circle $p1->SetMidColor('white'); // Use percentage values in the legends values (This is also the default) $p1->SetLabelType(PIE_VALUE_PER); $graph->legend->SetFont(FF_SIMSUN, FS_NORMAL, 8); //编码转化 foreach ($legend as $k => $v) { $legend[$k] = iconv('utf-8', 'gb2312', $v); } $p1->SetLegends($legend); // Add plot to pie graph $graph->Add($p1); // .. and send the image on it's marry way to the browser $graph->Stroke(); }
require_once 'jpgraph/jpgraph_pie.php'; // Some data $data = array(50, 28, 25, 27, 31, 20); // A new pie graph $piegraph = new PieGraph(400, 320); $n = count($data); // Number of slices // No border around graph $piegraph->SetFrame(false); // Setup title $piegraph->title->Set("CSIM Center Pie plot"); $piegraph->title->SetFont(FF_ARIAL, FS_BOLD, 18); $piegraph->title->SetMargin(8); // Add a little bit more margin from the top // Create the pie plot $p1 = new PiePlotC($data); // Set the radius of pie (as fraction of image size) $p1->SetSize(0.32); // Label font and color setup $p1->value->SetFont(FF_ARIAL, FS_BOLD, 11); $p1->value->SetColor('white'); // Setup the title on the center circle $p1->midtitle->Set("Distribution\n2008 H1"); $p1->midtitle->SetFont(FF_ARIAL, FS_NORMAL, 12); // Set color for mid circle $p1->SetMidColor('yellow'); // Use percentage values in the legends values (This is also the default) $p1->SetLabelType(PIE_VALUE_PER); // The label array values may have printf() formatting in them. The argument to the // form,at string will be the value of the slice (either the percetage or absolute // depending on what was specified in the SetLabelType() above.
require_once "jpgraph/jpgraph_pie.php"; // Some data $data = array(50, 28, 25, 27, 31, 20); // A new pie graph $graph = new PieGraph(400, 400, 'auto'); // Don't display the border $graph->SetFrame(false); // Uncomment this line to add a drop shadow to the border // $graph->SetShadow(); // Setup title $graph->title->Set("PiePlotC"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 18); $graph->title->SetMargin(8); // Add a little bit more margin from the top // Create the pie plot $p1 = new PiePlotC($data); // Set size of pie $p1->SetSize(0.35); // Label font and color setup $p1->value->SetFont(FF_ARIAL, FS_BOLD, 12); $p1->value->SetColor('white'); $p1->value->Show(); // Setup the title on the center circle $p1->midtitle->Set("Test mid\nRow 1\nRow 2"); $p1->midtitle->SetFont(FF_ARIAL, FS_NORMAL, 14); // Set color for mid circle $p1->SetMidColor('yellow'); // Use percentage values in the legends values (This is also the default) $p1->SetLabelType(PIE_VALUE_PER); // The label array values may have printf() formatting in them. The argument to the // form,at string will be the value of the slice (either the percetage or absolute
// content="text/plain; charset=utf-8" // $Id // Example of pie with center circle require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_pie.php'; // Some data $data = array(50, 28, 25, 27, 31, 20); // A new pie graph $graph = new PieGraph(300, 300, 'auto'); // Setup title $graph->title->Set("Pie plot with center circle"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); $graph->title->SetMargin(8); // Add a little bit more margin from the top // Create the pie plot $p1 = new PiePlotC($data); // Set size of pie $p1->SetSize(0.32); // Label font and color setup $p1->value->SetFont(FF_ARIAL, FS_BOLD, 10); $p1->value->SetColor('black'); // Setup the title on the center circle $p1->midtitle->Set("Test mid\nRow 1\nRow 2"); $p1->midtitle->SetFont(FF_ARIAL, FS_NORMAL, 10); // Set color for mid circle $p1->SetMidColor('yellow'); // Use percentage values in the legends values (This is also the default) $p1->SetLabelType(PIE_VALUE_PER); // Add plot to pie graph $graph->Add($p1); // .. and send the image on it's marry way to the browser
public function graficar_pastel() { $sql = "call PRGetGraficaDias('{$this->fecha_inicial}','{$this->fecha_final}');"; $res = mysql_query($sql); while ($row = mysql_fetch_array($res)) { $datos[] = $row["Contador"]; $labels[] = $row["Estado"]; } if (empty($datos)) { echo 'No existe datos a mostrarse.'; } else { // A new graph $graph = new PieGraph(1000, 800, 'auto'); $graph->SetFrame(false); $graph->img->SetAntiAliasing(); // Setup title $graph->title->Set("Porcentaje de Personas que Entran - Salen"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 22); $graph->title->SetMargin(20); // The pie plot $p1 = new PiePlotC($datos); $p1->SetSliceColors(array('hotpink', 'aquamarine3')); // Move center of pie to the left to make better room // for the legend $p1->SetSize(0.3); // Set color for mid circle $p1->SetMidColor('white'); $p1->SetCenter(0.5, 0.4); $p1->value->SetFont(FF_ARIAL, FS_BOLD, 20); $p1->value->SetColor('white'); $p1->value->Show(); $p1->SetLabelType(PIE_VALUE_PER); $lbl = array("%.1f%%", "%.1f%%"); $p1->SetLabels($lbl); $p1->ExplodeAll(10); // Legends $p1->SetLegends(array("ENTRA", "SALE")); $graph->legend->SetFont(FF_ARIAL, FS_BOLD, 15); $graph->legend->SetPos(0.5, 0.4, 'center', 'bottom'); $graph->legend->SetColumns(2); $graph->Add($p1); $graph->Stroke(); } }