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