Sandaysoft

Support forum for Cumulus weather station software
It is currently Sat May 18, 2013 4:55 am
Please click here before posting. Help me to help you!
Useful Links: Cumulus FAQ • Enhancement requests • Wiki (documentation)
Please put your approximate location into your profile
Add your web site to the Cumulus user map
Vantage Pro2 users with firmware 3.00 should upgrade to fw 3.12 and Cumulus 1.9.4

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Annual Data Summary - Coloured Values
PostPosted: Fri Jun 17, 2011 3:08 am 
Offline
User avatar

Joined: Wed Mar 03, 2010 10:20 am
Posts: 299
Location: Brisbane, Australia
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows Vista SP2
With David's help in another topic I was able to colour the data in my Annual Data Summary page as seen here . It works well and you can easily see seasonal trends and extremes in the data at a glance.
My javascript file has been modified somewhat from the original provided by David (added wind run, deleted avg temps and min/max, changed colours etc) but I have posted the info so you can see how easily it can be done. This is how I modified the javascript version....

(make back ups of your original datasummary.css file and readDayfile.js files before starting... just in case)

First I created a 'colour scale' in the datasummary.css file by adding the following code just below
#table_container .zerovalue { color: #555555;}

Code:
#table_container .extremehigh { color: #800080;}
#table_container .veryhigh { color: #F71B08;}
#table_container .higher{ color: #EC550E;}
#table_container .high{ color: #EEC900;}
#table_container .low { color: #40DA40;}
#table_container .lower{ color: #4078DA;}
#table_container .verylow { color: #00FFFF;}
#table_container .extremelow { color: #FFFFFF;}
#table_container .grey { color: #292727;}


