Re: Server Generated Graphs for MX
Posted: Mon 16 Feb 2015 11:56 am
The MySQL script is in the Wiki already, http://wiki.sandaysoft.com/a/ImportCumulusFile
Support forum for Cumulus weather station software
https://cumulus.hosiene.co.uk/
Code: Select all
$GRAPH['jpgraphcache'] =
Code: Select all
@unlink(CACHE_DIR . $name);
All good here.mcrossley wrote:Anyone else seeing this problem?
Code: Select all
# CONFIGURATION INFORMATION
############################################################################
$GRAPH['version'] = "0.4";
$GRAPH['width'] = 600;
$GRAPH['height'] = 300;
$GRAPH['jsonloc'] = "/";
$GRAPH['jpgraphloc'] = "/jpgraph/";
$GRAPH['cachetime'] = 10;
#---------------------------------------------------------------------------
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;
#---------------------------------------------------------------------------
Code: Select all
// Display the graph
@unlink(CACHE_DIR . $name);
$graph->Stroke();
Code: Select all
// Display the graph
@unlink($GRAPH['jpgraphcache'] . $name);
$graph->Stroke();
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);
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?
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.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