Digma Chauhan
Digma Chauhan

Reputation: 31

How to display graph from database values using php?

I want to create graph using php. I have tested jpgraph example. But it display error like

> The image “http://localhost/test/jpgraphtest.php” cannot be displayed
> because it contains errors.

<?php
include('phpgraphlib.php');
$graph = new PHPGraphLib(500,350);
$data = array(12124, 5535, 43373, 22223, 90432, 23332, 15544, 24523,
 32778, 38878, 28787, 33243, 34832, 32302);
$graph->addData($data);
$graph->setTitle('Widgets Produced');
$graph->setGradient('red', 'maroon');
$graph->createGraph();
?>

Upvotes: 1

Views: 3468

Answers (1)

Sina R.
Sina R.

Reputation: 1788

check this link I think its perfect.

http://pchart.sourceforge.net/

(also you should configure php to enable image creating).
In Windows, you'll include the GD2 DLL php_gd2.dll as an extension in php.ini. The GD1 DLL php_gd.dll was removed in PHP 4.3.2. Also note that the preferred truecolor image functions, such as imagecreatetruecolor(), require GD2.

check these links. http://www.php.net/manual/en/image.requirements.php
http://www.php.net/manual/en/image.installation.php
http://www.php.net/manual/en/image.configuration.php examples:

ex01

ex02

Upvotes: 2

Related Questions