/**
  * 环形图
  */
 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();
 }
 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();
     }
 }