Home > Backend Development > PHP Tutorial > PHP report jpgraph histogram example_PHP tutorial

PHP report jpgraph histogram example_PHP tutorial

WBOY
Release: 2016-07-21 14:54:26
Original
975 people have browsed it

jpgraph is a very, very powerful third-party reporting tool in PHP. It is said to be able to complete all the graphics you want...

Novices who are new to jpgraph will definitely encounter various problems, such as garbled characters. This case is produced by jpgraph3.0.7. After many experiments by myself, the garbled problem is solved

$datay=array(); //Vertical coordinate data

$datax=array(); //Abscissa 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); //Image height and 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 graph”));
$graph-> ;xaxis->title->Set(iconv(“UTF-8″, “gb2312″,”User Name”));
$graph->yaxis->title->Set(iconv( “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();

?>

Rendering:

jpgraph download address: jpgraph-002d3.0.7.tar.gz

Original address: http://www.52blogger.com/archives/539

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364589.htmlTechArticlejpgraph is a very, very powerful third-party reporting tool in php. It is said to be able to complete everything you want for graphics novices When you first meet jpgraph, you will definitely encounter various problems, such as garbled characters and so on...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template