Then right after this line in the readDayfile.js file,
if ((parseFloat(wd_data[dayfilecol].split(',').join('.')) == 0) && (dayfilecol ==14 || dayfilecol ==1)) { $(data_cell).addClass('zerovalue'); }
I added the following code:
Code:
            // Max Temp
            if((parseFloat(wd_data[dayfilecol])>=37.0)&&(dayfilecol==6)){$(data_cell).addClass('extremehigh');}
            if((parseFloat(wd_data[dayfilecol])<=36.9)&&(dayfilecol==6)){$(data_cell).addClass('veryhigh');}
            if((parseFloat(wd_data[dayfilecol])<=33.0)&&(dayfilecol==6)){$(data_cell).addClass('higher');}
            if((parseFloat(wd_data[dayfilecol])<=30.0)&&(dayfilecol==6)){$(data_cell).addClass('high');}
            if((parseFloat(wd_data[dayfilecol])<=25.0)&&(dayfilecol==6)){$(data_cell).addClass('low');}
            if((parseFloat(wd_data[dayfilecol])<=20.0)&&(dayfilecol==6)){$(data_cell).addClass('lower');}
            if((parseFloat(wd_data[dayfilecol])<=10.0)&&(dayfilecol==6)){$(data_cell).addClass('verylow');}
            if((parseFloat(wd_data[dayfilecol])<=6.0)&&(dayfilecol==6)){$(data_cell).addClass('extremelow');}
            // Min Temp
            if((parseFloat(wd_data[dayfilecol])>=37.0)&&(dayfilecol==4)){$(data_cell).addClass('extremehigh');}
            if((parseFloat(wd_data[dayfilecol])<=36.0)&&(dayfilecol==4)){$(data_cell).addClass('veryhigh');}
            if((parseFloat(wd_data[dayfilecol])<=33.0)&&(dayfilecol==4)){$(data_cell).addClass('higher');}
            if((parseFloat(wd_data[dayfilecol])<=29.0)&&(dayfilecol==4)){$(data_cell).addClass('high');}
            if((parseFloat(wd_data[dayfilecol])<=25.0)&&(dayfilecol==4)){$(data_cell).addClass('low');}
            if((parseFloat(wd_data[dayfilecol])<=20.0)&&(dayfilecol==4)){$(data_cell).addClass('lower');}
            if((parseFloat(wd_data[dayfilecol])<=10.0)&&(dayfilecol==4)){$(data_cell).addClass('verylow');}
            if((parseFloat(wd_data[dayfilecol])<=6.0)&&(dayfilecol==4)){$(data_cell).addClass('extremelow');}            
            // Total Rainfall
            if((parseFloat(wd_data[dayfilecol])>=200.0)&&(dayfilecol==14)){$(data_cell).addClass('extremehigh');}
            if((parseFloat(wd_data[dayfilecol])<=199.9)&&(dayfilecol==14)){$(data_cell).addClass('veryhigh');}            
            if((parseFloat(wd_data[dayfilecol])<=150.0)&&(dayfilecol==14)){$(data_cell).addClass('veryhigh');}
            if((parseFloat(wd_data[dayfilecol])<=100.0)&&(dayfilecol==14)){$(data_cell).addClass('higher');}
            if((parseFloat(wd_data[dayfilecol])<=75.0)&&(dayfilecol==14)){$(data_cell).addClass('high');}
            if((parseFloat(wd_data[dayfilecol])<=50.0)&&(dayfilecol==14)){$(data_cell).addClass('low');}
            if((parseFloat(wd_data[dayfilecol])<=20.0)&&(dayfilecol==14)){$(data_cell).addClass('lower');}
            if((parseFloat(wd_data[dayfilecol])<=10.0)&&(dayfilecol==14)){$(data_cell).addClass('verylow');}
            if((parseFloat(wd_data[dayfilecol])<=2.0)&&(dayfilecol==14)){$(data_cell).addClass('extremelow');}            
            if((parseFloat(wd_data[dayfilecol])==0.0)&&(dayfilecol==14)){$(data_cell).addClass('grey');}
            // Rain Rate
            if((parseFloat(wd_data[dayfilecol])>=200.0)&&(dayfilecol==12)){$(data_cell).addClass('extremehigh');}
            if((parseFloat(wd_data[dayfilecol])<=199.9)&&(dayfilecol==12)){$(data_cell).addClass('veryhigh');}            
            if((parseFloat(wd_data[dayfilecol])<=179.9)&&(dayfilecol==12)){$(data_cell).addClass('veryhigh');}
            if((parseFloat(wd_data[dayfilecol])<=99.9)&&(dayfilecol==12)){$(data_cell).addClass('higher');}
            if((parseFloat(wd_data[dayfilecol])<=74.9)&&(dayfilecol==12)){$(data_cell).addClass('high');}
            if((parseFloat(wd_data[dayfilecol])<=49.9)&&(dayfilecol==12)){$(data_cell).addClass('low');}
            if((parseFloat(wd_data[dayfilecol])<=19.9)&&(dayfilecol==12)){$(data_cell).addClass('lower');}
            if((parseFloat(wd_data[dayfilecol])<=9.9)&&(dayfilecol==12)){$(data_cell).addClass('verylow');}
            if((parseFloat(wd_data[dayfilecol])<=1.9)&&(dayfilecol==12)){$(data_cell).addClass('extremelow');}            
            if((parseFloat(wd_data[dayfilecol])==0.0)&&(dayfilecol==12)){$(data_cell).addClass('grey');}
            // High Pressure
            if((parseFloat(wd_data[dayfilecol])>=1030.00)&&(dayfilecol==10)){$(data_cell).addClass('extremehigh');}
            if((parseFloat(wd_data[dayfilecol])<=1029.99)&&(dayfilecol==10)){$(data_cell).addClass('high');}
            if((parseFloat(wd_data[dayfilecol])<=1019.99)&&(dayfilecol==10)){$(data_cell).addClass('low');}
            if((parseFloat(wd_data[dayfilecol])<=1009.99)&&(dayfilecol==10)){$(data_cell).addClass('verylow');}
            if((parseFloat(wd_data[dayfilecol])<=999.99)&&(dayfilecol==10)){$(data_cell).addClass('extremelow');}            
            // Low Pressure
            if((parseFloat(wd_data[dayfilecol])>=1030.00)&&(dayfilecol==8)){$(data_cell).addClass('extremehigh');}
            if((parseFloat(wd_data[dayfilecol])<=1029.99)&&(dayfilecol==8)){$(data_cell).addClass('high');}
            if((parseFloat(wd_data[dayfilecol])<=1019.99)&&(dayfilecol==8)){$(data_cell).addClass('low');}
            if((parseFloat(wd_data[dayfilecol])<=1009.99)&&(dayfilecol==8)){$(data_cell).addClass('verylow');}
            if((parseFloat(wd_data[dayfilecol])<=999.99)&&(dayfilecol==8)){$(data_cell).addClass('extremelow');}            
            // Wind Speed
            if((parseFloat(wd_data[dayfilecol])>=45.0)&&(dayfilecol==17)){$(data_cell).addClass('extremehigh');}
            if((parseFloat(wd_data[dayfilecol])<=44.9)&&(dayfilecol==17)){$(data_cell).addClass('veryhigh');}            
            if((parseFloat(wd_data[dayfilecol])<=29.9)&&(dayfilecol==17)){$(data_cell).addClass('veryhigh');}
            if((parseFloat(wd_data[dayfilecol])<=19.9)&&(dayfilecol==17)){$(data_cell).addClass('higher');}
            if((parseFloat(wd_data[dayfilecol])<=14.9)&&(dayfilecol==17)){$(data_cell).addClass('high');}
            if((parseFloat(wd_data[dayfilecol])<=9.9)&&(dayfilecol==17)){$(data_cell).addClass('low');}
            if((parseFloat(wd_data[dayfilecol])<=4.9)&&(dayfilecol==17)){$(data_cell).addClass('lower');}
            // Wind Gust
            if((parseFloat(wd_data[dayfilecol])>=50.0)&&(dayfilecol==1)){$(data_cell).addClass('extremehigh');}
            if((parseFloat(wd_data[dayfilecol])<=49.9)&&(dayfilecol==1)){$(data_cell).addClass('veryhigh');}
            if((parseFloat(wd_data[dayfilecol])<=39.9)&&(dayfilecol==1)){$(data_cell).addClass('veryhigh');}
            if((parseFloat(wd_data[dayfilecol])<=29.9)&&(dayfilecol==1)){$(data_cell).addClass('high');}
            if((parseFloat(wd_data[dayfilecol])<=19.9)&&(dayfilecol==1)){$(data_cell).addClass('low');}
            if((parseFloat(wd_data[dayfilecol])<=9.9)&&(dayfilecol==1)){$(data_cell).addClass('lower');}
            if((parseFloat(wd_data[dayfilecol])<=4.9)&&(dayfilecol==1)){$(data_cell).addClass('verylow');}            
            // Wind Run
            if((parseFloat(wd_data[dayfilecol])>=200.0)&&(dayfilecol==16)){$(data_cell).addClass('extremehigh');}
            if((parseFloat(wd_data[dayfilecol])<=199.9)&&(dayfilecol==16)){$(data_cell).addClass('veryhigh');}
            if((parseFloat(wd_data[dayfilecol])<=174.9)&&(dayfilecol==16)){$(data_cell).addClass('veryhigh');}
            if((parseFloat(wd_data[dayfilecol])<=149.9)&&(dayfilecol==16)){$(data_cell).addClass('higher');}
            if((parseFloat(wd_data[dayfilecol])<=124.9)&&(dayfilecol==16)){$(data_cell).addClass('high');}
            if((parseFloat(wd_data[dayfilecol])<=99.9)&&(dayfilecol==16)){$(data_cell).addClass('low');}
            if((parseFloat(wd_data[dayfilecol])<=49.9)&&(dayfilecol==16)){$(data_cell).addClass('lower');}
            if((parseFloat(wd_data[dayfilecol])<=24.9)&&(dayfilecol==16)){$(data_cell).addClass('verylow');}
            if((parseFloat(wd_data[dayfilecol])<=9.9)&&(dayfilecol==16)){$(data_cell).addClass('extremelow');}

