Page 4 of 18

Re: Server Generated Graphs for MX

Posted: Mon 16 Feb 2015 11:56 am
by mcrossley
The MySQL script is in the Wiki already, http://wiki.sandaysoft.com/a/ImportCumulusFile

Re: Server Generated Graphs for MX

Posted: Mon 16 Feb 2015 12:00 pm
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.

Re: Server Generated Graphs for MX

Posted: Sat 21 Feb 2015 10:47 pm
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!

Re: Server Generated Graphs for MX

Posted: Wed 04 Mar 2015 4:50 pm
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.

Re: Server Generated Graphs for MX

Posted: Sun 08 Mar 2015 3:17 am
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.

Re: Server Generated Graphs for MX

Posted: Sun 08 Mar 2015 8:33 am
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?

Re: Server Generated Graphs for MX

Posted: Sun 08 Mar 2015 8:47 am
by duke
mcrossley wrote:Anyone else seeing this problem?
All good here.

Re: Server Generated Graphs for MX

Posted: Sun 08 Mar 2015 10:30 am
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

Re: Server Generated Graphs for MX

Posted: Sun 08 Mar 2015 11:36 am
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.

Re: Server Generated Graphs for MX

Posted: Sun 08 Mar 2015 11:45 am
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...

Re: Server Generated Graphs for MX

Posted: Sun 08 Mar 2015 8:06 pm
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?

Re: Server Generated Graphs for MX

Posted: Mon 09 Mar 2015 12:19 am
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

Re: Server Generated Graphs for MX

Posted: Mon 09 Mar 2015 9:26 am
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?

Re: Server Generated Graphs for MX

Posted: Mon 09 Mar 2015 9:31 am
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.

Re: Server Generated Graphs for MX

Posted: Mon 09 Mar 2015 6:52 pm
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