Page 2 of 4

Re: Highcharts Tides

Posted: Mon 09 Dec 2013 1:34 pm
by mcrossley
SpaceWalker wrote:Any chances of getting such a package before the end of year 2013... :lol:
I doubt it, this is low priority - so low I'd forgotten about it until someone PM'd me on another forum yesterday! Like I said if I were to do it again I'd probably use the HighStock variant of HighCharts.

To implement it yourself, the JavaScript is obviously on that demo page, the PHP can be had by using the view-sce option:
https://weather.wilmslowastro.com/test/ ... p?view-sce

The SQL table is really simple...

Code: Select all

--
-- Table structure for table 'tide'
--

CREATE TABLE tide (
  LogDate datetime NOT NULL,
  height decimal(3,2) DEFAULT NULL,
  PRIMARY KEY (LogDate)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
I used a 10 minute time interval, so use wxtide to generate some data, something like

Code: Select all

-incremental 10 -gstart <startdate> -nummonths <num_of_moths_required> -csv -file "filename"
Then edit in an editor and/or spreadsheet to concatenate the date/time values with delimiters etc, and wrap in the SQL statement like 'insert into <table> LogDate=<date-time>, height=<value>'. Or bulk import for example...

Code: Select all

INSERT INTO `tide` (`LogDate`, `height`) VALUES
('2012-12-20 00:00:00', 3.06),
('2012-12-20 00:10:00', 3.19),
('2012-12-20 00:20:00', 3.33),
('2012-12-20 00:30:00', 3.46),
('2012-12-20 00:40:00', 3.59),
('2012-12-20 00:50:00', 3.71),
('2012-12-20 01:00:00', 3.83),
('2012-12-20 01:10:00', 3.95),
And Robert's your father's brother.

Re: Highcharts Tides

Posted: Fri 17 Jul 2015 1:40 pm
by Big Daddy
I really hate to bring up an old topic but just came across this as its my next "project" as I live near the South Coast.

I took a look at Marks webpage and unfortunately its beyond me where to even start.

Did anybody ever implement this and could you give me some help please.

Thanks
Andy

Re: Highcharts Tides

Posted: Fri 02 Oct 2015 11:49 pm
by nar00ma
Hi, I have used WxTide32 to generate the data. I works for my location and has data world wide. http://www.wxtide32.com/
You can see the simple output on my side. http://www.ringlandsbay.com

Re: Highcharts Tides

Posted: Fri 28 Dec 2018 7:03 pm
by Big Daddy
Sorry to open an old thread but a tide chart has been in my head for a while, especially since the UK Admiralty opened an API
https://admiraltyapi.portal.azure-api.net/

I have signed up and currently put a 7 day table for selected ports of interest on my website but it would be nice to show this in a graph as well but have no idea where to start. I pull down a json file and then extract the data from there but you can get an xml download as well.....if it’s easier.

Andy

Re: Highcharts Tides

Posted: Fri 28 Dec 2018 8:24 pm
by mcrossley
Interesting, shame you can't get the documentation without signing up. :bash: It should be fairly straightforward to graph the data though.

Re: Highcharts Tides

Posted: Fri 28 Dec 2018 9:05 pm
by Mapantz
I see I posted a reply 6 years ago lol

I still actively go sea spinning and fishing, so tides are of a great used to me! :D

Re: Highcharts Tides

Posted: Sat 29 Dec 2018 3:40 pm
by mcrossley
Here's a quick and dirty use of the API...
https://weather.wilmslowastro.com/test/tides/tides2.php

It caches the API data for 1 hour to minimise API calls - though you are allowed 10,000 calls a month iirc.

Re: Highcharts Tides

Posted: Sat 29 Dec 2018 5:54 pm
by dazza1223
is there a download link then mark :D :D

Re: Highcharts Tides

Posted: Sat 29 Dec 2018 7:03 pm
by mcrossley
Link added to the demo page.

Re: Highcharts Tides

Posted: Sat 29 Dec 2018 8:36 pm
by Big Daddy
Hi Mark,
That’s brilliant and very quick. Thanks so much, that would have taken me weeks to even get just a basic graph.

I will download and have a look tomorrow to try and understand :D

Is it using the straight download of the json file from the Admiralty. From what I read and have downloaded so far, it’s a very basic API but gives the important basic information.

Thanks again.

Andy

Re: Highcharts Tides

Posted: Sat 29 Dec 2018 8:51 pm
by mcrossley
Yes, it uses the JSON data, and extracts the time and height info for the graph.

I have a test version that adds high/lowtide to the tooltip rather than the static 'tide' text. It's not working how I would like though, and I'm having a hard time working out how to configure HighStock to do what I want.

The spline curve isn't perfect, particularly at the start/end of the the data, but it gives an rough indication. The API data says that intermediate data is/should be available, but it doesn't appear to be implemented as an as API call yet.

Re: Highcharts Tides

Posted: Sun 30 Dec 2018 5:28 pm
by Mapantz
Question: Where do you find a list of station ID's? I'm having a thick moment.. :lol:

Re: Highcharts Tides

Posted: Sun 30 Dec 2018 5:57 pm
by mcrossley
I used the "try it" page for the stations API, you input a port name and it returns the ID and other info.

Now, how you know all the port names... :groan:

Re: Highcharts Tides

Posted: Sun 30 Dec 2018 6:15 pm
by mcrossley

Re: Highcharts Tides

Posted: Sun 30 Dec 2018 8:50 pm
by Big Daddy
Hi Mark,
I got a chance to look at this tonight. For me it works ok, I just need to make some chamges to colurs, size etc so it fits in with the rest of my website.

A couple of things I noticed.

It didnt immediately load when I put it on my Pi that I use as a webserver. The error seems to be in the first line of tideDemo.php file where it has this:
<?php require 'zbblock.php'; ?>

I dont have that php file so it immediately stalled. Once removed it was ok.

Secondly, it never seems to create a cache file. Have tried entering a cache directory, lets say /var/www/html/tides and hoped it might create as per your notes. Also manually created the directory but it never seems to cache the file. May be my ignorance / inexperience.
[EDIT Have resolved this now. Permissions error on the directory. :bash: ]

And finally, I see you modify the json file thats downloaded to just take out the date and height. Does that also change the formatting of the original file and put it into something like the json files Cumulus uses for tempdata etc. e.g. {"mintemp":[[1545523200000,3.3],[1545609600000,-0.9],[1545696000000,-0.8],[1545782400000,6.3]

I currently use 6 x API calls to get tide data for 6 x ports and was hoping to use something like the weather graphs to generate them on one page (see http://www.midlifedad.me.uk/weather/trends.php) and replacing Temperature, Pressure, Humity etc with the different ports. However the Admirilty API generates things differently and I am not clever enough and dont have the knowledge on how to extract the data and convert it. Any pointers.

Alternative is to have 6 x different php pages based around your scripts.

Thanks again for all your efforts

Andy