cancel
Showing results for 
Search instead for 
Did you mean: 

New Platform - PEAR Image_Graph package problems

discostu
Newbie
Posts: 8
Registered: ‎20-02-2014

New Platform - PEAR Image_Graph package problems

Hi Folks,
After experiencing some odd behaviour regarding SQLite3 databases I've now discovered some odd behaviour regarding the PEAR Image_Graph package. This package uses the Image_Canvas package which in turn uses the GD2 library to produce graphs as PNG files. The PEAR packages are in a "pear" folder in my "public" folder. I have a website for recording the scores of a card game. I use Image_Graph to produce graphs using the results of completed games on the "stats" page and graphs of the game in progress on the "score_sheet" page.
The website works on Windows 7 + Xampp, Xubuntu + lighttpd and the old Plusnet platform. The same class is used to create the Image_Graph. Then each graph populates the graph with its particular datasets. On the new platform the 12 graphs on the "stats" page are produced correctly but the 3 graphs on the "score_sheet" page are not. Problems include missing axis lines, missing marker symbols, missing legends and the wrong colours.
I've created a page http://ccgi.therussellmob.plus.com/test-image-graph.php to produce a graph using hard-coded data that has the legend missing on the new platform but is OK on the others. The PHP is available as test-image-graph.php.txt. Another graph image showing the other problems is available at http://ccgi.therussellmob.plus.com/graphs/rfh.png.
The PHP appears to be correct (at least on the three other platforms). Does anyone have an inkling as to why the produced PNG files are different on the new platform? I'm at a loss to understand what's going on.
Thanks,
Stuart
7 REPLIES 7
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: New Platform - PEAR Image_Graph package problems

PHP_OS on the new server is Linux so it should define FONTNAME as FreeSans. I haven't checked what fonts are available but the legend might be missing because that isn't one of them.
Sorry, I've no ideas/suggestions concerning the other problems you mentioned.
David
David
discostu
Newbie
Posts: 8
Registered: ‎20-02-2014

Re: New Platform - PEAR Image_Graph package problems

Hi David,
Many thanks for taking a look and replying.
When I first started using Image_Graph the font caught me out. The examples used Verdana but this didn't work on Linux. Eventually, after looking at the code, I just copied the FreeSans font to the Image/Canvas directory. Not pretty but it worked. I repeated the trick on the old platform and the file is present on the new platform.
I forgot to mention in my initial post I fixed a "bug". On the three working platforms by default the plotarea of the graph has a white background and border. On the new platform the default plotarea background and border are black. I fixed this by invoking a couple of functions to set the colour explicitly.
Why the difference? I've since discovered the PHP gd_info function which offers an explanation. I hope. The "GD Version" on my Xubuntu + lighttpd is "2.0", on my Windows 7 + Xampp it's "bundled (2.0.34 compatible)" and on the new platform it's "bundled (2.1.0 compatible)". Presumably, the GD library guys decided the default background and border colour should be black rather than white between version 2.0 and 2.1.
Unfortunately, that doesn't help explain why the graphs on the "stats" page work but those on the "score_sheet" page don't. I've even added another two graphs to the "stats" page and they too work fine. I'm running out of straws to clutch at!
Thanks,
Stuart
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: New Platform - PEAR Image_Graph package problems

I'm more familiar with GD on Perl than on PHP. However I thought GD used the first colour added to its colour table as the default background colour.
The "score sheet" code might behave differently on the new server because it runs PHP 5.3. It could be generating warning messages which don't display because the default setting is to suppress them (to avoid file paths being exposed). You could try putting

php_value display_errors 1
php_value error_reporting 32767

into a .htaccess file in /public to see if anything is reported.
David
David
discostu
Newbie
Posts: 8
Registered: ‎20-02-2014

Re: New Platform - PEAR Image_Graph package problems

Hi David,
Turned on the error reporting and there are a lot of "Strict Standards" warnings produced by the Image_Graph PHP code about static functions. For example "Non-static method Image_Canvas::factory should not be called statically ...". However, these warnings are the same for the working graphs.
As mentioned previously all the graphs work fine on Windows 7 using XAMPP 1.7.7 which includes PHP 5.3.8 and GD 2.0.34. The new platform uses GD 2.1.0 so I thought I'd try that version. I've installed XAMPP 1.8.2 which includes PHP 5.4.25 and GD 2.1.0. This setup exhibits the same problem as on the new platform.
I know the PHP versions have changed but I'm inclined to think the cause is hiding in the changes between GD 2.0.34 and GD 2.1.0.
Thanks,
Stuart
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: New Platform - PEAR Image_Graph package problems

Yes, it does look as though the upgrade to GD causes the problem. Has Image_Graph been upgraded to support GD 2.1?
David
David
discostu
Newbie
Posts: 8
Registered: ‎20-02-2014

Re: New Platform - PEAR Image_Graph package problems

Hi David,
Rather than devote a lot of time and effort to investigating the differences between GD 2.0.34 and 2.1.0 I decided to look for another PHP graph library. I quick search lead me to pChart (see http://www.pchart.net).
There are some differences in approach between the two libraries. For example, with Image Graph you define a plot area which includes the axis labels but a pChart Graph Area does not. HTML source for Image Maps can be generated automatically by Image Graph but not by pChart. Although you can access the array of coordinates and output the HTML map yourself quite easily.
A definite bonus for pChart is the fact it's under active development and has an active forum community.
All my graphs are generated correctly using pChart for both GD 2.0.34 and GD 2.1.0. Maybe the problem was with Image Graph all along.
Stuart
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: New Platform - PEAR Image_Graph package problems

Thanks for that feedback.
Are those 'strict' warning messages present when using pChart? If such messages cause annoyance they can be removed by changing the error_reporting value to 30719. Of course that doesn't fix the problem, just suppresses the warnings.
David
David