AnnualDataSummary: Difference between revisions

m
spelling
(Created Page)
 
m (spelling)
 
(122 intermediate revisions by 4 users not shown)
{{AddOnBanner|name=Annual Data Summary|type=HTML & Javascript|author=David Jamieson|contact=[[User:Daj|DAJ]]|updated=6 March 2011|version=1.0}}
 
Revision as of 22:41, 27 November 2012
'Annual Data Summary' is a small tool to read the [[dayfile.txt]] produced by Cumulus and summarise this in a table showing a full years worth of data. This tool uses standard HTML and Javascript so does not require a webserver with PHP services enabled. (many of the free hosting services do not offer PHP so this was a solution to that problem)
Name: Annual Data Summary
Type: HTML & Javascript
Author: David Jamieson
Contact: DAJ
Last update: 7 March 2011
Version: 1.1
 
Updated by BCJKiwi:
An working example is [http://www.grantownweather.co.uk/historic/dataSummary.php here]
{{AddOnBanner|name=Annual Data Summary|type=HTML & Javascript|author=David Jamieson|contact=[[User:Daj|DAJ]]<br>updated=7 March 2011<br>version=1.1|updated=17 December 2012|version=1.2 BCJKiwi}}
 
 
'''An updated article, that supersedes this one is called [[Daily_Summary]]'''
 
'Annual Data Summary' is a small tool to read the [[dayfile.txt]] produced by Cumulus and summarise this in a table, arranged like a calendar, showing a full years worth of a selected criterion such as maximum daily temperature.
 
*The tool uses HTML, jQuery (a library script that produces Javascript) and a CSS file.
*The JavaScript version does not require a webserver with PHP services enabled. (Many of the free hosting services do not offer PHP so this was a solution to that problem).
*The alternative is a PHP version (included so you have the option to use either).
*Both provide identical looking output and functionality, however if you have PHP services on your web server use the PHP version as it is slightly faster.
 
 
An working example used to be available at the subsequently abandoned web site [http://www.grantownweather.co.uk/historic/dataSummary.php here]
 
= Requirements =
*Javascript enabled browser (all modern browsers use Javascript)
*optionally, a tool to automate the uploading of dayfile.txt to your webserver once per day. Example, [[CumulusToolbox]]
*optionally, PHP enabled web server if you wish to use the PHP version
 
== Configuration Variables ==
 
by default, the script (the file 'readDayfile.js' or 'readDayfile.php' depending on your choice) will do the following:
* (both versions) Assume the dayfile.txt is read from a subfolder called 'data'.
* (JS version only) Insert the table it generates into a HTML element with attribute ''id='tableData' ''
* (both versions) Assume the date format in the dayfile is ''dd/mm/yy'' (the month is always in the middle for all Cumulus log files)
* (both versions) Assume the data in the dayfile is separated with a ''comma''
 
The last two assumptions are fine for UK based systems, however others should check their dayfile.txt and adjust as necessary
 
*Look for the line 'dayfile='/data/dayfile.txt';' around line 15 and change this to point to your dayfile.txt on your webserver.
:for ''PHP'' version the path should start from the / (root),
:for '''JavaScript''' version the path should start from where the HTML will be stored.
* (JS Version only) '''tableDiv''' - the HTML element ''id attribute'' on your webpage to insert the table into
* (both versions) '''field_delimiter''' - the symbol separating each of your fields in the dayfile.txt. For most people this is a '''comma''' but (if you use comma to separate integer and decimal parts of real numbers) it could be a semi-colon (''';''') or other symbol.
* (both versions) '''date_delimiter''' - the symbol separating your date format. See [[setup]].
 
Change as needed, save and test
 
 
== Revised PHP ==
Here is a revised set of files (PHP only) ver 1.2.
 
These are available here and update the Ver 1.1 fileset to eliminate errors in validation due to non-standard or deprecated code routines.
They also include a couple of updates from DAJ version as advised by posts in the Forum.
The files include additional notes, and explanations on the changes, where relevant.
 
*A working example was [http://silveracorn.co.nz/weather/datasummary.php here] and also [http://www.fordingbridgeweather.co.uk/datasummary.php here]
*Download the following file...[https://cumuluswiki.org/files/AnnualDataSummary_12.zip AnnualDataSummary_12.zip], the zip contains 3 files:
*#'''readDayfile.php''' - script for reading the dayfile.txt and for creating the table structure that displays selected statistics in a calendar style
*#'''datasummary.php''' - example 'carrier' web page, this one uses the Saratoga template system, so also requires 2 more scripts (not provided) ''Settings.php'' and ''common.php''. You can use your own page instead of this file.
*#'''datasummary.css''' - styling sheet for the table structure that displays selected statistics in a calendar style
 
*Follow the instructions below for the PHP version.
 
= The Basics =
 
= Original 1.1 Fileset and instructions:- =
*download the following file...[http://wiki.sandaysoft.com/files/AnnualDataSummary.zip AnnualDataSummary.zip]
*Unzip the contents (three files will be extracted)
*Edit the file 'readDayfile.js' file in a a good text editor (for example, [http://notepad-plus-plus.org/ notepad++]).
*Look for the line 'var dayfile='/data/dayfile.txt';' around line 15 and change this to point to your dayfile.txt on your webserver. This path should start from the / (root)
*Copy all the files to your web site into a subfolder, or the root -- your choice
* open datasummary.html in from your website in a browser
 
*download the following file...[https://cumuluswiki.org/files/AnnualDataSummary.zip AnnualDataSummary.zip]
<br>
*Unzip the contents (five files will be extracted)
*Edit the file 'readDayfile' file in a a good text editor (for example, [http://notepad-plus-plus.org/ notepad++]). Edit the .js version or the .php depending on your choice
*Look for the line 'dayfile='/data/dayfile.txt';' around line 15 and change this to point to your dayfile.txt on your webserver. This path should start from the / (root)
*Copy the necessary files to your web site into a subfolder, or the root -- your choice
: if using the PHP version copy datasummary.php and readDayfile.php
: for the Javascript version copy datasummary.html and readDafyfile.js
*Copy datasummary.css
* open datasummary.html or datasummary.php from your website in a browser
 
= Usage =
 
Along the top will be a menu of the six data sets available and on the top left of the table is the year currently being shown. Change either the year, or click one of the top buttons to change the datadataset. Depending on the speed of your internet connection, and your browser, the data may take a few seconds to be processed.
 
AsIf thisyou isselect athe pure Javascript solution available here, it means yourthe page viewer's browser is doing all the work. The complete dayfile.txt is loaded each time you showselect thea datadataset, and your PC then filters and processes it. This isAn in[https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=8690 contrastalternative toJavascript/jQuery asolution] PHPthat solutiononly wherereads the serverdayfile.txt doesonce, allhowever themany worktimes andyou onlychoose sendsa different data set or a different year is in the results3rd party tools forum. That alternative is thus considerably faster, especially with large dayfile.txt files.
 
This is in contrast to a PHP solution also available here, where the source server does all the work and only sends the results to the viewer's browser.
<br>
 
= Possible problems =
 
*This has been tested and runs on IE 7, IE 8, IE9, FireFox 3 &amp;to 414, Chrome/Dragon/SRWare Iron, and Safari -- running on the latternon IE threebrowsers for both Windows and the Mac.
*IE7 is notoriously slow for Javascript processing so there will be a longer delay as you change the data set (a few more seconds in some cases)
 
<br>
 
= Customisation =
== Understanding the Basics ==
 
The 'tool' relies on two files for successful operation.... datasummary.css (the style sheet) and readDayfile.js (the Javascript) or readDayfile.php (the PHP version). The third file, datasummary.html/php, is simply a carrier page to show the data.
 
If you wish to use your own page to show the data on, do the following:
Including the following three lines on ANY of your own pages will build a summary table
 
*for the JS version
In the &lt;HEAD&gt; section.....
: In the &lt;HEAD&gt; section.....
<pre>&lt;link rel="stylesheet" type="text/css" media="screen" href="datasummary.css" /&gt;
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="readDayfile.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
: This loads the stylesheet; loads a jQuery library from Google servers (rather than having the file on your server); and loads the Javascript to build the table
</pre>
: Once the page is loaded it runs readDayfile.js and will look for a DIV called 'tableData'; inserting the data table within it. You can change the DIV it inserts into (see later in this article).
This loads the stylesheet; loads a jQuery library from Google servers (rather than having the file on your server); and loads the Javascript to build the table
 
*for the PHP version
Once the page is loaded it runs readDayfile.js and will look for a DIV called 'tableData'; inserting the data table within it. You can change the DIV it inserts into (see later in this article). By inserting it in a DIV you have complete control over where and how the table is displayed. However, please note that the table needs a good amount of space to show a full year of data (at least 900 pixels unless you start reducing the font size!)
:use the code <pre><?php include('readDayfile.php');?></pre>
 
Please note that the table needs a good amount of space to show a full year of data (at least 900 pixels unless you start reducing the font size!)
<br>
 
<br>
 
== Configuration Variables ==
by default, the script will do the following:
 
*Insert it's contents into a DIV called 'tableData' (JS version only)
*Assumes the date format in the dayfile is dd/mm/yy
*Assumes the data in the dayfile is separated with a comma
If you need to adjust any of these settings, edit the readDayfile.js file and consider the variables in the top section of the script:
 
*'''tableDiv''' - the name of the DIV on your webpage to insert the table into (JS Version only)
*'''field_delimiter''' - the symbol separating each of your fields in the dayfile.txt. For most people this is a comma but may also be a period (.)
*'''date_delimiter''' - the symbol separating your date format. In the UK this is / however in other countires it may be -
The script has been designed to be easily translated to your language of choice.
 
As above, edit the readDayfile.js / .php
 
*variable '''mn''' is a list of the 12 months of the year, in an abbreviated format. You may change these as necessary, but try to keep it to an abbreviation as there is limited space.
*''''label_items'''' is a list of all possible data sets to be displayed. Again you can change these to suit. However, the format is a little more involved and you should take some care. Example,....
<pre>['maxtemp','Max Temp','Maximum Temperature',true]</pre>
*The first element, in this case 'maxtemp' -- domust NOTremain change'''unchanged''', this is a system variable to identify the datadataset and tested elsewhere in the code
*Second, '''Max Temp''' is the text to be displayed in the ''button'' at the top of the table. You may change this to your own language
*Third, '''Maximum Temperature''' is the text shown at the top of the table to ''describe the current data set''; again you may change this
*Finally, 'true' will display this button at the top; 'false' will hide it. Therefore, if you do not wish to allow users to jump to the 'Rainfall' datadataset' change the 'true' to 'false' in the rianfall'rainfall' element of the variable. (true/false MUST be lowercase)
 
<br>
 
== Opening a specific data set when the page is first loaded ==
By default (in the original version) the table created will show the available daily values of the ''maximum temperature'' for the current ''local calendar year'' (see possible problems below), however you can start with any data set and any year (assuming you have those values in the dayfile.txt) by ''adding a 'Query String' to the end of your URL'' in the browser.
 
*The parameter 'data' (in the original version) takes mintemp, maxtemp, avgtemp, minmaxt, rainfall, windgust. (You can add further data sets or change the language of these values - see Localization). '''Note''' the specified data will be displayed even if it is assigned 'false' and does not appear as a button.
By default the table will summaries the maximum temperature for the current year, however you can start with any dataset or year (assuming you have the data in the dayfile.txt) but adding a string to the end of your URL in the browser. examples....,
*You can supply both data set and year parameters, one only, or none
 
examples....,
*myserver.com/datasummary.html?year=2010
 
*JS version -- '''myserver.com/datasummary.html?year=2010'''
:This will open the data set initially showing year 2010
*PHP version -- ''myserver.com/datasummary.php?year=2010''
:This will open the default (maximum temperature) data set but initially showing year 2010
 
*myserver.com/datasummary.html?data=rainfall&amp;year=2009
 
:This*JS willversion open the-- myserver.com/datasummary.html?data=rainfall dataset for the &amp;year =2009.
:This will open the rainfall data set for the year 2009.
 
The parameter 'data' takes mintemp, maxtemp, avgtemp, minmaxt, rainfall, windgust. You can supply both parameters, one only, or none
 
== Styling ==
 
= Version Control =
1.2 New PHP version
 
1.1 PHP version included
 
1.0 Public launch
 
<br>
 
{{WatchReminderBanner}}
 
[[Category:WebTools]]
5,838

edits