using the Jpgraph class library to make the chart function and its powerful, not only can draw the plane graph, but also can draw the graph with 3D effect. Direct use of the GD2 Library can draw a variety of graphics, of course, including 3D pie chart, but the use of GD2 function to draw 3D graphics takes a lot of time, and relatively complex, and the use of Jpgraph class library to draw 3D pie chart is very convenient and fast. Example: Using Jpgraph to create a 3D pie chart for departmental performance comparison. The steps are as follows:
(1) Import Jpgraph class library and pie chart drawing function in the program.
Require_once ' jpgraph/src/jpgraph.php '; Import jpgraph class library require_once ' jpgraph/src/jpgraph_pie.php '; Import the Jpgraph class library's pie chart function require_once ' jpgraph/src/jpgraph_pie3d.php '; Import the 3D pie chart feature of the Jpgraph class library
(2) Creating a numeric array as a statistical data
$data = Array (for the duration of the (); Set up statistics
(3) Create a chart object and set the title content and font of the chart.
$graph = new Piegraph, $graph->setshadow (), $graph->title->set (iconv (' utf-8 ', ' gb2312//ignore ', ' $graph->title->setfont (Ff_simsun, fs_bold);
(4) Create a 3D pie chart object and enter a chart
$pieplot = new Pieplot3d ($data); Create 3D Pie Chart Object $pieplot->setcenter (0.5, 0.5); $department = Array (' ASP ', ' JSP ', ' PHP ', '. NET ', ' C + + ');//Set the content of the text box $pieplot->setlegends ($department); $graph->legend->setfont (Ff_simsun, Fs_bold) ;//Set Font $graph->legend->setlayout (Legend_hor); $graph->legend->pos (0.5, 0.98, ' center ', ' Bottom ');// The position of the legend text box $graph->add ($pieplot);//Add the pie chart to the chart object $graph->stroke ();//Output image
The results of the operation are as follows:
Create a 3D pie chart with Jpgraph