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 4018) - 28 March 2024

Legacy Cumulus 1 release v1.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

Server Generated Graphs for MX

From build 3044 the development baton passed to Mark Crossley. Mark has been responsible for all the Builds since. He has made the code available on GitHub. It is Mark's hope that others will join in this development, but at the very least he welcomes your ideas for future developments (see Cumulus MX Development suggestions).

Moderator: mcrossley

User avatar
mcrossley
Posts: 12697
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Post by mcrossley »

The MySQL script is in the Wiki already, http://wiki.sandaysoft.com/a/ImportCumulusFile
water01
Posts: 3215
Joined: Sat 13 Aug 2011 9:33 am
Weather Station: Ecowitt HP2551
Operating System: Windows 10 64bit
Location: Burnham-on-Sea
Contact:

Re: Server Generated Graphs for MX

Post by water01 »

Apologies Mark, stupid of me already using this for dayfile build didn't realise it could be used for loading the reatime.log file.
David
Image
User avatar
mcrossley
Posts: 12697
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Post by mcrossley »

David kindly pointed out that some of the SQL based graph files used the new array syntax and will not work with older versions of PHP, version 0.2 of the zip fixes those issues - think I have got all of them now!
User avatar
mcrossley
Posts: 12697
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Post by mcrossley »

I have added a new copy of the MX graphs - version 0.4, this version is required for Cumulus MX b3021 due to the changes in the data structures.

Take care you download the correct zip file. I will remove version 0.3 in a day or so.
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Server Generated Graphs for MX

Post by BCJKiwi »

Have a puzzle with v 0.4.
There is no

Code: Select all

$GRAPH['jpgraphcache']   =
in graphSettings.php now but there is still this in the individual graph files;

Code: Select all

@unlink(CACHE_DIR . $name);
How does this work now?
Can you change the cache location?
Can you turn off the cache?

Have a graph that won't load the first time - it gets created in the cache, but then the page needs to be refreshed to display the graph.
User avatar
mcrossley
Posts: 12697
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Post by mcrossley »

The cache settings - location, enabled - are set in the jpgraphs configuration file just as they were before. The only difference is that you do not have to replicate the location path into $GRAPH['jpgraphcache'] as the script now uses the value from jpgraphs.

Other than that change and the changes to the json files the scripts work the same. I don't see any problems with them not loading first time. Is it just one graph? Anyone else seeing this problem?
duke

Re: Server Generated Graphs for MX

Post by duke »

mcrossley wrote:Anyone else seeing this problem?
All good here.
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Server Generated Graphs for MX

Post by BCJKiwi »

I have just downloaded - again - ver 0.4.
The 0.4 graphSettings.php has

Code: Select all

# CONFIGURATION INFORMATION
############################################################################
$GRAPH['version']        = "0.4";
$GRAPH['width']          = 600;
$GRAPH['height']         = 300;
$GRAPH['jsonloc']        = "/";
$GRAPH['jpgraphloc']     = "/jpgraph/";
$GRAPH['cachetime']      = 10;
#---------------------------------------------------------------------------
where ver 0.2 had;

Code: Select all

# CONFIGURATION INFORMATION
############################################################################
$GRAPH['version']        = "0.2";
$GRAPH['width']          = 600;
$GRAPH['height']         = 300;
$GRAPH['jsonloc']        = "/";
$GRAPH['jpgraphloc']     = "/jpgraph/";
$GRAPH['jpgraphcache']   = "/jpgraph/cache/";  // This folder must exist
$GRAPH['cachetime']      = 10;
#---------------------------------------------------------------------------
The graphHum.php file now has;

Code: Select all

// Display the graph
@unlink(CACHE_DIR . $name);
$graph->Stroke();
when it used to have;

Code: Select all

// Display the graph
@unlink($GRAPH['jpgraphcache'] . $name);
$graph->Stroke();
The cache still seems to work but I don't know how.
I want to turn it off to see if it eliminates the problem I'm having.