Upload both files to your server and ... Taadaaaaah!

Expirement with the scales values / colours etc as you weather data will most definately be different from mine. There are probably more elegant and friendlier ways of doing this but it was a fun exercise.
Enjoy.

_________________
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Fri Jun 17, 2011 12:29 pm 
Offline
User avatar

Joined: Tue Dec 09, 2008 1:37 pm
Posts: 1844
Location: Dudley, West Midlands, UK
Weather Station: None !
Operating System: XP SP3
The beteljuice is unhappy with the logic order - there seems to be a lot of unecessary work being done !

I haven't looked at any of the original code, but am assuming:

    This code is already in a loop where each 'line' of data is being processed
    Each line has already been split into 'col' components - wd_data[x] - where x = dayfilecol

You wish to make a decision based on content type - dayfilecol value - (eg. 4 = Min temp)
but the first 'enquiry' is the value of the data regardless of type (ie. EVERY record entry), this would sort of be OK for a single type check, but is escalating because of all the multiple type checks.

The original code snippet was not incorrect because it was looking for any zero value of data.

So this:
Code:
// Max Temp
if((parseFloat(wd_data[dayfilecol])>=37.0)&&(dayfilecol==6)) {$(data_cell).addClass('extremehigh');}

Would be better as:
Code:
// Max Temp
if((dayfilecol==6) && (parseFloat(wd_data[dayfilecol])>=37.0)){$(data_cell).addClass('extremehigh');}

