Example of a jpgraph column chart for PHP reports

Source: Internet
Author: User

Jpgraph is a very powerful Third-party reporting tool in PHP and is said to be able to do all the graphics you want ...

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

$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:

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.