Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Cumulus Server Sided JpGraph Graphs

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
TNETWeather

Cumulus Server Sided JpGraph Graphs

Post by TNETWeather »

.
Cumulus Server Sided JpGraph Graphs

Image

This is a first shot at generating JpGraph graphs for various data collected from realtime.txt files. JpGraph is available in both a free and commercial versions and works with PHP4 and PHP5 based servers.

More info about JpGraph can be found: http://www.aditus.nu/jpgraph/

These generated graphs were designed to look a bit like the earlier Flash versions in format. As they are outputted images, there is no interaction with them like the flash charts are, but they do work for all browsers without extra addons like the flash ones need.

Test Charts:
http://cumulus.tnetweather.com/samp-graph.php

How its done

Collection of Data:

A perl script runs via cron (called realtimelog.pl), once a minute and grabs the contents of the uploaded realtime.txt file (also uploaded once a minute). I plan on creating a PHP version of this same script so that it can be used on servers without Perl access.

The script re-formats the data (changes the date to ISO format) and then appends it to a logfile (realtime.log).

This script will be available shortly and will be posted in its own topic.

Displaying Images:

The graphs themselves are individual PHP5 scripts. They read the data from the saved logfile info and display that data for each graph. The scripts are configured to allow arguments to be passed to them to change the number of hours and the frequency of samples.

By default, they output 24 hours worth of data sampled once an hour.

Options:

There are currently two options...

level

Level if provided changes the number of hours the graph displays. 0 = 24hrs, 1=48hrs, 2=72hrs and 3=96hrs. The default is 0. The argument can be passed via the URL itself with ?level=x or if used in CLI mode, as -l x on the command line.

freq

freq if provided changes the frequency of the graph displays. 0=Once an Hour, 1=Twice an Hour and 3=Four Times an hour. The default is 0. The argument can be passed via the URL itself with ?freq=x or if used in CLI mode, as -f x on the command line.

Graphs:

Currently, I have a temp, dewpt, baro and wind graph close to being done. I am going to be adding a rain, temp hi-lo as well and others if possible. There are some limitations due to the data source as it only provides some weather information. More enhanced versions will be created after I get the XML project done and have access to larger amounts of data sets.

Project page and downloads:

http://cumulus.tnetweather.com/projects/jpgraphgraphs
TNETWeather

Re: Cumulus Server Sided JpGraph Graphs

Post by TNETWeather »

I've been collecting Paul's site now for a while so I have enough data to start plotting.

The following page uses his logged data plotted for 24 hours:

http://cumulus.tnetweather.com/test/bra ... -graph.php

His data is Metric.
arthurhh
Posts: 63
Joined: Thu 18 Sep 2008 8:40 pm
Weather Station: Davis VP pro 2
Operating System: Win7
Location: Tokoroa South Waikato New Zealand
Contact:

Re: Cumulus Server Sided JpGraph Graphs

Post by arthurhh »

With all this wonderful stuff that you are producing for Cumulus (and WD) I think I will have to visit your paypal link (and steves too)
http://tokoroa.dyndns.org/ Main Site

IT Fixer
TNETWeather

Re: Cumulus Server Sided JpGraph Graphs

Post by TNETWeather »

PHP JpGraph Graphs Package

Version 1.0

This is a package of scripts that will generate based off of a realtime.log history file a series of graphs.

Currently supported are:

Temp/Hum
Dewpt
Baro
Wind
Rain

REQUIREMENTS

This package requires the following to work:

1) PHP5 Server. Might work with PHP4 but I've not tested it.

2) JpGraph PHP Library installed. It is assumed that you have loaded a recent version of this pacakge into the root of your webserver in the directory jpgraph. It can be located elsewhere, but you need to know where.

3) GD with FreeType Support. These graphs use the following truetype fonts:

Verdana

You could change the source to use the standard GD default fonts, but it would require a lot of changes and positioning... and won't look nearly as nice.

4) An updating realtime.log file. This can be created with the realtimelog.php script. See Forum Entry for realtimelog.php

Installation

The files come in a zip file and assume to be loaded into the sub-directory graphs off the main web directory. If the realtime.log file is located in the root directory above the graphs directory you won't need to make many changes to the configuration file.

The package comes with one configuration file called GraphSettings.php.

This file is included by all the graphs to get the base colors, station name and field types.

The configuration section of that script is:

Code: Select all

