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

Tarting up my Data Summary

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderators: daj, TNETWeather

RayProudfoot
Posts: 2541
Joined: Wed May 06, 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Tarting up my Data Summary

Postby RayProudfoot » Thu Aug 23, 2018 7:17 pm

A few years back a kind forum member wrote some PHP code that showed max temp >= 25C in red as shown below. Temps below freezing were displayed in blue. Simple but effective.

Summary_Ray.png


But having looked at a couple of other sites this colour scheme has been expanded and it's something I would like to use on mine. I do have some programming knowledge but in Visual Basic, SQL and Cobol. None in PHP.

Summary_Paul.png


The page datasummaryT.htm has a reference to tableData which could be the key. But I also have a datasummary.php which includes a reference to readDayfile.php. That reads the Dayfile... obviously.

datasummary.php was written by David Jamieson and my copy also has a reference to Ray Beriau who was presumably the chap who wrote the code for me.

readDayfile.php appears to be the file that requires the work as it contains the value that trigger a change of colour. But where to start?

Any help appreciated.
You do not have the required permissions to view the files attached to this post.
Cheers,
Ray, Cheshire.

Image

sfws
Posts: 430
Joined: Fri Jul 27, 2012 11:29 am
Weather Station: Customised mix of Fine Offset
Operating System: Tempermental Win. 10 PC
Location: UK

Re: Tarting up my Data Summary

Postby sfws » Fri Aug 24, 2018 10:38 am

Ray - You might find the wiki helpful as http://wiki.sandaysoft.com/a/Daily_Summary contains some of the history you refer to and some links to various threads in this support forum. You will find one such link that mentions coloured values.

I have not found the right query-string http://www.cheadlehulmeweather.co.uk/datasummary.php?xxx=yyyy to look at your PHP source, but somewhere it must have a test that includes a "if" and a "25" (or zero in the blue case), and that will somehow relate to both checking that it is a temperature and assigning the CSS class of "highvalue" to apply colour red (or assigning class of "lowvalue" to apply colour blue). Certainly your script is using a very very old version of jQuery, so I am guessing your script is very old, probably therefore it is the one that the forum "coloured values" thread worked on, so that should be applicable to you.

Of course there are lots of more recent equivalent scripts mentioned in that Wiki article, and it might be better in long run to switch to something compatible with newer versions of PHP etc.

I won't say any more, recent PC problems here mean that I had to reset my PC (reinstall Windows 10 from scratch and am rebuilding now my own data) and so far I have not yet restored my files relating to the various data summary experiments I did, and I don't want to muddle you by relying on my ancient memory.

RayProudfoot
Posts: 2541
Joined: Wed May 06, 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Tarting up my Data Summary

Postby RayProudfoot » Fri Aug 24, 2018 11:01 am

Thanks sfws, that's a good starting point. I'll also investigate how to update jQuery without breaking anything.

I am familiar with IF THEN ELSE but it all looks very convoluted compared to Visual Basic which is where I spent most of my years before retirement.

I'm attaching my readDayfile.php zipped up.
You do not have the required permissions to view the files attached to this post.
Cheers,
Ray, Cheshire.

Image

sfws
Posts: 430
Joined: Fri Jul 27, 2012 11:29 am
Weather Station: Customised mix of Fine Offset
Operating System: Tempermental Win. 10 PC
Location: UK

Re: Tarting up my Data Summary

Postby sfws » Fri Aug 24, 2018 5:36 pm

Thanks Ray.
Your PHP script does not include any downloader http://sandaysoft.com/forum/viewtopic.php?f=14&t=16425, so I would not have been able to see the PHP script without you sharing it.

When I first applied for a job (many decades ago!), on my application I actually put "I do not want to work with computers", but of course from time to time in employment I did encounter them, in my case learning Fortran, Pascal, Cobol, BBC basic, Visual Basic, HP Basic, and a few others for various specific needs in the earlier part of my working career; after that I basically sat in front of a PC using standard applications and forgetting how to code. After retirement when I came to learn PHP it was hard, but essentially I bought a simple book and worked through its examples and then edited one of Mark's scripts for further practice before I ventured out on my own with first a daily summary type script and then the METAR scripts (very challenging and I developed my expertise), all mentioned elsewhere in the forum.