The problem is with the sunshine hours graph which is not one of the standard set. I generate a json file and have changed the output so it has the same format as the new ver 0.4 MX generated files. The json file is generated within the script that later loads the graph. This script also loads the solar graph as well.
Sometimes the graph file is not generated properly - a graphics viewer can't load it. If I delete it from the cache the file will be created properly but will not load in the page unless the page is refreshed. The issue did not arise before.
Have attached sunhrdata.json file and graphSunHrs.php
You do not have the required permissions to view the files attached to this post.
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Server Generated Graphs for MX

Post by BCJKiwi »

OK, you can see the charts here http://silveracorn.co.nz/weather/wxmxsolaret.php
(Just had to sort out the files for the public server so they could be viewed!

There is no sun on the solar chart as that is using data from MX where the test unit is inside = no sun.
The sunshine hours are coming from live data.
User avatar
mcrossley
Posts: 12697
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Post by mcrossley »

You configure the JpGraph cache within the the jpg-config.inc file...

Code: Select all

//------------------------------------------------------------------------
// Directories for cache and font directory.
//
// CACHE_DIR:
// The full absolute name of the directory to be used to store the
// cached image files. This directory will not be used if the USE_CACHE
// define (further down) is false. If you enable the cache please note that
// this directory MUST be readable and writable for the process running PHP.
// Must end with '/'
//
// TTF_DIR:
// Directory where TTF fonts can be found. Must end with '/'
//
// The default values used if these defines are left commented out are:
//
// UNIX:
//   CACHE_DIR /tmp/jpgraph_cache/
//   TTF_DIR   /usr/share/fonts/truetype/
//   MBTTF_DIR /usr/share/fonts/truetype/
//
// WINDOWS:
//   CACHE_DIR $SERVER_TEMP/jpgraph_cache/
//   TTF_DIR   $SERVER_SYSTEMROOT/fonts/
//   MBTTF_DIR $SERVER_SYSTEMROOT/fonts/
//
//------------------------------------------------------------------------
define('CACHE_DIR','/jpgraph/cache/');
// define('TTF_DIR','/usr/share/fonts/TrueType/');
// define('MBTTF_DIR','/usr/share/fonts/TrueType/');

......


// Should the cache be used at all? By setting this to false no
// files will be generated in the cache directory.
// The difference from READ_CACHE being that setting READ_CACHE to
// false will still create the image in the cache directory
// just not use it. By setting USE_CACHE=false no files will even
// be generated in the cache directory.
define('USE_CACHE',true);

// Should we try to find an image in the cache before generating it?
// Set this define to false to bypass the reading of the cache and always
// regenerate the image. Note that even if reading the cache is
// disabled the cached will still be updated with the newly generated
// image. Set also 'USE_CACHE' below.
define('READ_CACHE',true);
I'll have to have a look at your code and json file later...
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Server Generated Graphs for MX

Post by BCJKiwi »

Thanks Mark,
I left the two pages (local Lan and public site) running in separate browser sessions over night.
The public site seems OK but the local LAN site required a refresh.

I have to assume at this point that it is a timing issue of some sort.
When the cache is stale, there is a short delay while jpgraph builds the image file and then it appears. This works for the solar graph as the json file is pre-existing. However the sun hours json file is built at the beginning of the page the graph is loaded in. I suspect that the page times out waiting for the graphic file.

On the local LAN;
With 'USE_CACHE' true, the cache folder open and the solar and sunhrs .png files deleted, the page loads with both chart spaces blank. The files appear in the cache, the solar chart appears but the sunhrs chart does not. A refresh then loads the sunhrs chart.
If I change 'USE_CACHE' to false, then no graph ever appears in the cache - as expected. However the solar chart does appear but the sunhrs chart never does.

On the public server;
With the cache set to false, the sunhrs chart actually appears first.
So I guess this confirms it is a Local LAN server horsepower issue and/or a WAMP issue.

I did try to replace the jpgraph setup by using the Highcharts files.
First issue was that highcharts would only display one chart, the first if the second was remmed out, and the second where the first should be if both were set to load. This was done by creating two separate files from the MX menu setup (removed the buttons and reduce each file to one chart).
I then found the example config for two charts on one page where a shim 'spacer' div is used to create a separation. The sample file worked fine. Also a new file using chunks from the MX file in the style of the sample also worked (eventually) with static data but I was not able to work out how to load data from the json files into that format.
I also could not see how to eliminate the 'extra' bits and just display the base chart for the solar chart. I already have a sunhrs chart on the Cumulus web site - http://silveracorn.co.nz/cumulusmx/trends.php. Being a column chart is has no zoom options and no zoom tool chart below the main chart and I would like the solar chart to be as simple in this alternate application.
I would prefer this option as it seems to me that it would be better to have the same look and feel every where on the site.
Any thoughts on this highcharts alternative?
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: Server Generated Graphs for MX

Post by n9mfk »

Hi mark,
I am running the last update the cache is not working an it is set
but its not being used
http://n9mfk.info/cumulus/images/graphPress.php
Beau
User avatar
mcrossley
Posts: 12697
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Post by mcrossley »

As this isn't really anything to do with the files I supplied it could do with being a different thread.
BCJKiwi wrote:Thanks Mark,
I left the two pages (local Lan and public site) running in separate browser sessions over night.
The public site seems OK but the local LAN site required a refresh.

I have to assume at this point that it is a timing issue of some sort.
When the cache is stale, there is a short delay while jpgraph builds the image file and then it appears. This works for the solar graph as the json file is pre-existing. However the sun hours json file is built at the beginning of the page the graph is loaded in. I suspect that the page times out waiting for the graphic file.

On the local LAN;
With 'USE_CACHE' true, the cache folder open and the solar and sunhrs .png files deleted, the page loads with both chart spaces blank. The files appear in the cache, the solar chart appears but the sunhrs chart does not. A refresh then loads the sunhrs chart.
If I change 'USE_CACHE' to false, then no graph ever appears in the cache - as expected. However the solar chart does appear but the sunhrs chart never does.

On the public server;
With the cache set to false, the sunhrs chart actually appears first.
So I guess this confirms it is a Local LAN server horsepower issue and/or a WAMP issue.

I did try to replace the jpgraph setup by using the Highcharts files.
First issue was that highcharts would only display one chart, the first if the second was remmed out, and the second where the first should be if both were set to load. This was done by creating two separate files from the MX menu setup (removed the buttons and reduce each file to one chart).
I then found the example config for two charts on one page where a shim 'spacer' div is used to create a separation. The sample file worked fine. Also a new file using chunks from the MX file in the style of the sample also worked (eventually) with static data but I was not able to work out how to load data from the json files into that format.
I also could not see how to eliminate the 'extra' bits and just display the base chart for the solar chart. I already have a sunhrs chart on the Cumulus web site - http://silveracorn.co.nz/cumulusmx/trends.php. Being a column chart is has no zoom options and no zoom tool chart below the main chart and I would like the solar chart to be as simple in this alternate application.
I would prefer this option as it seems to me that it would be better to have the same look and feel every where on the site.
Any thoughts on this highcharts alternative?
User avatar
mcrossley
Posts: 12697
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Post by mcrossley »

n9mfk wrote:Hi mark,
I am running the last update the cache is not working an it is set
but its not being used
http://n9mfk.info/cumulus/images/graphPress.php
Beau
They is not a lot I can do to investigate it remotely. If you have specified the path to the cache folder correctly (depending on the OS) and the folder has write permissions for PHP to read and write to it, it should work. If it doesn't you have probably made an error somewhere.
Adrian Hudson
Posts: 220
Joined: Mon 03 Jan 2011 4:27 pm
Weather Station: Davis Vantage Pro2
Operating System: Win 7
Location: Willand, mid Devon.
Contact:

Re: Server Generated Graphs for MX

Post by Adrian Hudson »

Hi Mark,

Just a quick thank you for these graphs. Very nice. They work perfectly.

Can I ask, have you ever programmed in Fortran in your dim and distant past?

Adrian
Post Reply