############################################################################
# CONFIGURATION INFORMATION
############################################################################
$SITE['version']        = "1.0";
$SITE['hloc']           = "../";
$SITE['jpgraphloc']		= "../jpgraph/src/";
$SITE['datafile']       = "realtime.log";
$SITE['format']         = "png";        # Options: jpeg  gif  png 
$SITE['sitename']       = "YOUR SITE NAME";
$SITE['tempunit']       = "°F";
$SITE['rainunit']       = "\"";
$SITE['barounit']       = " mb";
$SITE['windunit']       = " mph";
$SITE['bgncolor']		= "#EFEFEF";
$SITE['txtcolor']		= "#22464F";
$SITE['tz']				= "US/Arizona";
Lets go through them one at a time so you know what they are...

$SITE['version']

Basically just the version of the graph package.

$SITE['hloc']

Location of home from where the package is. This is a relative position and if you have loaded the package in a subdirectory off of the main web directory it should be just fine as it is.

$SITE['jpgraphloc']

Again, this is a relative address and assumes that the JpGraph library is located in jpgraph off the main web root. If you loaded it somewhere else, you will need to change this.

$SITE['datafile']

The datafile that contains the history. DON'T PUT PATH INFO HERE, just the filename.

$SITE['sitename']

This is the name of your site.

$SITE['format']

The default is png which is what most will use. You can change it to other formats if you GD supports those formats. Note that Jpeg is NOT a recommended format as it will make fuzzy looking images.

$SITE['tempunit']
$SITE['rainunit']
$SITE['barounit']
$SITE['windunit']


These values should be changed to the types of values your station is outputing.

For tempunit, recommended that you just change the F to a C if you need to and leave the degree symbol alone.

For rain, the default is " which is escaped with a \. If you want to change it to in or mm...

$SITE['bgncolor']
$SITE['txtcolor']


Settings for colors. bgncolor is the background of the margin and txtcolor is for most of the labels. If you change these, you will most likely need to adjust other colors used on the graphs.

$SITE['tz']

This allows the server to be set to the proper timezone when getting the current date.

For US values, it should be something like US/Eastern US/Pacific ...

For Europe, EUROPE/London etc...

Look at the following page for hints to match your locale...
http://us.php.net/manual/en/timezones.php

That's basically it....

Using the Graphs...

A sample page is included called samp-graphs.php

It provides examples of the various settings you can use when you call the charts.

This page shows how the same scripts can be used to display different numbers of hours and different frequency of samples.

Basically by adding:

level=X

You can set the hours to:

0 = 24hrs (default)
1 = 48hrs
2 = 72hrs
3 = 96hrs

freq=X

You can change the sample frequence to:

0 = once an hour (default)
1 = twice an hour
2 = four times an hour

Example:

Code: Select all

 http://YOURWEBSITE/temp.php?level=2&freq=2
Would display 72 hours on the graph with a sample frequency of four times an hour.

Note about values displayed:

The modules search the database looking at the minutes of the entries.

If Frequency is set to 0, it looks for entries that end in 00 minutes.
If Frequency is set to 1, it looks for entries that end in 00 and 30 minutes.
If Frequency is set to 2, it looks for 00 15 30 and 45 minutes.

It ignores any entries that don't match the above. It is assumed that the realtime.log has entries for once a minute.

NOT SUPPORTED YET

o I've not yet added PHP CLI support. This would allow you to use cron to generate static images that an active web page could hit without having to dynamically generate the images each time.

o Language support. Adding a simple array to the configuration file could make it easy to select the language used for the titles and labels...

o Multi-site report. Just an idea, but if you pass it a site number, it could look for different versions of the realtime.log files to display multiple site images using the same scripts. This would be for someone that has multiple locations.

Source Code:

Almost forgot the source code...

Source is included in a zip file. It will extract with all the modules in a subdirectory called graphs.

TNET Cumulus Project Page
pinto
Posts: 112
Joined: Sat 11 Oct 2008 3:20 pm
Weather Station: Davis Vantage Pro 2 Plus
Operating System: Debian Buster

Re: Cumulus Server Sided JpGraph Graphs

Post by pinto »

Great job, as always Kevin. :D

You can see the test-page here
very easy to setup

Jozef
Edit:logging started 11/oct/2008 at 16:00 so graphs are not yet what they are going to be
Jozef
TNETWeather

Re: Cumulus Server Sided JpGraph Graphs

Post by TNETWeather »

Well thank you very much Jozef. I'm glad you like them.