Also, in the case of temp, your colour decisions are identical for Max / Min, so no need to duplicate the code just:
Code:
// Min / Max Temp
if((dayfilecol==4 || dayfilecol==6) && (parseFloat(wd_data[dayfilecol])>=37.0)){$(data_cell).addClass('extremehigh');}

and so on ... having just ONE block of code

Perhaps daj could please cast an eye and either confirm or delete the musings of the beteljuice ...

_________________
Image
......................Imagine, what you will KNOW tomorrow !


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Fri Jun 17, 2011 12:58 pm 
Offline
User avatar

Joined: Wed Mar 03, 2010 10:20 am
Posts: 299
Location: Brisbane, Australia
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows Vista SP2
I see what you mean. I did say... there are probably more elegant and friendlier ways of doing this.... My knowledge of javascript is pretty limited. Anything to minimise the amount of code is always welcome.

_________________
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Mon Jun 20, 2011 11:36 am 
Offline
User avatar

Joined: Tue Jul 29, 2008 8:00 pm
Posts: 2001
Location: Thornhill, Dumfries, UK
Weather Station: WH1081
Operating System: Mac OSx & Win 7
As already hinted at, there are better ways to write more complicated logic statements. In this case you might write it as...

Code:
if (dayfilecol==6)
    {
     if (parseFloat(wd_data[dayfilecol])>=37.0) {$(data_cell).addClass('extremehigh');}
     if (parseFloat(wd_data[dayfilecol])<=36.9) {$(data_cell).addClass('veryhigh');}
     if (parseFloat(wd_data[dayfilecol])<=33.0) {$(data_cell).addClass('higher');}
     if (parseFloat(wd_data[dayfilecol])<=30.0) {$(data_cell).addClass('high');}
     if (parseFloat(wd_data[dayfilecol])<=25.0) {$(data_cell).addClass('low');}
     if (parseFloat(wd_data[dayfilecol])<=20.0) {$(data_cell).addClass('lower');}
     if (parseFloat(wd_data[dayfilecol])<=10.0) {$(data_cell).addClass('verylow');}
     if (parseFloat(wd_data[dayfilecol])<=6.0)  {$(data_cell).addClass('extremelow');}
}


This avoids over-zealous logic as it will only do the sub-logic if dayfilecol=6. If not, it would skip to the next block of code -- in theory saving cricual milli-seconds of processing ;)

_________________
David
Contact Me


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Mon Jun 20, 2011 11:44 am 
Offline
User avatar

Joined: Thu Jan 07, 2010 9:44 pm
Posts: 2500
Location: Wilmslow, Cheshire, UK
Weather Station: Davis VP2
Operating System: XP SP3, Win 7
Indeed, you could even add a few 'break' commands in there to stop the processing once the condition had been found - or make them all 'else if's, or...

_________________
Mark
Wilmslow Astro Weather


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Mon Jun 20, 2011 2:38 pm 
Offline
User avatar

Joined: Tue Jul 29, 2008 8:00 pm
Posts: 2001
Location: Thornhill, Dumfries, UK
Weather Station: WH1081
Operating System: Mac OSx & Win 7
aye, it can be refined further. trade off between readability and good, economic code I guess.

The worst thing is the PHP 'switch' statement -- I hate repetition and using all those 'breaks' pains me! :lol:

_________________
David
Contact Me


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Mon Jun 20, 2011 3:10 pm 
Offline
User avatar

Joined: Tue Dec 09, 2008 1:37 pm
Posts: 1844
Location: Dudley, West Midlands, UK
Weather Station: None !
Operating System: XP SP3
:lol: OK, let's put it all together (One way at least) ;)

Even by putting the dayfilecol check first, In the worst case scenario (temp less than 6)
    ParseFloat() was being invoked 8 times
    $(data_cell) was being 'decoded' 8 times
    addClass() was being invoked 8 times

