Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Server Generated Graphs for MX

Discussion of version 3 of Cumulus, which runs on Windows, Linux, and OS X. All Cumulus MX queries in here, please.
User avatar
mcrossley
Posts: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby mcrossley » Mon Feb 16, 2015 11:56 am

The MySQL script is in the Wiki already, http://wiki.sandaysoft.com/a/ImportCumulusFile

water01
Posts: 1460
Joined: Sat Aug 13, 2011 9:33 am
Weather Station: WH1081
Operating System: Windows 7 64bit HP SP1
Location: Somewhere in the USA
Contact:

Re: Server Generated Graphs for MX

Postby water01 » Mon Feb 16, 2015 12:00 pm

Apologies Mark, stupid of me already using this for dayfile build didn't realise it could be used for loading the reatime.log file.

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

Re: Server Generated Graphs for MX

Postby mcrossley » Sat Feb 21, 2015 10:47 pm

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: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby mcrossley » Wed Mar 04, 2015 4:50 pm

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: 859
Joined: Mon Jul 09, 2012 8:40 pm
Weather Station: Davis VP2 Cabled with Solar
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Server Generated Graphs for MX

Postby BCJKiwi » Sun Mar 08, 2015 3:17 am

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: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby mcrossley » Sun Mar 08, 2015 8:33 am

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?

User avatar
duke
Posts: 840
Joined: Sun Jul 03, 2011 6:23 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 - 64 bit
Location: Eastleigh, Hampshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby duke » Sun Mar 08, 2015 8:47 am

mcrossley wrote:Anyone else seeing this problem?


All good here.
Duke

Nightingale Weather
Eastleigh, Hampshire, UK
------------------------------------------------------
Validate your pages - often!

BCJKiwi
Posts: 859
Joined: Mon Jul 09, 2012 8:40 pm
Weather Station: Davis VP2 Cabled with Solar
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Server Generated Graphs for MX

Postby BCJKiwi » Sun Mar 08, 2015 10:30 am

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: 859
Joined: Mon Jul 09, 2012 8:40 pm
Weather Station: Davis VP2 Cabled with Solar
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Server Generated Graphs for MX

Postby BCJKiwi » Sun Mar 08, 2015 11:36 am

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: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby mcrossley » Sun Mar 08, 2015 11:45 am

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: 859
Joined: Mon Jul 09, 2012 8:40 pm
Weather Station: Davis VP2 Cabled with Solar
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Server Generated Graphs for MX

Postby BCJKiwi » Sun Mar 08, 2015 8:06 pm

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 May 10, 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

Postby n9mfk » Mon Mar 09, 2015 12:19 am

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: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby mcrossley » Mon Mar 09, 2015 9:26 am

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: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Server Generated Graphs for MX

Postby mcrossley » Mon Mar 09, 2015 9:31 am

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: 215
Joined: Mon Jan 03, 2011 4:27 pm
Weather Station: Davis Vantage Pro2
Operating System: Win 7
Location: Willand, mid Devon.
Contact:

Re: Server Generated Graphs for MX

Postby Adrian Hudson » Mon Mar 09, 2015 6:52 pm

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


Return to “Cumulus MX”

Who is online

Users browsing this forum: No registered users and 2 guests