PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Images » Image_Graph » Bug #4785

More descriptive error messages, use PEAR_Error or Exceptions

Details

Request #4785More descriptive error messages, use PEAR_Error or Exceptions
Submitted2005-07-11 07:41 UTC
Fromnohn at php dot net
StatusOpen
PackageImage_Graph
PHP Version5.0.4
OSLinux
Roadmaps(Not assigned)

Comments

[2005-07-11 07:41 UTC] nohn at php dot net

Description:
------------
Initalize an Image_Graph (0.4.0) object fails

Reproduce code:
---------------
<?php
require_once 'Image/Graph.php';

$graph = Image_Graph::factory('graph', 300, 100);
$plotarea = $graph->addNew('plotarea');

$daten = Image_Graph::factory('dataset');
$daten->addPoint('Test', 43.0);
$daten->addPoint('Hans', 23.0);
$daten->addPoint('Wurst', 12.0);
$plot = $plotarea->addNew('bar', $daten);

$graph->done();
?>

Expected result:
----------------
A graph is painted.

Actual result:
--------------
[client 82.83.253.83] PHP Warning: imagecreatetruecolor() [<a href='function.imagecreatetruecolor'>function.imagecreatetruecolor</a>]: Invalid image dimensions in /opt/php/lib/php/Image/Graph/Driver/GD.php on line 177

[2005-07-11 16:58 UTC] pear dot nosey at veggerby dot dk

This a bug in your graph :)

The factory method takes as second parameter an array of parameters to pass to the constructor of the object. This means that you should simply change your code from:

$graph = Image_Graph::factory('graph', 300, 100);

to

$graph = Image_Graph::factory('graph', array(300, 100));

And you should get the expected result.

regards
Jesper

[2005-07-27 21:17 UTC] pear dot nosey at veggerby dot dk

Well I guess that's a good idea - you know it's just one of these things that are at the end of the list (and seem to stay there :))

regards
Jesper