示例#1
0
// $Id
// Example of pie with center circle
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Some data
$data = array(50, 28, 25, 27, 31, 20);
// A new pie graph
$graph = new Graph\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 Plot\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
示例#2
0
use Amenadiel\JpGraph\Plot;
// Some data
$data = array(50, 28, 25, 27, 31, 20);
// A new pie graph
$graph = new Graph\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 Plot\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
示例#3
0
use Amenadiel\JpGraph\Plot;
// Some data
$data = array(50, 28, 25, 27, 31, 20);
// A new pie graph
$graph = new Graph\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("Plot\\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 Plot\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