Novice first know Jpgraph will encounter a variety of problems, such as garbled something, this case is jpgraph3.0.7 production, also through my many experiments, solve garbled problem
Copy Code code as follows:
<?php
$datay =array (); Ordinate data
$datax =array (); Horizontal coordinate data
foreach ($usernums as $key => $value) {
$datay [] = $value;
$datax [] = $userids [$key];
}
Require_once (' jpgraph-3.0.7/jpgraph/jpgraph.php ');
Require_once (' jpgraph-3.0.7/jpgraph/jpgraph_bar.php ');
Create the graph. These two calls 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" 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 Chart"));
$graph->xaxis->title->set (Iconv ("Utf-8″," Gb2312″, "user name"));
$graph->yaxis->title->set (Iconv ("Utf-8″," Gb2312″, "Number of User Orders"));
$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 ();
?>
Effect Chart:
The official website http://jpgraph.net/download/cloud-Habitat community download address http://www.jb51.net/codes/38194.html