My suggestion is that you swap your source to http://www.komokaweather.com/weather/datasummary-colour2.php?view=sce. That source, although it is on Paul's site, is by Mark Crossley and is the one referenced by http://sandaysoft.com/forum/viewtopic.php?f=14&t=5319#p82284 i.e. the coloured version that the Wiki links to. As you may have discovered the link in that forum post no longer works as it was before Mark revamped his site. Hopefully, Paul's source (also now linked from Wiki) will work with almost no modification on your site, depending on which colour ranges you want. See lines 873 to 877:

Code: Select all

// temperature gradient colours for 4 ranges in Celsius
$tempGrad10to0 = gradient('54509F','00FFD4',100);
$tempGrad0to10 = gradient('00FFD4','48FF00',100);
$tempGrad10to20 = gradient('48FF00','FFDD00',100);
$tempGrad20to30 = gradient('FFDD00','FF0000',100);

If you do have problems, Mark may remember enough to sort you out, but if necessary I might find the time to compare your current source and Paul's ex-Mark source to work out any change needed if you cannot.

-----------------------------------------------------------------------------------------
I don't think persisting with your current script makes sense, and it is a long explanation that you do not need to read...

The relevant bit of code for defining whether to change colours is in lines 36 to 43:

Code: Select all

// use different colours for minimum/maximum/zero values - display the legends for the colours
$hilow    = true;

// minimum/maximum values used to display data in different colours - '$hilow' must be set to true
$minTemp  = '0';   // minimum temperature highlight
$maxTemp  = '25';  // maximum temperature highlight
$maxRain  = '0.5';  // maximum rain quantity highlight
$maxGust  = '30';  // maximum wind gust speed highlight


Between reading a value and its output into the table your script for each such value determines if changing colour of output text is needed in lines 151 to 166:

Code: Select all

if ($whatdata =='rainfall' or $whatdata =='windgust') {
            $value = floatval(str_replace(',','.',$data_arr[0]));
            // set a class for rain or wind zero values
            if ($value == 0) { $tablelayout .= ($hilow ? ' zerovalue2' : ' zerovalue'); }
            // set a class for excessively wet days
            if ($hilow and $whatdata =='rainfall' and $value >= $maxRain) { $tablelayout .= ' wetvalue'; }
            // set a class for excessively windy/gusty days
            if ($hilow and $whatdata =='windgust' and $value >= $maxGust) { $tablelayout .= ' gustvalue'; }
          }
          if ($whatdata == 'maxtemp' or $whatdata == 'mintemp' or $whatdata == 'avgtemp'  or $whatdata == 'minmaxt') {
            $value = floatval(str_replace(',','.',$data_arr[0]));
            // set a class for low temperature values - check if we have two sets of data
            if ($hilow and $value <= $minTemp) { $tablelayout .= ($dayfilecol2 > 0 ? ' lowvalue2' : ' lowvalue'); }
            // set a class for high temperature values - check if we have two sets of data
            if ($hilow and $value >= $maxTemp) { $tablelayout .= ($dayfilecol2 > 0 ? ' highvalue2' : ' highvalue'); }
          }

Line 160:

Code: Select all

