Viewing file: 9.php (1.94 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
// JpGraph does not work with notices enabled
error_reporting(E_ALL ^ E_NOTICE);
// Include the necessary JpGraph libraries
require_once ('jpgraph.php'); // Core engine
require_once ('jpgraph_pie.php'); // Pie graph
require_once ('jpgraph_pie3d.php'); // 3D Pie graph
// Sample sales data: could be a database query
$xdata=array('Mousemats','Pens','T-Shirts','Mugs'); // X Axis
$ydata=array (35,43,15,10); // Y Axis
// Set up the graph
$graph = new PieGraph(400,200,'auto'); // Width, height,cache filename
$graph->SetMarginColor('yellow'); // Margin color yellow
$graph->SetShadow(); // Use a drop shadow
$graph->SetFrame(true,'red'); // Red frame round the image
// Set up the graph title
$graph->title->Set('March Sales'); // Title text
$graph->title->SetColor('navy'); // Title color
$graph->title->SetFont(FF_VERDANA,FS_BOLD,14); // Title font
// Set up the pie segment legend
$graph->legend->SetColor('navy'); // Legend text color
$graph->legend->SetFillColor('orange'); // Legend background color
$graph->legend->Pos(0.05,0.5); // Legend position
// Set up 3D pie chart
$pie = new PiePlot3d($ydata); // Instantiate 3D pie with Y data
$pie->SetLegends($xdata); // Add X data to legends
$pie->SetTheme('water'); // Set color theme (earth|pastel|sand|water)
$pie->SetCenter(0.39); // Center relative to X axis
$pie->SetSize(100); // Size of pie radius in pixels
$pie->SetAngle(30); // Set tilt angle of pie
$pie->ExplodeSlice(0); // Pop out a slice
$pie->ExplodeSlice(1); // Pop out another slice
// Set up values against each segment
$pie->value->SetFont(FF_VERDANA,FS_NORMAL,10); // The font
$pie->value->SetColor('navy'); // Font color
// Finishing
$graph->Add($pie); // Add bar plot to graph
$graph->Stroke(); // Send to browser
?>
|