Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Little day/night chart

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

Moderator: daj

User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Little day/night chart

Post by mcrossley »

I picked this up from WD forum, some people on there were using the old depreciated Google chart API's and PHP to generate a little day/night graphic.

I implemented in JavaScript and used teh Cumulus tags to produce a 'better' one. This shows dawn and dusk twilights in pink as well as full daylight in yellow, and night as midnight blue rather than black. It also keeps the daylight sector centred at 9 O'Clock. Like this...
day_night_chart.png
You can see it on my Index page here.

The code to produce this is:

Code: Select all

On your HTML page add an empty span to hold the image:

<span id="daylightChart" style="width:75px; height:75px; margin: 0px 5px; border:0"></span>


Then add some JavaScript to create the image and add it into the span...

<script>
var dayPct = (+'<#daylength>'.split(':')[0] + '<#daylength>'.split(':')[1] / 60) / 24 * 100;
var duskPct = (+'<#daylightlength>'.split(':')[0] + '<#daylightlength>'.split(':')[1] / 60) / 24 * 100;
duskPct -= dayPct;
var nightPct = 100 - dayPct - duskPct;
duskPct /= 2;
document.getElementById('daylightChart').innerHTML = '<img src="http://chart.apis.google.com/chart?' +
				'chs=75x75' +
				'&chtt=day/night' +
				'&chts=000000,12' +
				'&chma=0,0,0,0' +
				'&chd=t:' + duskPct + ',' + dayPct + ',' + duskPct + ',' + nightPct +
				'&cht=p3' +
				'&chp=' + (Math.PI - (dayPct + duskPct * 2) / 100 * Math.PI) +
				'&chf=bg,s,FFFFFF00' +
				'&chco=F046A1,FFD700,F046A1,303060' +
				'" alt="day/night ratio"/>';

</script>
I haven't actually tested the above (I do it slightly differently on my page), but another way would be to put the JavaScript in-line where you want the image and just do a document.write('<img src="http://chart.apis.google.com/chart?' +
'chs=75x75' +
'&chtt=day/night' +
'&chts=000000,12' +
'&chma=0,0,0,0' +
'&chd=t:' + duskPct + ',' + dayPct + ',' + duskPct + ',' + nightPct +
'&cht=p3' +
'&chp=' + (Math.PI - (dayPct + duskPct * 2) / 100 * Math.PI) +
'&chf=bg,s,FFFFFF00' +
'&chco=F046A1,FFD700,F046A1,303060' +
'" alt="day/night ratio"/>');
instead.
You do not have the required permissions to view the files attached to this post.
User avatar
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Re: Little day/night chart

Post by William Grimsley »

Interesting invention, Mark! :D
User avatar
PaulMy
Posts: 3847
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: Little day/night chart

Post by PaulMy »

HI Mark, and thanks again for your talent and sharing. I have inserted it http://www.komokaweather.com and is there a way to narrow the distance space between the "day/night" heading and the chart? I have enlarged the chart but I don't think the distance ratio in my revision is changed from the space in your original 75x75 size.

Paul
VP2+
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
Image
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Little day/night chart

Post by mcrossley »

No, you cannot position the title. You could omit it and put the text on the page though.
User avatar
PaulMy
Posts: 3847
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: Little day/night chart

Post by PaulMy »

OK thanks Mark, that could be my homework of today's lesson.

Paul
VP2+
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
Image
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Little day/night chart

Post by mcrossley »

If you miss the title off, it comes out larger if you make the image wider than it is tall.
User avatar
PaulMy
Posts: 3847
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: Little day/night chart

Post by PaulMy »

Thanks again Mark. I started my homework but thrashed away most of the pages :bash: , as I got the chart and text showing up all over the place - but a good lesson on the results of placing of text within and outside of <table> and<tbody> tags :o

It has been a bit of fun, but painstaking - with each little indexT edit, wait or force a Cumulus web update to see the results, try another edit, etc. I tried to run it outside of the Cumulus indexT page so I could use Filezilla to ftp but that didn't work well. I use Notepad++ for all my edits now (put Dreamweaver aside because it is too overwelming) and is there something else that I can do or run to see the affect of an edit change without uploading to my webserver?

Paul
VP2+
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
Image
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Little day/night chart

Post by mcrossley »

