Gradient Thermometer v1.08

I adjusted $minX = 20 to show the 1 in 100, but it shifted the blank image. The 100 is visible, but part of the underlying image is visible too.

   $minX =  17; // left
   $maxX =  27; // right
   $minY =  20; // top
   $maxY = 140; // bottom

Probably the wrong part to adjust?

Murry,
Could you please provide a textual representation of what line to change?
Thanks.

Lee,
What worked for me was changing lines 297-316 from


// Put on minimum temp bar/value
   if(isset($min)) {
      $Tpct = ( $min-$Tmin ) / $Trange ;
      $Y    = ( 1-$Tpct ) * ( $maxY-$minY ) + $minY;
      imagefilledrectangle( $image ,$minX-18 ,$Y ,$minX - 5 ,$Y+1, $blue );
      $tstr  = sprintf('%2d',round($min,0));
      $tsize = strlen($tstr) * imagefontwidth($font+1);
      imagestring( $image, $font+1 ,$minX-$tsize-3 ,$Y+2 ,$tstr ,$blue );
   }


// Put on maximum temp bar/value
   if(isset($max)) {
      $Tpct = ( $max-$Tmin ) / $Trange;
      $Y    = ( 1-$Tpct ) * ( $maxY-$minY ) + $minY;
      imagefilledrectangle( $image ,$minX-18 ,$Y ,$minX-5 ,$Y+1, $red );
      $tstr  = sprintf('%2d',round($max,0));
      $tsize = strlen($tstr)*imagefontwidth($font+1);
      imagestring($image, $font+1 ,$minX-$tsize-3 ,$Y-imagefontheight($font+1) ,$tstr ,$red );
   }

to


// Put on minimum temp bar/value
   if(isset($min)) {
      $Tpct = ( $min-$Tmin ) / $Trange ;
      $Y    = ( 1-$Tpct ) * ( $maxY-$minY ) + $minY;
      imagefilledrectangle( $image ,$minX-15 ,$Y ,$minX - 3 ,$Y+1, $blue );
      $tstr  = sprintf('%2d',round($min,0));
      $tsize = strlen($tstr) * imagefontwidth($font+1);
      imagestring( $image, $font+1 ,$minX-$tsize-1 ,$Y+2 ,$tstr ,$blue );
   }


// Put on maximum temp bar/value
   if(isset($max)) {
      $Tpct = ( $max-$Tmin ) / $Trange;
      $Y    = ( 1-$Tpct ) * ( $maxY-$minY ) + $minY;
      imagefilledrectangle( $image ,$minX-(15+(3*($max>=99.5))) ,$Y ,$minX-3 ,$Y+1, $red );
      $tstr  = sprintf('%2d',round($max,0));
      $tsize = strlen($tstr)*imagefontwidth($font+1);
      imagestring($image, $font+1 ,$minX-$tsize-1 ,$Y-imagefontheight($font+1) ,$tstr ,$red );
   }

Thanks Murry.

Thank you Murry for the explanation. I would never found it.

John

Ditto (never would have found that). We’re still going over 100 here in Phoenix, and probably will continue to do so for another 2 weeks or so. It’s really getting old, but nice to see the ‘1’ in place.

Thanks, Murry!

Is it possible to use this script without the Carterlake template?

I dont think so because for me its not working but may be…

greetz,
Oebel

Definitely, the thermometer.php script can be used without the template … you just need to configure the script itself to find your weather conditions from clientraw.txt, then invoke the script on your webpage by using it in an tag.

Best regards,
Ken

Hi Ken,

Ok

current temperature, daily low/high

Hi All

Has anyone managed to get this graphic working on the latest templates from Ken?

Clearly the thermometer script is working partially as it detects and gets data for the temperatures but fails to display on the thermometer graphic itself.

Any thoughts?

Jon

I have not gotten the image to work on my site as well. I think I have it setup right but have to be missing something in the img tag.

Mike

The issue is that the bws-thermometer.php is encountering an error:

Warning: file_get_contents(./weather/clientraw.txt): failed to open stream: No such file or directory in /hsphere/local/home/c277470/n7dq.com/weather/bws-thermometer.php on line 179

It can’t find the clientraw.txt.

Try changing your Settings-weather.php to have

$SITE['clientrawfile'] = './clientraw.txt';

since your site is in the /weather directory. Similar changes in Settings-weather.php that have ‘./weather/’ in them should be changed to ‘./’

Best regards,
Ken

Ken,

The one file I missed. Thanks!

Not sure if anyone has said this recently, but you “Rock!”

Thanks
Mike

Thanks for the kind words! :oops:

Hello,

The temp has hit 100 today and looking at the gradient thermometer it appears that the number 1 is being truncated on the image. I have tried changing the width in the dashboard with no luck and I have been looking in thermometer.php trying to find a place to edit the width, but I am stuck. Could someone point me in the right direction.

Thanks,
Paul


You might try changing

      imagestring( $image, $font+1 ,$minX-$tsize-3 ,$Y+2 ,$tstr ,$blue );

to

      imagestring( $image, $font ,$minX-$tsize-3 ,$Y+2 ,$tstr ,$blue );

and changing

      imagestring($image, $font+1 ,$minX-$tsize-3 ,$Y-imagefontheight($font+1) ,$tstr ,$red );

to

      imagestring($image, $font ,$minX-$tsize-3 ,$Y-imagefontheight($font) ,$tstr ,$red );

and see if that fixes the issue. It reduces the font size for the max/min numbers so maybe they’ll fit :slight_smile:

Hi Ken,

Well it did reduce the font size, but it did not correct the issue…it seems as though it does not have enough room in the image itself to display the 3 digits.

Hmmm… I don’t see the changed code in your thermometer.php … it currently reads:

// Put on minimum temp bar/value
   if(isset($min)) {
      $Tpct = ( $min-$Tmin ) / $Trange ;
      $Y    = ( 1-$Tpct ) * ( $maxY-$minY ) + $minY;
      imagefilledrectangle( $image ,$minX-18 ,$Y ,$minX - 5 ,$Y+1, $blue );
      $tstr  = sprintf('%2d',round($min,0));
      $tsize = strlen($tstr) * imagefontwidth($font+1);
      imagestring( $image, $font+1 ,$minX-$tsize-3 ,$Y+2 ,$tstr ,$blue );
   }


// Put on maximum temp bar/value
   if(isset($max)) {
      $Tpct = ( $max-$Tmin ) / $Trange;
      $Y    = ( 1-$Tpct ) * ( $maxY-$minY ) + $minY;
      imagefilledrectangle( $image ,$minX-18 ,$Y ,$minX-5 ,$Y+1, $red );
      $tstr  = sprintf('%2d',round($max,0));
      $tsize = strlen($tstr)*imagefontwidth($font+1);
      imagestring($image, $font+1 ,$minX-$tsize-3 ,$Y-imagefontheight($font+1) ,$tstr ,$red );
   }

so is not using the changes I proposed ?

Umm, that would be because I uploaded the wrong file… :oops:; however I have now uploaded the modified file and I do not see a change… :wink:

ADD:
I edited the lines above the ones you pointed out and that seemed to work;

$tsize = strlen($tstr) * imagefontwidth($font+1);

changed to

$tsize = strlen($tstr) * imagefontwidth($font);

Thanks for your help Ken! :smiley:

Ahhh… good catch. Glad it worked with your addition.

Best regards,
Ken