AnnualDataSummary: Difference between revisions

m
Updated for PHP version
(Created Page)
 
m (Updated for PHP version)
{{AddOnBanner|name=Annual Data Summary|type=HTML & Javascript|author=David Jamieson|contact=[[User:Daj|DAJ]]|updated=67 March 2011|version=1.01}}
 
'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). However, a PHP version is included so you have the option to use either. Both provide identical data and functionality, however if you have PHP services on your web server use the PHP version as it is slightly faster.
 
An working example is [http://www.grantownweather.co.uk/historic/dataSummary.php here]
*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
 
= The Basics =
 
*download the following file...[http://wiki.sandaysoft.com/files/AnnualDataSummary.zip AnnualDataSummary.zip]
*Unzip the contents (threefive files will be extracted)
*Edit the file 'readDayfile.js' 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 '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 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
* open datasummary.html in from your website in a browser
: for the Javascript version copy datasummary.html and readDafyfile.js
*Copy datasummary.css
* open datasummary.html inor datasummary.php from your website in a browser
 
<br>
 
= Usage =
As this is a pure Javascript solution it means your browser is doing all the work. The complete dayfile.txt is loaded each time you show the data and your PC then filters and processes it. This is in contrast to a PHP solution where the server does all the work and only sends the results.
 
<br>
 
= Possible problems =
*This has been tested and runs on IE 7, IE 8, FireFox 3 &amp; 4, Chrome and Safari -- the latter three 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.....
<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). 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!)
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>
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.
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....,
 
*JS version --myserver.com/datasummary.html?year=2010
*PHP version -- myserver.com/datasummary.php?year=2010
 
:This will open the data set initially showing year 2010
 
 
*myserver.com/datasummary.html?data=rainfall&amp;year=2009
 
:This will open the rainfall dataset for the year 2009.
 
 
= Version Control =
1.1 PHP version included
 
1.0 Public launch
1,120

edits