PHP creates a 3D pie chart effect instance using Jpgraph

Source: Internet
Author: User
This article mainly introduces PHP using Jpgraph to create 3D pie chart effect, combined with an example of PHP based on jpgraph drawing of the principle, implementation steps and related operation skills, the need for friends can refer to the next

This example explains PHP's use of jpgraph to create a 3D pie chart effect. Share to everyone for your reference, as follows:

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 (89, 78, 99, 65, 92); 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 a pie chart to the chart object $graph->stroke (); Output image

The results of the operation are as follows:

The above is the whole content of this article, I hope that everyone's study has helped.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.