function PieChart($w, $h, $title, $data, $dataL, $output) { $graph = new PieGraph($w, $h, "auto"); $graph->SetFrame(false); $graph->SetShadow(false); $graph->title->Set($title); $graph->title->SetFont(FF_FONT1, FS_BOLD); $p1 = new PiePlot3D($data); $p1->SetAngle(20); $p1->SetSize(0.5); $p1->SetCenter(0.45); $p1->SetLegends($dataL); $graph->Add($p1); $graph->Stroke($output); }
function dansguardian_buildGraph_week(){ include_once(dirname(__FILE__).'/listener.graphs.php'); $sql="SELECT COUNT( sitename ) AS tcount ,TYPE FROM `dansguardian_events` WHERE YEARWEEK( zDate ) = YEARWEEK( NOW( ) ) GROUP BY TYPE ORDER BY tcount DESC LIMIT 0 , 30"; if(isset($_GET["dansguardian-stats-query"])){return dansguardian_buildGraph_by_type();} $md5=md5($sql); $q=new mysql(); $results=$q->QUERY_SQL($sql,'artica_events'); $html="<table style='width:100%'>"; while ($ligne = mysql_fetch_array($results)) { if($ligne["TYPE"]<>null){ $data[]=$ligne["tcount"]; $labels[]=$ligne["TYPE"]; $jsa="javascript:ShowGraphDansGuardianDetails('{$ligne["TYPE"]}','week');"; $html=$html . "<tr " . CellRollOver()."> <td width=1%><img src='img/fw_bold.gif'> <td><strong style='font-size:11px'>{$ligne["tcount"]}</td> <td><strong style='font-size:11px'><a href='#' OnClick=\"$jsa\">{$ligne["TYPE"]}</a></td> </tr> "; $js[]="$jsa"; } } $html=$html."</table>"; if (!is_array($data)){ die("<center>".ICON_DANSGUARDIAN_STATISTICS()."</center>"); } $tpl=new templates(); $p1 = new PiePlot3D($data); $p1->SetSize(.4); $p1->SetAngle(75); $p1->SetCSIMTargets($js,$labels); $p1->SetCenter(0.3,0.5); $p1->ExplodeAll(10); $p1->SetLegends($labels); //$p1->SetSliceColors(array('red','blue','green','navy','orange')); $graph = new PieGraph(470,350,'auto'); $graph->Add($p1); $graph->title->Set("Week"); $graph->title->SetFont(FF_FONT1,FS_BOLD); $graph->legend->Pos(0,0,'right','top'); $graph->legend->SetFillColor('white'); $graph->legend->SetLineWeight(0); //$graph->legend->SetLayout(LEGEND_HOR); //hori $graph->legend->SetColor('black'); $graph->legend->SetShadow("white",0); $graph->SetFrame(false); if(function_exists("imageantialias")){$graph->img->SetAntiAliasing();} $mapName = 'MapName'; $imgMap = $graph->GetHTMLImageMap($mapName); $graph->Stroke("ressources/logs/$md5.png"); $html= " <table style='width:100%'> <tr> <td valign='top'> $imgMap ".RoundedLightWhite(" <img src='ressources/logs/$md5.png' alt='graph' ismap usemap='#$mapName' border='0'>")." </td> <td valign='top'>".RoundedLightWhite($html)."</td> </tr> </table> "; return $html; }
//生成二维数组 $rows_count = count($res); //声明数组 $arraynum0 = array(); $arraycip0 = array(); //解析数组 for ($i = 0; $i < $rows_count; $i++) { array_push($arraynum0, $res[$i][num]); array_push($arraycip0, $res[$i][cip]); } /*************************************************************/ //创建画布 $graph = new PieGraph(990, 276); $graph->SetShadow(); //设置标题名称 $graph->title->Set("应用3D饼形图统计分析全部区域许愿比率"); $graph->title->SetFont(FF_SIMSUN, FS_BOLD); $graph->legend->SetFont(FF_SIMSUN, FS_NORMAL); $size = 0.5; /***********************统计全部许愿比率*************************/ //创建饼形图对象 $p0 = new PiePlot3D($arraynum0); $p0->SetLegends($arraycip0); $p0->SetSize($size); $p0->SetCenter(0.45, 0.48); $p0->SetLegends($arraycip0); $p0->value->SetFont(FF_FONT0); $p0->title->SetFont(FF_SIMSUN, FS_BOLD); /*************************************************************/ $graph->Add($p0); $graph->Stroke();
it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. OCOMON is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Foobar; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ session_start(); include "../../includes/jpgraph/src/jpgraph.php"; include "../../includes/jpgraph/src/jpgraph_pie.php"; include "../../includes/jpgraph/src/jpgraph_pie3d.php"; $graph = new PieGraph(800, 500, "auto"); $graph->SetShadow(); $graph->SetAntiAliasing(); //$titulo=$titulo.$instituicao; $graph->title->Set($_GET['titulo']); $graph->subtitle->Set($_GET['instituicao']); $graph->title->SetFont(FF_FONT1, FS_BOLD); $p1 = new PiePlot3D($_GET['data']); $p1->ExplodeAll(); $p1->SetSize(0.45); $p1->SetCenter(0.35); $p1->SetLegends($_GET['legenda']); $graph->Add($p1); $graph->Stroke();
$res5 = $DB->get_rows_array($sql5); //生成二维数组 $rows_count5 = count($res5); //声明数组 $arraynum5 = array(); $arraycip5 = array(); //解析数组 for ($n = 0; $n < $rows_count5; $n++) { array_push($arraynum5, $res5[$n][num]); array_push($arraycip5, $res5[$n][cip]); } /*************************************************************/ //创建画布 $graph = new PieGraph(320, 246); $graph->SetShadow(); //设置标题名称 $graph->title->Set("统计分析全部区域的[ 奥运会 ] 许愿比率"); $graph->title->SetFont(FF_SIMSUN, FS_BOLD); $graph->legend->SetFont(FF_SIMSUN, FS_NORMAL); $size = 0.3; /***********************统计奥运会许愿比率*************************/ //创建饼形图对象 $p = new PiePlot3D($arraynum5); $p->SetLegends($arraycip5); $p->SetSize($size); $p->SetCenter(0.45, 0.55); $p->value->SetFont(FF_FONT0); $p->title->SetFont(FF_SIMSUN, FS_BOLD); /*************************************************************/ $graph->Add($p); $graph->Stroke();
// Some data $data = array(); $i = 0; $username = "******"; $selectPieGraph = "select SUM(total_Steps), SUM(total_Calories), SUM(total_Floors), SUM(total_Distance) from Data where (username = '******')"; $result = mysqli_query($connection, "{$selectPieGraph}"); while ($row = mysqli_fetch_array($result)) { $data[0] = $row["SUM(total_Steps)"]; $data[1] = $row["SUM(total_Calories)"]; $data[2] = $row["SUM(total_Floors)"]; $data[3] = $row["SUM(total_Distance)"]; } // Create the Pie Graph. $graph = new PieGraph(300, 300); $theme_class = new VividTheme(); $graph->SetTheme($theme_class); // Set A title for the plot $graph->title->Set("Breakdown of holly123's exercise"); // Create $p1 = new PiePlot3D($data); $p1->SetLegends(array("Steps", "Floors", "Calories", "Distance")); $p1->SetCenter(0.5, 0.55); $p1->SetSize(0.3); $p1->SetLabelType(PIE_VALUE_PER); $p1->value->show(); $p1->value->SetFont(FF_FONT0, FS_NORMAL, 12); $graph->Add($p1); $p1->ShowBorder(); $p1->SetColor('black'); //$p1->ExplodeSlice(1); $graph->Stroke();
function crearPie($pdf, $verde, $rojo, $ciclos, $alineacion) { $data = array($verde, $rojo); $labels = array("Valores\ndentro de\nnorma\n(%.1f%%)", "Valores\nfuera de\nnorma\n(%.1f%%)"); $graph = new PieGraph(310, 200); $graph->SetShadow(); $graph->title->Set(utf8_decode("Análisis de resultados " . $ciclos)); $graph->title->SetFont(FF_FONT1, FS_BOLD); $p1 = new PiePlot3D($data); $p1->SetSize(0.5); $p1->SetCenter(0.5); $p1->ExplodeAll(15); $p1->SetStartAngle(60); $p1->SetLabels($labels); $p1->SetLabelPos(0); $p1->value->SetColor('black'); $graph->Add($p1); $p1->SetSliceColors(array('green', 'red')); //$graph->Stroke(); $nombreImagen = '' . uniqid() . '.png'; // Display the graph $graph->Stroke($nombreImagen); if ($alineacion === 'C') { $pdf->Image($nombreImagen, 145, 145, 55, 45); } elseif ($alineacion === 'L') { $pdf->Image($nombreImagen, 90, 145, 55, 45); } elseif ($alineacion === 'R') { $pdf->Image($nombreImagen, 195, 145, 55, 45); } elseif ($alineacion === 'C1') { $pdf->Image($nombreImagen, 75, 205, 55, 45); } elseif ($alineacion === 'L1') { $pdf->Image($nombreImagen, 20, 205, 55, 45); } elseif ($alineacion === 'R1') { $pdf->Image($nombreImagen, 125, 205, 55, 45); } elseif ($alineacion === 'C2') { $pdf->Image($nombreImagen, 75, 160, 55, 45); } unlink($nombreImagen); }
} } // require_once 'ossim_conf.inc'; $conf = $GLOBALS["CONF"]; $jpgraph = $conf->get_conf("jpgraph_path"); require_once "{$jpgraph}/jpgraph.php"; require_once "{$jpgraph}/jpgraph_pie.php"; require_once "{$jpgraph}/jpgraph_pie3d.php"; // Setup the graph. $graph = new PieGraph(400, 150, "auto"); $graph->SetAntiAliasing(); $graph->SetColor("#fafafa"); $graph->SetFrame(true, '#fafafa', 0); if (isset($temp_activado)) { // Create the bar plots $piePlot3d = new PiePlot3D($data['value']); $piePlot3d->SetSliceColors(array(COLORPIE1, COLORPIE2, COLORPIE3, COLORPIE4, COLORPIE5, COLORPIE6, COLORPIE7, COLORPIE8)); //$piePlot3d->SetAngle(30); $piePlot3d->SetHeight(12); $piePlot3d->SetSize(0.5); $piePlot3d->SetCenter(0.26, 0.4); // Labels //$piePlot3d->SetLabels($data['title'],1); $piePlot3d->SetLegends($data['title']); $graph->Add($piePlot3d); $graph->legend->SetPos(0.01, 0.6, 'right', 'bottom'); } // Finally send the graph to the browser $graph->Stroke(); unset($graph);
if ($options['graph_pie_antialiasing']) { $graph->SetAntiAliasing(); } // Setup graph title $graph->title->Set($data['title']); $graph->title->SetFont(FF_FONT1, FS_BOLD); // Create pie plot if ($options['graph_pie_3dangle'] == 0) { $plot = new PiePlot($data['values']); } else { $plot = new PiePlot3D($data['values']); $plot->setAngle($options['graph_pie_3dangle']); } //$plot->SetFont(FF_VERDANA,FS_BOLD); //$plot->SetFontColor("darkred"); $plot->SetSize(0.3); $plot->setCenter($options['graph_pie_center']); if (count($data['legend'] > 10)) { $i = 0; foreach ($data['legend'] as $key => $val) { if ($i > 10) { unset($data['legend'][$key]); } $i++; } } $plot->SetLegends($data['legend']); $plot->setTheme($options['graph_pie_theme']); if ($options['graph_plotshadow']) { $plot->SetShadow(); }
// si todos los valores están a 0, el piegraph da el siguiente error 'Illegal pie plot. Sum of all data is zero for pie plot' $temp_activado = true; } } // require_once 'ossim_conf.inc'; $conf = $GLOBALS["CONF"]; $jpgraph = $conf->get_conf("jpgraph_path"); require_once "{$jpgraph}/jpgraph.php"; require_once "{$jpgraph}/jpgraph_pie.php"; require_once "{$jpgraph}/jpgraph_pie3d.php"; // Setup the graph. $graph = new PieGraph(350, 150, "auto"); $graph->SetAntiAliasing(); $graph->SetColor("#fafafa"); $graph->SetFrame(true, '#fafafa', 0); if (isset($temp_activado)) { // Create the bar plots $piePlot3d = new PiePlot3D($dataValue1); $piePlot3d->SetSliceColors(array(COLORPIE1, COLORPIE2, COLORPIE3, COLORPIE4, COLORPIE5, COLORPIE6, COLORPIE7, COLORPIE8)); //$piePlot3d->SetAngle(30); $piePlot3d->SetHeight(12); $piePlot3d->SetSize(0.3); $piePlot3d->SetCenter(0.5, 0.3); // Labels $piePlot3d->SetLabels(array($groupTit1, $groupTit2), 1); $graph->Add($piePlot3d); } // Finally send the graph to the browser $graph->Stroke(); unset($graph);
// content="text/plain; charset=utf-8" require_once '../../vendor/autoload.php'; \JpGraph\JpGraph::load(); \JpGraph\JpGraph::module('pie'); \JpGraph\JpGraph::module('pie3d'); // 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 3 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(80); // Adjust projection angle $p1->SetAngle(45); // As a shortcut you can easily explode one numbered slice with $p1->ExplodeSlice(3); // Setup the slice values $p1->value->SetFont(FF_ARIAL, FS_BOLD, 11); $p1->value->SetColor("navy"); $p1->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct")); $graph->Add($p1); $graph->Stroke();
require "../../conexion.php"; $datos_genero = array(); $datos_puntaje = array(); $generos = "SELECT SUM(visitas),genero FROM juegos RIGHT JOIN genero_juego ON(juegos.id_genero=genero_juego.id_genero) GROUP BY genero\n"; $resultado_genero = mysql_query($generos) or die("Error" . $generos); while ($array_generos = mysql_fetch_array($resultado_genero)) { array_push($datos_genero, $array_generos['genero']); array_push($datos_puntaje, $array_generos['0']); } //print_r($datos_genero); //print_r($datos_puntaje); //$data = array(40,60,21,33); $graph = new PieGraph(450, 200, "auto"); $graph->img->SetAntiAliasing(); $graph->SetMarginColor('gray'); //$graph->SetShadow(); // Setup margin and titles $graph->title->Set("Cantidad de visitas según género"); $p1 = new PiePlot3D($datos_puntaje); $p1->SetSize(0.35); $p1->SetCenter(0.5); // Setup slice labels and move them into the plot $p1->value->SetFont(FF_FONT1, FS_BOLD); $p1->value->SetColor("black"); $p1->SetLabelPos(0.2); //$nombres=array("pepe","luis","miguel","alberto"); $p1->SetLegends($datos_genero); // Explode all slices $p1->ExplodeAll(); $graph->Add($p1); $graph->Stroke();
if (isset($host[$y])) { array_push($targ, $_SERVER["PHP_SELF"] . "?pageId=Search&slice=1&table={$table}&excludeHost=0&host2=&host%5B%5D={$host[$y]}&excludeFacility=1&excludePriority=1&date={$date}&time=&date2={$date2}&time2=&limit=100&orderby=datetime&order=DESC&msg1=&msg2=&msg3=&collapse=1"); } else { $array_count++; } } // die(print_r($targ)); $p1->SetCSIMTargets($targ, $alts); // Horizontal: 'left','right','center' // Vertical: 'bottom','top','center' $graph->legend->SetAbsPos(10, 20, 'right', 'top'); // $graph->legend->Pos(0.5,0.5); // $graph->legend->SetColumns(2); $graph->legend->SetFont(FF_VERDANA, FS_NORMAL, 8); // Adjust size and position of plot $p1->SetSize(0.4); $p1->SetCenter(0.39, 0.6); // Setup slice labels and move them into the plot $p1->value->SetFont(FF_FONT1, FS_BOLD); $p1->value->SetColor("darkred"); $p1->SetLabelPos(0.7); // Set perM > 1 below to enable per million labels $perM = 0; if ($perM < 1) { $p1->SetLabelType(PIE_VALUE_ABS); $p1->value->SetFormat("%d"); } else { $p1->SetLabelType(PIE_VALUE_PER); $p1->value->SetFormat(".%dM"); } // Set percentage to enable per percent labels
<?php include "../jpgraph.php"; include "../jpgraph_pie.php"; include "../jpgraph_pie3d.php"; $data = array(40, 60, 21, 33); $graph = new PieGraph(300, 200, "auto"); $graph->SetShadow(); $graph->title->Set("A simple Pie plot"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $p1 = new PiePlot3D($data); $p1->SetSize(0.5); $p1->SetCenter(0.45); $p1->SetLegends($gDateLocale->GetShortMonth()); $graph->Add($p1); $graph->Stroke(); ?>
public function pie_chart($piedata, $legentdata, $title) { require_once 'Examples/jpgraph/jpgraph.php'; require_once 'Examples/jpgraph/jpgraph_pie.php'; require_once 'Examples/jpgraph/jpgraph_pie3d.php'; $graph = new PieGraph(800, 450); $graph->SetShadow(); $graph->title->SetFont(FF_SIMSUN, FS_BOLD, 12); // 设置中文字体 $graph->title->Set($title . "饼状图"); $graph->SetFrame(false); $p1 = new PiePlot3D($piedata); $p1->SetSize(0.4); $p1->SetCenter(0.3); $p1->SetLegends($legentdata); $p1->SetLabelMargin(10); $graph->legend->SetFont(FF_SIMSUN, FS_NORMAL); $graph->legend->Pos(0.03, 0.18, 'right', 'top'); $graph->legend->SetLayout(LEGEND_HOR); $graph->legend->SetColumns(2); $graph->legend->SetVColMargin(0); $graph->Add($p1); $graph->SetImgFormat('png', 90); $graph->Stroke(); }
/** * chartService::renderPiePlot() - draw the Pie type plot * * @param array $data plot data array reference * @param array $xmlArr xml array reference * @return object refernce Pie plot object reference */ public function renderPiePlot(&$data, &$xmlArr) { $id = $xmlArr['ATTRIBUTES']['ID']; $field = $xmlArr['ATTRIBUTES']['FIELD']; $chartType = $xmlArr['ATTRIBUTES']['CHARTTYPE']; $size = $xmlArr['ATTRIBUTES']['SIZE']; $center = $xmlArr['ATTRIBUTES']['CENTER']; $height = $xmlArr['ATTRIBUTES']['HEIGHT']; $angle = $xmlArr['ATTRIBUTES']['ANGLE']; $labelPos = $xmlArr['ATTRIBUTES']['LABELPOS']; $legendField = $xmlArr['ATTRIBUTES']['LAGENDFIELD']; if ($chartType == "Pie") { $plot = new PiePlot($data); $plot->SetLabelPos($labelPos); } else { if ($chartType == "Pie3D") { $plot = new PiePlot3D($data); $plot->SetHeight($height); $plot->SetAngle($angle); } } list($c1, $c2) = explode(',', $center); $plot->SetCenter($c1, $c2); $plot->SetSize($size); $this->_drawString($plot->value, $xmlArr['VALUE']['ATTRIBUTES']['FONT'], $xmlArr['VALUE']['ATTRIBUTES']['COLOR']); return $plot; }
function generatePie3D($data, $legend_index = 0, $chartData_index = 1, $image = false, $length = 500, $width = 300, $hasShadow = true, $fontFamily = FF_FONT1, $fontStyle = FS_BOLD, $fontSize = '', $fontColor = 'black') { include_once XHELP_JPGRAPH_PATH . '/jpgraph_pie.php'; include_once XHELP_JPGRAPH_PATH . '/jpgraph_pie3d.php'; $graph = new PieGraph($length, $width); if ($hasShadow) { // Add a shadow to the image $graph->setShadow(); } $graph->title->Set($this->meta['name']); $p1 = new PiePlot3D($data[$chartData_index]); $p1->SetSize(0.3); $p1->SetCenter(0.45); $p1->SetStartAngle(20); $p1->SetAngle(45); $p1->SetLegends($data[$legend_index]); $p1->value->SetFont($fontFamily, $fontStyle, $fontSize); $p1->value->SetColor($fontColor); $p1->SetLabelType(PIE_VALUE_PER); $a = array_search(max($data[$chartData_index]), $data[$chartData_index]); //Find the position of maximum value. $p1->ExplodeSlice($a); // Set graph background image if ($image != false) { $graph->SetBackgroundImage($image, BGIMG_FILLFRAME); } $graph->Add($p1); $graph->Stroke(); }