So, one way to stop doing all that extra processing..
Code:
// Allocate T_min / T_max colour class
fiddle = false;
if (dayfilecol==4 || dayfilecol==6)
    {
    fiddle = true; // a fiddle so we don't need to do range checks and can use break
    temp_class ='extremelow'; // default value
    temp_check = parseFloat(wd_data[dayfilecol]);
    if (temp_check >=37.0) {temp_class ='extremehigh'; break;}
    if (temp_check >=33.1) {temp_class ='veryhigh'; break;}
    if (temp_check >=30.1) {temp_class ='higher'; break;}
    if (temp_check >=25.1) {temp_class ='high'; break;}
    if (temp_check >=20.1) {temp_class ='low'; break;}
    if (temp_check >=10.1) {temp_class ='lower'; break;}
    if (temp_check >=6.1) {temp_class ='verylow';}
}
if(fiddle) { $(data_cell).addClass(temp_class);}
// END Allocate T_min / T_max colour class

Notice the subtle change in the temp_check logic and values, this is so we can use break as soon as possible.

_________________
Image
......................Imagine, what you will KNOW tomorrow !


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Sat Dec 31, 2011 5:49 pm 
Offline

Joined: Wed May 13, 2009 9:35 am
Posts: 110
Location: Nr Ilkley, West Yorks, UK
Weather Station: WMR-200
Operating System: Windows 7
I've spent the best part of two days trying to get colours to work in the Min/Max Temp option in the PHP script.

I have no knowledge of PHP ( :lol: ), but have read a lot on here and looked at other examples and have actually learnt quite a bit!
So, before I go mad, can one of you genii(?) point me in the right direction?

I know it is something to do with this:

// if we have two sets of data (i.e. Min & Max)
if ($dayfilecol2 >0) {
$tablelayout .= '<td class="datacell smallfont">';
$tablelayout .= $data_arr[1];
$tablelayout .='</td>';
}

but everything I have tried doesn't quite work. It either throws out the columns, affects other tables or tells me to get lost...... :bash:

I know it will be easy to you master coders, but just give me a clue somebody, please? Anybody?

Thanks in anticipation :clap:

_________________
bigmac
Menston Weather


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Sat Dec 31, 2011 6:46 pm 
Offline
User avatar

Joined: Tue Dec 09, 2008 1:37 pm
Posts: 1844
Location: Dudley, West Midlands, UK
Weather Station: None !
Operating System: XP SP3
Quote:
I know it is something to do with this:
Err ........ no - that's simply saying if there are two lots of data in the 'cell' use a small font ;)

Keep looking .. :lol:

_________________
Image
......................Imagine, what you will KNOW tomorrow !


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Sun Jan 01, 2012 2:22 am 
Offline

Joined: Wed May 13, 2009 9:35 am
Posts: 110
Location: Nr Ilkley, West Yorks, UK
Weather Station: WMR-200
Operating System: Windows 7
Quote:
Err ........ no - that's simply saying if there are two lots of data in the 'cell' use a small font


Yeah, but that's the thing, I've tried every where else in the code, it don't f'ing work, but if I play around with this bit, it nearly works.

Please Beteljuice, just one more crumb of a clue :twisted:

_________________
bigmac
Menston Weather


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Sun Jan 01, 2012 5:53 am 
Offline
User avatar

Joined: Tue Dec 09, 2008 1:37 pm
Posts: 1844
Location: Dudley, West Midlands, UK
Weather Station: None !
Operating System: XP SP3
Weeeell ..........

First of all you need to have created the colour 'classes' in the css file.

Then you need to convert the JavaScript logic and variable names to the php logic and variable names.

In the js a class was been added, but in the php you are 'building' the cell <td class= > content </td> as you go.

So once you have done your range checks for a particular data type, instead of the js
$(data_cell).addClass(temp_class);

you would have something like:

$tablelayout .= '<td class="datacell ' .$temp_class. ' ">';
$tablelayout .= $data_arr[x];
$tablelayout .='</td>';

Someone has done all this already somewhere I would have thought, once their hangovers cleared hopefully they'll post the code ;)

_________________
Image
......................Imagine, what you will KNOW tomorrow !


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Sun Jan 01, 2012 5:58 pm 
Offline

Joined: Wed May 13, 2009 9:35 am
Posts: 110
Location: Nr Ilkley, West Yorks, UK
Weather Station: WMR-200
Operating System: Windows 7
Thanks Beteljuice.
Surprisingly, I had already figured something like that was what I needed and had tried this:

