Author Topic: A Different Sunlight Pie Chart in My Saratoga Template and Dashboard  (Read 6618 times)

0 Members and 1 Guest are viewing this topic.

Offline Breezy

  • Indian Trail Weather
  • Forecaster
  • *****
  • Posts: 325
    • Indian Trail Weather
Re: A Different Sunlight Pie Chart in My Saratoga Template and Dashboard
« Reply #25 on: September 23, 2017, 02:24:47 PM »
Quote
Dennis,

I'm trying to install the script following the notes in Jerry's thread as included here. I'll post to this thread as I make progress. Testing will be conducted at
http://indiantrailweather.com/indextest.php

Jeff

Update: As soon as I edited "common.php" my page went blank. Too much for me. I'll be sticking with my current version.

Jeff
Jeff

W7-64, Intel Z170A 16 GB RAM
Davis VP2 Plus, Davis Soil Moisture/Temp Sensors, Laser Snow Depth Sensor LR4/Fluke 414D

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: A Different Sunlight Pie Chart in My Saratoga Template and Dashboard
« Reply #26 on: September 23, 2017, 02:38:24 PM »
Update: As soon as I edited "common.php" my page went blank. Too much for me. I'll be sticking with my current version.

Jeff
Unless you are using the sunlight pie chart in your menubar, and I see you're not, you DON'T need to modify 'common.php'.  Just add the two functions to the 'function' section of your 'ajax-dashboard6.php' instead.  They will be read in as needed by your dashboard.

Here are the relevant functions in my 'ajax-dashboard6.php':
Code: [Select]
// -----------------------------------------------------------------------------
// The following functions were added by SE Lincoln Weather as part of ajax-dashboard69x
// -----------------------------------------------------------------------------
// Keep images fresh
// Adds timestamp to image making it unique
// -----------------------------------------------------------------------------
if (!function_exists('getUniqueImageURL')) {
function getUniqueImageURL($image_url){
$timestamp = time();
if(strpos($image_url, '?')){
$image_url = str_replace('?', "?$timestamp&", $image_url);
}
else{
$image_url .= "?$timestamp";
}
return $image_url;
}
}
// end of getUniqueImageURL
//
// -----------------------------------------------------------------------------
// CHANGE IN DAYLENGTH FUNCTION:  computes length of yesterday, today,  & tomorrow
//   and then the change in day length from yesterday to today
// Written by SE Lincoln Weather                                                           .
// -----------------------------------------------------------------------------
// Alternate $changeinday routine that finds $changeinday2
if (!function_exists('get_changeinday')) { // Avoid fatally re-declaring this!!!
function get_changeinday() {
$hrsOfSunLight = array();
global $SITE;

$t = time()-86400; // Yesterday

for ($i=0; $i<(2+($displayTomorrow?1:0)); $i++) { // Only loop twice if no $displayTomorrow
$sun = date_sun_info($t, $SITE['latitude' ], $SITE["longitude"]);
$srise  = $sun["sunrise"];
$sset  = $sun["sunset"];
$sunhrs[$i] = $sset - $srise;   // $sunhrs is time between sunrise and sunset
$sh[$i] = floor($sunhrs[$i]/3600); // Sun Hours
$sm[$i] = floor((($sunhrs[$i]/3600)-$sh[$i])*60); // Sun Minutes
$ss[$i] = round(((((($sunhrs[$i]/3600)-$sh[$i])*60)-$sm[$i])*60),0); // Sun Seconds
$hrsOfSunLight[$i] = $sh[$i].':'.$sm[$i].':'.$ss[$i]; // Assemble strings in array
$t+=86400; // Next Day
}

$cindsign = (($sunhrs[1]-$sunhrs[0])>0)?'+':'-'; // Change IN Day sign

$shdiff = ($cindsign=='-'?($sh[0] - $sh[1]):($sh[1] - $sh[0])); // Difference in hours
$smdiff = ($cindsign=='-'?($sm[0] - $sm[1]):($sm[1] - $sm[0])); // Difference in minutes
$ssdiff = ($cindsign=='-'?($ss[0] - $ss[1]):($ss[1] - $ss[0])); // Difference in seconds
if ($ssdiff<0) { // negative number of seconds?
$smdiff -= 1; // borrow
$ssdiff += 60; // and carry
}
if ($smdiff<0) { // negative number of minutes?
$shdiff -=1; // borrow
$smdiff += 60; // and carry
}
$changeinday2 = $cindsign.$shdiff.':'.$smdiff.':'.$ssdiff; // Assemble cind string
$result = array($changeinday2,$hrsOfSunLight);
return $result;
}
}
// end of changeinday()

« Last Edit: September 23, 2017, 02:44:46 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Breezy

  • Indian Trail Weather
  • Forecaster
  • *****
  • Posts: 325
    • Indian Trail Weather
Re: A Different Sunlight Pie Chart in My Saratoga Template and Dashboard
« Reply #27 on: September 24, 2017, 09:53:01 AM »
I've added the functions in the dashboard and now need to get the php scripting correct in the dashboard.  ](*,) http://indiantrailweather.com/indextest.php It would probably behoove me to take a PHP scripting course 101 ...  :idea:
Jeff

W7-64, Intel Z170A 16 GB RAM
Davis VP2 Plus, Davis Soil Moisture/Temp Sensors, Laser Snow Depth Sensor LR4/Fluke 414D

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: A Different Sunlight Pie Chart in My Saratoga Template and Dashboard
« Reply #28 on: April 03, 2019, 04:13:04 PM »
Thanks for the info!  I've repackaged the ajax-dashboard6.php with the heavens.pie mods
along with the needed images and support scripts into one distribution to make it easier for initial installs to use.  The dashboard was updated to allow both DarkSky and the new WU/TWC forecasts.  I took the opportunity to replace the Google charts sunpie with Gerry's version of beteljuice's sunpie (made by heavens.php and cached in ./cache/heavenpie.png).  Also rooted around and collected the old included scripts needed, updated all for PHP7+ where needed.

Should make new installs a bit easier for folks.  Download the 6.95b package from legacy scripts page.

Best regards,
Ken

« Last Edit: April 03, 2019, 06:12:20 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: A Different Sunlight Pie Chart in My Saratoga Template and Dashboard
« Reply #29 on: April 03, 2019, 04:56:28 PM »
A stellar job, as usual, Ken!  Kudos for assembling this package which should make it much easier for people to install Scott's Alternate Dashboard 695 with all the added bells and whistles including the 'raintodate' script and of course the Cumulus-derived sunlight pie chart. \:D/ =D&gt; \:D/
Regards, Jerry Wilkins
gwwilk@gmail.com