if ($whatdata == 'maxtemp' or $whatdata == 'mintemp' or $whatdata == 'avgtemp'  or $whatdata == 'minmaxt') {

This is the if statement relevant to temperature. The $whatdata is a variable that holds what you have selected to display in the table, so this code is obeyed for displaying either the minimum temperature, or the maximum temperature, or the minimum temperature on the left and the maximum on the right per table cell pair for a particular day of the year.
Line 161: Don't worry about this, it is basically changing a comma representing the boundary between integer and decimal parts of a floating format into a full stop, i.e. how you or I would write a real number.
Line 165:

Code: Select all

if ($hilow and $value >= $maxTemp) { $tablelayout .= ($dayfilecol2 > 0 ? ' highvalue2' : ' highvalue'); }

This somewhat convoluted code is what tests the magnitude of the value and decides if colour is to be applied because it is a high value. It is nothing like what we met in Visual Basic! Let me dissect it,

Code: Select all

if ($hilow
this checks the value set in line 37, it is true, so that is noted and the next part of the condition is examined.

Code: Select all

and
This says the next bit must also be true or the script will move to next statement.

Code: Select all

$value >= $maxTemp
This compares the left hand value (the only value unless both min and max are being shown) with the threshold defined in line 41. If that condition is also true, a space and then the class highvalue is added to the instructions for how to format the table cell - see

Code: Select all

$tablelayout .= ' highvalue'
.
However, if there are two figures being shown per day of year, the variable $dayfilecol2 is true and this is tested by

Code: Select all

$dayfilecol2 > 0 ?

If that is true then the class highvalue2 is added to the instructions for how to format the table cell - see

Code: Select all

$tablelayout .= ' highvalue2'
.

OK, I explain all that to show what you want to achieve is far from simple with the way that the script you are using is written. You would need something like 165 for each different colour:

Code: Select all

if($hilow and $value > $lowEndOfRange1 and$value <= $highEndOfRange1)

This would probably be implemented within a loop, and the range values defined in an array. For greater efficiency, the $hilow would not be repeated, the $whatdata would be tested by using the switch(){}construct and you can see it is quite a large rewrite, and not a short job, so forget attempting that.

RayProudfoot
Posts: 2541
Joined: Wed May 06, 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Tarting up my Data Summary

Postby RayProudfoot » Fri Aug 24, 2018 5:55 pm

Thanks for taking the time to explain the process sfws. It sure is complicated. I suppose the more interested you are in learning a particular language the more time you'll devote to it. If I'm honest I want the end result but if I can use others' work without fully understanding how each line works that will do me.

I have created an Access database and it runs over 100 queries to present all sorts of info for last 7 days, current month, current year and last year. But I can get my head around queries and even those that require VBA being able to step through code line by line and hover over a variable to see its value is very helpful.

I'll read your post several times and tread carefully. It did occur to me that borrowing someone's code would be sensible. No point reinventing the wheel. It would also make sense if the colours were standard for the temperatures etc. but perhaps that depends on country. A cold day in Canada is very different to a cold one in the UK.
Cheers,
Ray, Cheshire.

Image

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: Tarting up my Data Summary

Postby mcrossley » Fri Aug 24, 2018 7:57 pm

Some good advice there.

There are now so many diverged versions of this script it is a bit of nightmare. The version I run on my site is probably pretty unique to me now, I have made many tweaks here and there over time, and mine is MySQL based as well.

This is one of those scripts that makes my head ache every time I try and sort out issues with it. I often think I'd like to write my own version one day, but the size of the task puts me off when what I have seems to work - mostly!

sfws
Posts: 430
Joined: Fri Jul 27, 2012 11:29 am
Weather Station: Customised mix of Fine Offset
Operating System: Tempermental Win. 10 PC
Location: UK

Re: Tarting up my Data Summary

Postby sfws » Fri Aug 24, 2018 8:24 pm

RayProudfoot wrote:If I'm honest I want the end result but if I can use others' work without fully understanding how each line works that will do me.

I prefer being outdoors well away from computers as much as I can, but for me I am happier understanding how any script I use works.

mcrossley wrote:There are now so many diverged versions of this script it is a bit of nightmare. The version I run on my site is probably pretty unique to me now, I have made many tweaks here and there over time, and mine is MySQL based as well.
mcrossley wrote:I often think I'd like to write my own version one day, but the size of the task puts me off when what I have seems to work - mostly!

I agree with first quote, despite (contrast second quote) having made the effort to successfully write my own version from scratch in the past. The fact that I created that Wiki article reflects how much effort I put into understanding all the diverged versions. After I posted my alternative javascript version on forum, I developed a new version and yes my current script closest to these daily summary versions uses PHP and MySQL. I think you, Mark, are forgetting how much time you did devote to working on daily summary tweaks in those bygone days!

RayProudfoot wrote:A cold day in Canada is very different to a cold one in the UK.
I would be surprised if Paul has customised Mark's script for Canada, Paul too has little knowledge of PHP. Also, I doubt if Mark considered temperatures experienced outside Cheshire when he devised that script as it probably was just demonstrating what could be done! However, in general a Meteorological service in one part of the world will use different colours to another for particular temperature ranges, so I doubt if there is an international standard.

RayProudfoot wrote:I have created an Access database and it runs over 100 queries to present all sorts of info for last 7 days, current month, current year and last year.

In my final job (paying phone bills for my local council) there was an access database used for recording phone calls per department. I tried to learn how to use Access to make better queries, but that was on a copy I developed at home, the council had their computer work contracted out. I ended up hating Access!
I wrote a database application for my late mum using the "Base" feature in Libre Office. She never mastered how to use it, but the queries I could run against it did allow me to answer some of her questions easily!

RayProudfoot wrote:being able to step through code line by line and hover over a variable to see its value is very helpful

I have to admit I have found MySQL easier to learn and easier to use than Access or Base. If you ever do learn to use PHP and MySQL, you may be surprised by some helpful features with those languages.

RayProudfoot
Posts: 2541
Joined: Wed May 06, 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Tarting up my Data Summary

Postby RayProudfoot » Fri Aug 24, 2018 9:48 pm

Gents,

Interesting replies which opens up something of a can of worms. In my naivety I thought there might have been a standardised php script that users simply dropped into their website structure making amendments where necessary for their location and web url.

It seems several have designed their own at great expense in time and effort.

There are several of you who have the skills to create a script that could be used by all. Would you consider such an undertaking and include a readme with the changes needed to make it compatible with users’ sites?

Maybe I’m asking for the impossible but if you don’t ask.... ;)
Cheers,
Ray, Cheshire.

Image

User avatar
PaulMy
Posts: 1674
Joined: Sun Sep 28, 2008 11:54 pm
Weather Station: Davis Vantage Pro 2 w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Tarting up my Data Summary

Postby PaulMy » Fri Aug 24, 2018 9:52 pm

RayProudfoot wrote:
A cold day in Canada is very different to a cold one in the UK.

I would be surprised if Paul has customised Mark's script for Canada, Paul too has little knowledge of PHP.

I have more than one data summary script :o and need to update my Credits page as way behind on recognizing the many that have provided their scripts and assistance over time. sfws is correct, very little knowledge and very little I would have changed other than what was specifically mentioned to do.

If Ray is asking on http://www.komokaweather.com/weather/be ... maryCU.php that is one that the beteljuice helped me with many years ago. If ok with him/her I can provide the zip.

Enjoy,
Paul

RayProudfoot
Posts: 2541
Joined: Wed May 06, 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Tarting up my Data Summary

Postby RayProudfoot » Fri Aug 24, 2018 10:11 pm

It is Paul. Very eye-catching. Thanks for any help you can supply or arrange with others.
Cheers,
Ray, Cheshire.

Image

User avatar
PaulMy
Posts: 1674
Joined: Sun Sep 28, 2008 11:54 pm
Weather Station: Davis Vantage Pro 2 w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Tarting up my Data Summary

Postby PaulMy » Fri Aug 24, 2018 10:45 pm

If I recall correctly this beteljuice version was a modification and added the weekday to the date when scrolling across any of the data.

Enjoy,
Paul

sfws
Posts: 430
Joined: Fri Jul 27, 2012 11:29 am
Weather Station: Customised mix of Fine Offset
Operating System: Tempermental Win. 10 PC
Location: UK

Re: Tarting up my Data Summary

Postby sfws » Fri Aug 24, 2018 11:18 pm

PaulMy wrote:added the weekday to the date when scrolling across any of the data.

Actually, an earlier variant introduced that - see 'Annual data Summary (DAJ script) - show day-of-week' reference in my already much mentioned Wiki article http://wiki.sandaysoft.com/a/Daily_Summary#PHP_scripts.

PaulMy wrote:If Ray is asking on http://www.komokaweather.com/weather/be ... maryCU.php that is one that the beteljuice helped me with many years ago. If ok with him/her I can provide the zip.

The script Paul refers to here is labelled as "Yet another Dayfile Reader", also mentioned in the Wiki article I linked in my first answer that has so many useful forum references. The forum thread http://sandaysoft.com/forum/viewtopic.php?f=14&t=11397 for that script suggests that producing one script for all, has not worked. You can read that very long thread to see why, and for the link to download the script. Amongst other problems, the syntax variations in the range of different versions of PHP that people use has apparently confused beteljuice. Anyway that script (like the day of week one mentioned above) was partially a collaboration between Mark and beteljuice, and was what I was thinking of when I said
sfws wrote:I think you, Mark, are forgetting how much time you did devote to working on daily summary tweaks in those bygone days!


RayProudfoot wrote:There are several of you who have the skills to create a script that could be used by all. Would you consider such an undertaking and include a readme with the changes needed to make it compatible with users’ sites?
My script at http://sandaysoft.com/forum/viewtopic.php?f=18&t=8690 was intended to be the one script for all, with a readme included. Reading through that topic should convince you that creating a script that suits all is impossible, and that was written using the comparitively simple jQuery library for implementing scripts in JavaScript language and using the tightly specified dayfile.txt file that Steve uses in both Cumulus 1 and Cumulus MX so I thought there was little scope for variation from what I saw as the requirement.

As my final point, Cumulus MX outputs into a simple database, but Steve has designed it so the tables in that database can either use the schema initiated by David Jamieson and tweaked by Mark Crossley or another schema. It could be argued that any new creation should be compatible with that. I tried that too (as it happens at Paul's suggestion), see 'New Script that displays a selected daily statistic for every day' reference in the same wiki article. You can read that forum thread to see if I was successful at http://sandaysoft.com/forum/viewtopic.php?f=14&t=16891.

User avatar
PaulMy
Posts: 1674
Joined: Sun Sep 28, 2008 11:54 pm
Weather Station: Davis Vantage Pro 2 w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Tarting up my Data Summary

Postby PaulMy » Fri Aug 24, 2018 11:54 pm

Thanks sfws, and agreed there has been much data summary script discussion and creating over the years and your memory is very good. I do remember your posting on this over the years, and our ;) collaboration earlier this year on the selected daily statistics.

Enjoy,
Paul

RayProudfoot
Posts: 2541
Joined: Wed May 06, 2009 6:29 pm
Weather Station: Davis VP2 with Daytime FARS
Operating System: Windows XP SP3
Location: Cheadle Hulme, Cheshire, England
Contact:

Re: Tarting up my Data Summary

Postby RayProudfoot » Sat Aug 25, 2018 8:22 am

Paul has kindly sent me the file created by beteljuice so I will read through the supplied readme and hopefully make sense of it.

I accept a one size fits all solution is not possible.

But first I need to update my version of jQuery. Hopefully not a daft question. I assume I need to stop Cumulus and run the installer. Is it something simple that once launched it knows what files need updating or is it a mainly manual exercise?
Cheers,
Ray, Cheshire.

Image

sfws
Posts: 430
Joined: Fri Jul 27, 2012 11:29 am
Weather Station: Customised mix of Fine Offset
Operating System: Tempermental Win. 10 PC
Location: UK

Re: Tarting up my Data Summary

Postby sfws » Sat Aug 25, 2018 8:57 am

RayProudfoot wrote:But first I need to update my version of jQuery. Hopefully not a daft question. I assume I need to stop Cumulus and run the installer. Is it something simple that once launched it knows what files need updating or is it a mainly manual exercise?

You are using Cumulus 1, jQuery is only included (http://wiki.sandaysoft.com/a/Simple_Website_setup#Cumulus_MX) in Cumulus MX. Your jQuery has nothing to do with Cumulus, it is loaded in your http://www.cheadlehulmeweather.co.uk/datasummary.php by line 11

Code: Select all

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>

Change that 1.6.4 to 3.3.1 for the quick and simple upgrade. Alternatively download jQuery from http://code.jquery.com/ and instead of using the google source above reference your local downloaded copy in your html e.g. src="jquery-3.3.1.min.js".

If you adopt beteljuice version from Paul, see whether it uses JQuery or not by hunting in what Paul has sent you. If it does, a similar change might be needed. If it does not use jQuery, then swapping scripts has removed the need to update.

The changes in newer versions of jQuery do remove some obsolete syntax and add some new syntax, but there are comparitively few changes compared to how for example PHP syntax varies between its versions. Once again I jog my memory by looking at my Wiki article http://wiki.sandaysoft.com/a/Daily_Summary#Errors_rectified_by_this_version. It is just possible that the version of the Mark Crossley PHP file I have suggested you download from Paul's site (for the easiest no hassle transistion to the extra colouring you requested) is using some obsolete jQuery syntax, but try upgrading jQuery anyway as generally Mark's scripts do use latest library and language versions applying at that time.


Return to “Web site - General”

Who is online

Users browsing this forum: No registered users and 2 guests