Code:
if (($dayfilecol2 >0) && (floatval(str_replace(',','.',$data_arr[1])) >= 30.0))
                  {
                  $tablelayout .= '<td class="datacell smallfontextremehigh">';
                  $tablelayout .= $data_arr[1];
                  $tablelayout .='</td>';
               }
            
         
            
               if (($dayfilecol2 >0) && (floatval(str_replace(',','.',$data_arr[1])) <= 29.9))
                  {
                  $tablelayout .= '<td class="datacell smallfontveryhigh">';
                  $tablelayout .= $data_arr[1];
                  $tablelayout .='</td>';
               }
            
            
            
               if (($dayfilecol2 >0) && (floatval(str_replace(',','.',$data_arr[1])) <= 25.0))
                  {
                  $tablelayout .= '<td class="datacell smallfonthigher">';
                  $tablelayout .= $data_arr[1];
                  $tablelayout .='</td>';
               }

etc..


..but that results in repetition of the high value as it agrees with each statement, and also completely screws the formatting resulting in this mess:

Attachment:
historic.PNG


Not knowing how to correctly break out once a condition is satisfied is my problem I believe. I assume I use the "break" word, but I don't know the correct syntax for it in this scenario :oops: When I tried "break;" in various places, it just resulted in no data being posted.

A little knowledge is a dangerous thing as they say......


You do not have the required permissions to view the files attached to this post.

_________________
bigmac
Menston Weather


Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Mon Jan 02, 2012 12:56 am 
Offline
User avatar

Joined: Tue Dec 09, 2008 1:37 pm
Posts: 1844
Location: Dudley, West Midlands, UK
Weather Station: None !
Operating System: XP SP3
Yup your code allows several results, each of which generates a table cell :lol:

Pseudo PHP code:
Code:
if( .. datatype..){ // eg. reasoning for temperature values
   $temp_check = floatval(str_replace(',','.',$data_arr[1]));  // get a 'real' numeric value
// do range checks for value
    if ($temp_check >=37.0) {
        $temp_class ='extremehigh';
    } elseif ($temp_check >=33.1) {
        $temp_class ='veryhigh';
    } elseif ($temp_check >=30.1) {
        $temp_class ='higher';
    } elseif ($temp_check >=25.1) {
        $temp_class ='high';
    } elseif ($temp_check >=20.1) {
        $temp_class ='low';
    } elseif ($temp_check >=10.1) {
        $temp_class ='lower';
    } elseif ($temp_check >=6.1) {
        $temp_class ='verylow';
    } else {
        $temp_class = 'extremelow';
    }  // END range check
// construct table cell
   $tablelayout .= '<td class="datacell ' .$temp_class. '">';
   $tablelayout .= $data_arr[1];
   $tablelayout .='</td>';
} // END data type


EDIT: corrected as per post below :oops:

_________________
Image
......................Imagine, what you will KNOW tomorrow !


Last edited by beteljuice on Mon Jan 02, 2012 7:16 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Annual Data Summary - Coloured Values
PostPosted: Mon Jan 02, 2012 2:11 pm 
Offline

Joined: Wed May 13, 2009 9:35 am
Posts: 110
Location: Nr Ilkley, West Yorks, UK
Weather Station: WMR-200
Operating System: Windows 7
Beteljuice, as ever, you have provided the answer :clap: for which I thank you!

And certainly not wishing to nit pick (after all I failed miserably at it!), but there was a bracket missed out after $data_arr[1]) ) ; on the 2nd line which had me scratching my head for a bit as it returned an error about an unexpected ";". So, just for the sake of clarity for anyone else reading, the ever so slightly corrected code:

Code:
if( .. datatype..){ // eg. reasoning for temperature values
   $temp_check = floatval(str_replace(',','.',$data_arr[1]));  // get a 'real' numeric value
// do range checks for value
    if ($temp_check >=37.0) {
        $temp_class ='extremehigh';
    } elseif ($temp_check >=33.1) {
        $temp_class ='veryhigh';
    } elseif ($temp_check >=30.1) {
        $temp_class ='higher';
    } elseif ($temp_check >=25.1) {
        $temp_class ='high';
    } elseif ($temp_check >=20.1) {
        $temp_class ='low';
    } elseif ($temp_check >=10.1) {
        $temp_class ='lower';
    } elseif ($temp_check >=6.1) {
        $temp_class ='verylow';
    } else {
        $temp_class = 'extremelow';
    }  // END range check
// construct table cell
   $tablelayout .= '<td class="datacell ' .$temp_class. '">';
   $tablelayout .= $data_arr[1];
   $tablelayout .='</td>';
} // END data type


Thank you again.

_________________
bigmac
Menston Weather


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group