// 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(40, 60, 21, 33); $piepos = array(0.2, 0.35, 0.5, 0.25, 0.3, 0.7, 0.85, 0.7); $titles = array('USA', 'Sweden', 'South America', 'Australia'); $n = count($piepos) / 2; // A new Graph\Graph $graph = new \PieGraph(450, 300, 'auto'); $theme_class = "PastelTheme"; $graph->SetTheme(new $theme_class()); // Setup background $graph->SetBackgroundImage('worldmap1.jpg', BGIMG_FILLFRAME); // Setup title $graph->title->Set("Pie plots with background image"); $graph->title->SetColor('white'); $graph->SetTitleBackground('#4169E1', TITLEBKG_STYLE2, TITLEBKG_FRAME_FULL, '#4169E1', 10, 10, true); $p = array(); // Create the plots for ($i = 0; $i < $n; ++$i) { $p[] = new \PiePlot3D($data); } for ($i = 0; $i < $n; ++$i) { $graph->Add($p[$i]); } // Position the four pies and change color for ($i = 0; $i < $n; ++$i) { $p[$i]->SetCenter($piepos[2 * $i], $piepos[2 * $i + 1]);
require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_pie.php'; require_once 'jpgraph/jpgraph_pie3d.php'; // Some data $data = array(array(80, 18, 15, 17), array(35, 28, 6, 34), array(10, 28, 10, 5), array(22, 22, 10, 17)); $piepos = array(0.2, 0.4, 0.65, 0.28, 0.25, 0.75, 0.8, 0.75); $titles = array('USA', 'Sweden', 'South America', 'Australia'); $n = count($piepos) / 2; // A new graph $graph = new PieGraph(550, 400, 'auto'); // Specify margins since we put the image in the plot area $graph->SetMargin(1, 1, 40, 1); $graph->SetMarginColor('navy'); $graph->SetShadow(false); // Setup background $graph->SetBackgroundImage('worldmap1.jpg', BGIMG_FILLPLOT); // Setup title $graph->title->Set("Pie plots with background image"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 20); $graph->title->SetColor('white'); $p = array(); // Create the plots for ($i = 0; $i < $n; ++$i) { $d = "data{$i}"; $p[] = new PiePlot3D($data[$i]); } // Position the four pies for ($i = 0; $i < $n; ++$i) { $p[$i]->SetCenter($piepos[2 * $i], $piepos[2 * $i + 1]); } // Set the titles
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(); }