Yes, I should have included that in the instructions. If you have just started to collect data, the graphs will error until you have at least 2 data points to see. So if you are using a frequency of 1, that would be at least 2 full hours including the top of the hour for both.

When you first start, if you don't already have enough data for at least 2 points, the graphs will not be to happy...

I'm curious, did you use the realtimelog.php script to collect the data or something else? I'm a bit worried that some might have some issues trying to implement that, especially the part of knowing where to find the PHP command script.
User avatar
steve
Cumulus Author
Posts: 26701
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Cumulus Server Sided JpGraph Graphs

Post by steve »

These are great - I'm definitely going to have some of these when I get some spare time :)
Steve
pinto
Posts: 112
Joined: Sat 11 Oct 2008 3:20 pm
Weather Station: Davis Vantage Pro 2 Plus
Operating System: Debian Buster

Re: Cumulus Server Sided JpGraph Graphs

Post by pinto »

TNETWeather wrote:I'm curious, did you use the realtimelog.php script to collect the data or something else? I'm a bit worried that some might have some issues trying to implement that, especially the part of knowing where to find the PHP command script.
I do use your realtimelog.php script to collect the data, use cron to run it on a Linux server.
Knowing where to find the php command script was easy (for me it was) but yes, it could be an issue for some.

Jozef
Jozef
TNETWeather

Re: Cumulus Server Sided JpGraph Graphs

Post by TNETWeather »

I've added a scatter plot wind direction graph.

Source code now includes that graph and an updated samp-graph.php as well.

Source Code:
TNET Cumulus Project Page

Example: 24 hour sample 4 times an hour:
Image
pinto
Posts: 112
Joined: Sat 11 Oct 2008 3:20 pm
Weather Station: Davis Vantage Pro 2 Plus
Operating System: Debian Buster

Re: Cumulus Server Sided JpGraph Graphs

Post by pinto »

pinto wrote:
TNETWeather wrote:I'm curious, did you use the realtimelog.php script to collect the data or something else? I'm a bit worried that some might have some issues trying to implement that, especially the part of knowing where to find the PHP command script.
I do use your realtimelog.php script to collect the data, use cron to run it on a Linux server.
Knowing where to find the php command script was easy (for me it was) but yes, it could be an issue for some.
I did ask 2 friends and my brother
mine was in the path
brother was in the path
1 friend had no cron, so he could not run it
1 friend it was in the path

so most of us can use

Code: Select all

* * * * * php /path_to_your_webroot/realtimelog.php > /dev/null 2>&1
Jozef
Jozef
TNETWeather

Re: Cumulus Server Sided JpGraph Graphs

Post by TNETWeather »

That is good to know. I have a couple remote hosted servers, but I've not checked there. The stuff here is on my own server so I already knew where that was. Using just php without a path works on that too.

Another path that is not so obvious sometimes is the ones for ImageMagick. I use that a lot for other graphic projects, but nothing with Cumulus yet.
pinto
Posts: 112
Joined: Sat 11 Oct 2008 3:20 pm
Weather Station: Davis Vantage Pro 2 Plus
Operating System: Debian Buster

Re: Cumulus Server Sided JpGraph Graphs

Post by pinto »

Hi Kevin

FYI
I had to change the labelformat in rain.php to

Code: Select all

$graph->yaxis->SetLabelFormat('%0.1f' . $SITE['rainunit']);
because I had 0.2 mm of rain and the labels where all 0(zero)
nobody could see the amound of rain when looking at the graph

Jozef
Jozef
TNETWeather

Re: Cumulus Server Sided JpGraph Graphs

Post by TNETWeather »

Updated the package to reflect that. I don't get much rain here... I've considered a sand counting graph though.
arthurhh
Posts: 63
Joined: Thu 18 Sep 2008 8:40 pm
Weather Station: Davis VP pro 2
Operating System: Win7
Location: Tokoroa South Waikato New Zealand
Contact:

Re: Cumulus Server Sided JpGraph Graphs

Post by arthurhh »

arthurhh wrote:With all this wonderful stuff that you are producing for Cumulus (and WD) I think I will have to visit your paypal link (and steves too)
Just went looking and you dont have a paypal link on TNETWeather. Have to do something else for you.
http://tokoroa.dyndns.org/ Main Site

IT Fixer
TNETWeather

Re: Cumulus Server Sided JpGraph Graphs

Post by TNETWeather »

Its on my Cumulus Project page.... which is in my signature below...

I also accept Gold, Gasoline, Soup and Bread now days...
Post Reply