Sample Code of the jpgraph bar chart in a php report

Source: Internet
Author: User
Jpgraph is a very powerful third-party report tool in php. it is said that new beginners who want to complete all the required graphics will certainly encounter various problems, such as garbled code or something, this case is made in jpgraph3.0.7 and has been tested several times to solve the garbled text problem.
Copy codeThe code is as follows:
$ Datay = array (); // ordinate data
$ Datax = array (); // x-axis data
Foreach ($ usernums as $ key => $ value ){
$ Datay [] = $ value;
$ Datax [] = $ userids [$ key];
}
Require_once ('jpgraph-3.0.7/jpgraph. php ');
Require_once ('jpgraph-3.0.7/jpgraph/jpgraph_bar.php ');
// Create the graph. These two cballs are always required
$ Graph = new Graph (800,600); // high Image width
$ Graph-> SetScale ("textlin ");
$ Graph-> xaxis-> SetTickLabels ($ datax );
$ Graph-> xaxis-> SetFont (FF_VERDANA, FS_NORMAL, 10 );
$ Graph-> xaxis-> SetLabelAngle (30 );
$ Graph-> yaxis-> scale-> SetGrace (20 );
$ Graph-> xaxis-> scale-> SetGrace (20 );
// Add a drop shadow
$ Graph-> SetShadow ();
// Adjust the margin a bit to make more room for titles
$ Graph-> img-> SetMargin (40, 30, 20, 40 );
// Create a bar pot
$ Bplot = new BarPlot ($ datay );
// Adjust fill color
$ Bplot-> SetFillColor ('Orange ');
$ Bplot-> value-> Show ();
$ Bplot-> value-> SetFont (FF_ARIAL, FS_BOLD, 10 );
$ Bplot-> value-> SetAngle (45 );
$ Bplot-> value-> SetFormat ('% d ');
$ Graph-> Add ($ bplot );
// Setup the titles
$ Graph-> title-> Set (iconv ("UTF-8", "gb2312", "user consumption report diagram "));
$ Graph-> xaxis-> title-> Set ("UTF-8", "gb2312", "user name "));
$ Graph-> yaxis-> title-> Set ("UTF-8", "gb2312", "user order quantity "));
$ Graph-> xaxis-> title-> SetFont (FF_SIMSUN, FS_BOLD );
$ Graph-> yaxis-> title-> SetFont (FF_SIMSUN, FS_BOLD );
$ Graph-> title-> SetFont (FF_SIMSUN, FS_BOLD );
// Display the graph
$ Graph-> Stroke ();
?>

:

Official website http://jpgraph.net/download/ network manager home http://www.bitsCN.com/codes/38194.html

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.