Example of a jpgraph histogram for a PHP report

Source: Internet
Author: User

Introduction: This is a detailed page of The jpgraph bar graph instance for PHP reports. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 345301 'rolling = 'no'>

Jpgraph is a very powerful third-party reporting tool in PHP. It is said that it can complete all the graphics you want...

When a newbie first learns about jpgraph, he will certainly encounter various problems, such as gibberish. This case is made in jpgraph3.0.7 and has been tested several times to solve the garbled problem.

<? PHP

$ 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 ();

?>

  

:

Jpgraph: http://down.qiannao.com/space/file/bingxingke/share/2010/6/29/jpgraph-002d3.0.7.tar.gz/.page

From: http://www.52blogger.com/archives/539

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/345301.html pageno: 4.

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.