Jpgraph is a very powerful third-party reporting tool in the php tutorial. It is said that it can complete everything 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 ();
?>
: