How to setup jpgraphs and wxgraphs

I just typed up an email to someone explaining all the steps to get jpgraphs working.

If anyone is interested:

  1. Copy test.php (in the attached zip) to your web server root. Browse to it. It will tell you what version of php your web server supports, if any.

  2. Scroll down the resulting page and make sure GD Support is enabled.

  3. Go to the JPGraph home page and download the version appropriate to the version of PHP on your server, ie, 1.22 for PHP4 or 2.2 for PHP5.

  4. Go to Broadstairs’ home page to download the wxgraphs.zip file.

  5. Edit graphsconf.php in the wxgraphs folder:
    a. Make sure these two lines point to the correct folders:

$hostloc = “${WEBROOT}/”; //must have trailing slash
$jploc = “${WEBROOT}/jpgraph-1.22/src/”; //must have trailing slash

b. Make any necessary changes to reflect the units you want to use. Directions are in the graphsconf.php file.

  1. Create a new folder under jpgraph-x.xx called ttf.

  2. Upload hardpath.php (in the attached zip) to the jpgraph-x.xx/ttf folder on your web server and browse to it.
    a. You’ll get a line that looks something like:

/homepages/24/d87962498/htdocs/jpgraph-1.22/ttf/

  1. Copy this line to the clipboard.

  2. Edit jpg-config.inc.php in the jpgraph-x.xx/src folder:
    a. Uncomment the line that begins with DEFINE(“TTF_DIR”,". (Line 40 in my editor)
    b. Replace the default path with the result of browsing to hardpath.php.

  3. Upload the jpgraph-x.xx folder to your web server. You do not need to upload the jpgraph-x.xx/docs folder.

  4. Upload the wxgraphs folder to your web server.

  5. Upload arialbd.ttf and arial.ttf from your /windows/fonts folder to /jpgraph-x.xx/ttf folder on the web server.

  6. You should now be able to insert graphs by including image links to the files in the wxgraphs folder in your web pages.

a. for example

  1. Delete test.php from your web server when your graphs are working.

See mine at www.thanko.info/rainfall.php and http://www.thanko.info/trend_graphs.php.

hardpath.php is thanks to Pinto from this thread:

http://discourse.weather-watch.com/t/27536

Any comments, changes or suggestions are welcomed.


files.zip (266 Bytes)

Well done Tim, I was about to do something similar but you beat me to it.

Stuart

Please note the correct location for downloading the zip file is https://www.stella-maris.org.uk/code.phtml

Looks like a FAQ that would be helpful. Maybe someone could make it one.

–Dave

Funny you should mention that, Stuart and I had been discussing it too. The FAQ is defined as “Frequently Asked Questions about Weather Display”, this very useful information doesn’t fit that definition. I have made this topic a sticky at the top of this forum.

Tim

I suggest adding a line about deleting test.php after it’s used, I believe it’s a security risk. You could change the title to something like “How to setup jpgraph” so it’s clear this is informational rather than a question.

Niko,

I’ve made the changes you suggested. Let me know if you like it better.

Whatever is appropriate, whether a faq or a sticky, is fine with me.

I’m happy to contribute something worthwhile.

Niko,

I just noticed that you use in your avatar one of the coolest words in the English language. :smiley:

Thanks for noticing :lol:

Could someone tell me where the wxgraph folder is. I have downloaded jpgraph-1.22 and unzipped it but cannot find a wxgraph folder.

Thanks,

Rick #-o

You need to download wxgraphs from here:

http://www.stella-maris.org.uk/code.shtml

Probably should add that to the directions…

Tim.

Thank you so much…

Rick

Can someone give me some help on the coding for this. I am getting the error:

Parse error: parse error, unexpected ‘.’ in /home/content/k/4/r/k4rcb/html/weather/wxgraph/graphsconf.php on line 7

wxgraph/graphsconf.php

$hostloc = “${./WEBROOT}/”; //must have trailing slash
$jploc = “${./WEBROOT}/jpgraph-1.22.5/src/”; //must have trailing slash

clientraw files and jpgraph-1.22/src are in the ./weather folder.

Thanks again for your help,

Rick

Kewee,

Remove the . before WEBROOT in both lines.

Tim,

Sorry the ./ was removed. Typo on my part.

These are the errors:

Warning: main(/home/content/k/4/r/k4rcb/html/jpgraph-1.22.5/src/jpgraph.php): failed to open stream: No such file or directory in /home/content/k/4/r/k4rcb/html/weather/wxgraph/baro_24hr.php on line 4

Warning: main(/home/content/k/4/r/k4rcb/html/jpgraph-1.22.5/src/jpgraph.php): failed to open stream: No such file or directory in /home/content/k/4/r/k4rcb/html/weather/wxgraph/baro_24hr.php on line 4

Warning: main(): Failed opening ‘/home/content/k/4/r/k4rcb/html/jpgraph-1.22.5/src/jpgraph.php’ for inclusion (include_path=‘.:/usr/local/lib/php’) in /home/content/k/4/r/k4rcb/html/weather/wxgraph/baro_24hr.php on line 4

Warning: main(/home/content/k/4/r/k4rcb/html/jpgraph-1.22.5/src/jpgraph_line.php): failed to open stream: No such file or directory in /home/content/k/4/r/k4rcb/html/weather/wxgraph/baro_24hr.php on line 5

Warning: main(/home/content/k/4/r/k4rcb/html/jpgraph-1.22.5/src/jpgraph_line.php): failed to open stream: No such file or directory in /home/content/k/4/r/k4rcb/html/weather/wxgraph/baro_24hr.php on line 5

Warning: main(): Failed opening ‘/home/content/k/4/r/k4rcb/html/jpgraph-1.22.5/src/jpgraph_line.php’ for inclusion (include_path=‘.:/usr/local/lib/php’) in /home/content/k/4/r/k4rcb/html/weather/wxgraph/baro_24hr.php on line 5

Fatal error: Cannot instantiate non-existent class: graph in /home/content/k/4/r/k4rcb/html/weather/wxgraph/baro_24hr.php on line 32

The page is http://www.dominion-llc.com/weather/wxgraph/baro_24hr.php

As you can see I am very much a novice at PHP.

Thanks,

Rick

I’m also having a problem. My clientraw files, jpgraph, and wxgraphs are all located at /wx/
My config files is set as follows:

//where are your clientraw*-files and JPGraph relative to where this file is
//note you should only need to change the jpgraph directory if you do not use standard names
$hostloc = “${WEBROOT}/”; //must have trailing slash
$jploc = “${WEBROOT}/wx/jpgraph-1.22/src/”; //must have trailing slash

If I try to load a image from the wxgraphs directory I get a page not found error. I can see the file is there when I ftp to the same directory. Any idea what I did wrong?

http://www.lesdiefenbach.org/wx/wxgraphs/rain_1hr.php

Kewee,

What folders did you create for jpgraph and wxgraph? Make sure the paths match exactly, including case.

dafuser,

Are all your weather files in /wx? I think you need to change $hosloc to reflect that.

Wxgraph and jpgraphs folders are setup under /weather and are named wxgraph and jpgraphs-1.22. All others files are in the /weather folder.
too.

Thanks for your help.

Rick

Yes, all files are under /wx/ I changed the WEBROOT to poit to /wx/ but still get the files not found error when I try to access any of the image files in the wxgraph folder

Could you both post the results of running hardpath.php?

My hardpath.php is located at:

http://www.lesdiefenbach.org/wx/jpgraph-1.22/ttf/hardpath.php

The results I get when running it are:

/home/content/d/a/f/dafuser/html/wx/jpgraph-1.22/ttf/