Well in Chrome (and Firefox I'm pretty sure) you can edit the HTML on the fly in the dev tools, and disable /create CSS elements etc. The dev tools are very powerful but they take a bit of learning. It is great to be able to see the effects of any changes immediately in the browser though.

The other alternative (probably easier to begin with) is to save a copy of your processed page locally and then edit that and load the locally saved page into your browser. Once you are happy, transfer the changes back into your template file.
User avatar
robynfali
Posts: 1076
Joined: Sat 31 Jul 2010 10:34 pm
Weather Station: Vantage Vue
Operating System: Windows XP
Location: Anglesey, North Wales, UK
Contact:

Re: Little day/night chart

Post by robynfali »

I have that on my watch, would be a good comparison
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: An Alternative Little day/night chart

Post by beteljuice »

An Alternative
The beteljuice has a great mistrust of (google) APIs and 'the cloud' etc. prefering to have some degree of control over what happens, and also reducing global internet traffic.

So here's a beteljuice plaything (not quite as neatly drawn) and with a different slant (or two) on display.

EDIT: V2.0 Incorporating drawing improvements / suggestions by Mark.
EDIT: V3.0 Incorporating logic fix by Mark Crossley.
EDIT: V3.1 hours markers option added

Image Midday (Civil) is 'North' and a 24 hour 'clock' hand shows 'now' time.
Image Midday (Civil) is 'North' and a 24 hour 'clock' hand shows 'now' time with hours markers.
Image 'Heavens' rotate East to West through North with a 'now' marker @ North.

As you can see Civil, Nautical and Astronomical twilights are shown.

Practically everything is configurable and most things can be 'posted' on-the-fly.

You MUST be running PHP 5+
If 'safe_mode' exists it should be "off". (Maybe unimportant following tweaks - unproven)
If you are unsure of the above, unzip and run the following file in your webspace:
fdebug.zip
If it suggests that safe_mode is enabled, check your web space control panel / settings and see if you can turn it "off", else contact your support.
If they say "Oh no can't do that its insecure", tell them its caused so much problems that it is depreciated in ver 5.3 and doesn't even exist in ver 5.4 ! - give them this link: http://uk.php.net/manual/en/features.safe-mode.php

GET / VIEW commented CODE

'Tis a beteljuice throwaway freebie ... enjoy or not as you wish :lol:

Edit: Forgot to mention. It's a stand-alone and no weather software is required :o

Edit: Basic usage ...

Using a txt editor such as Notepad++ change the timezone to YOUR location:

Code: Select all

$time_locale = "Europe/London";  // set your timezone - see: http://php.net/manual/en/timezones.php
If you are not using saratoga / carterlake template(s) you won't have a Settings.php so you need to change the lat / long, this is MY location ;)

Code: Select all

//----------------------------------------------------------------------------\\
// SETTINGS: only customise if you have no "Settings.php"                     \\
//----------------------------------------------------------------------------\\
if (!@(include_once "Settings.php")) {
   $SITE['latitude']      = 52.512; // N+, S-
   $SITE['longitude']      = -2.096; // W-, E+
}
   
To use it in an html page just call it like you would any other graphic.
Using your file name ....

Code: Select all

<img src="heavens.php" alt="day / night chart" title="day / night chart" />
EDIT:
If you really must have a bit of JavaScript to update the image on the page, please be aware that the 'resolution' of the graphic (regardless of size) is 1 degree (values rounded) which equates to 4 minutes.
So it would be pointless to have a refresh rate of less than 2 min. ;)
You do not have the required permissions to view the files attached to this post.
Last edited by beteljuice on Wed 11 Sep 2013 10:44 am, edited 10 times in total.
Image
......................Imagine, what you will KNOW tomorrow !
gemini06720
Posts: 1700
Joined: Mon 10 Aug 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: Little day/night chart

Post by gemini06720 »

mcrossley wrote:I picked this up from WD forum, some people on there were using the old depreciated Google chart API's and PHP to generate a little day/night graphic.
And, I picked up from you (you code modified to PHP), combined it with the code found/posted in the Weather-Watch forums and came up with this: :mrgreen:
Last edited by gemini06720 on Sun 09 Jun 2013 9:16 am, edited 1 time in total.
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Little day/night chart

Post by mcrossley »

gemini06720 wrote:And, I picked up from you (you code modified to PHP), combined it with the code found/posted in the Weather-Watch forums and came up with this: :mrgreen:
That's the way to do it, code sharing helps everyone. ;)
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Little day/night chart

Post by beteljuice »

Just a thought ...
What happens if daylight is all (today) or dawn > dusk is all (today) ?
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Little day/night chart

Post by mcrossley »

beteljuice wrote:Just a thought ...
What happens if daylight is all (today)
You get a yellow disk?
beteljuice wrote:or dawn > dusk is all (today) ?
There is no night sector - your version with astronomical twilight will not have any night sector in the UK around mid-summer.

If I'm understanding you right.
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: An Alternative Little day/night chart

Post by mcrossley »

beteljuice wrote: The beteljuice has a great mistrust of (google) APIs and 'the cloud' etc. prefering to have some degree of control over what happens, and also reducing global internet traffic.
Hi betejuice, I ran into a problem with the script. I do not have a 'Settings.php' file and this fails:

Code: Select all

if ((include_once "Settings.php") == 0) {
   $SITE['latitude' ]      = 52.512; // N+, S-
   $SITE['longitude']      = -2.096; // W-, E+
}
I changed it to

Code: Select all

if (!@(include_once "Settings.php")) {
   $SITE['latitude' ]      = 52.512; // N+, S-
   $SITE['longitude']      = -2.096; // W-, E+
}
and the script now runs

Edit: and shouldn't the output header be

Code: Select all

header('Content-Type: image/png');
My implementation: http://weather.wilmslowastro.com/images/sun_graphic.php
Post Reply