Page 19 of 28

Re: Highcharts Graphs

Posted: Fri 08 Jan 2016 12:02 pm
by mcrossley
Also setting up a view will not do anything for the compute time. BTW, I just added a new sunshine chart - from yet another intermediate table. If I get time the Sun by hour data can be derived easily from the new Sun by Month & Hour table, but for now I'm running both. Let me know if you want the query to build the new table.

Re: Highcharts Graphs

Posted: Fri 08 Jan 2016 1:54 pm
by BeaumarisWX
Hi Mark,

Yes for sure matey, that looks brilliant. What a great way to display it, your a legend.

regards,

Re: Highcharts Graphs

Posted: Tue 12 Jan 2016 10:30 am
by mcrossley
Sorry Tony, I was playing around with a few things. The sunshine by month and hour table is defined as:

Code: Select all

month - int(2)
hour - int(2)
sun - decimal (5,2)
percent - decimal(3,1)
The insert statements are:

Code: Select all

	DELETE FROM <db_name>.`sunbymonthhour`;
	INSERT INTO <db_name>.`sunbymonthhour`
	SELECT  month,
			hour,
			sum(sun),
			round(sum(sun) / count(*) * 100, 1)
	FROM (
		SELECT  month(CONVERT_TZ(t.LogDateTime,"EUROPE/London","UTC")) AS month,
				hour(CONVERT_TZ(t.LogDateTime,"EUROPE/London","UTC")) AS hour,
				(min(n.HrsSunShine) - min(t.HrsSunShine)) AS sun
		FROM <db_name>.<logdata_table_name> as t
		JOIN <db_name>.<logdata_table_name> as n
		ON t.LogDateTime = date_sub(n.LogDateTime, INTERVAL 1 hour)
		WHERE t.LogDateTime > "2013-4-14"
		AND hour(t.LogDateTime) BETWEEN 2 AND 22
		GROUP BY date_format(t.LogDateTime, "%Y%m%d%H")
	) as x
	GROUP BY month, hour;
The TZ settings will need adapting to your specific TZ as before - as will the solar data start date if it does not correspond with the general data start date, otherwise the t.LogDateTime > "2013-4-14" clause can be deleted.

Re: Highcharts Graphs

Posted: Wed 13 Jan 2016 12:09 am
by BeaumarisWX
Hi Mark,

Brilliant thank you, think I got it all running OK, seems to be correct. http://hrvistaweather.com/weather/wxhis ... rtsAll.php

In historicGraphs.js I changed:

From:

Code: Select all

var temperatureHourlyMonth = function () {
	try {
		chart.showLoading();
	} catch (e) {}

	$('#graph_description').text(
		'The average temperature for each hour of the day plotted per month. You can enable/disable the individual series plots by clicking on them in the graph legend.'
	);
To:

Code: Select all

var temperatureHourlyMonth = function () {
	try {
		chart.showLoading();
	} catch (e) {}

	$('#graph_description').text(
		'The average temperature for each hour of the day plotted per month.'
	);

removing the " You can enable/disable the individual series plots by clicking on them in the graph legend."

regards,

Re: Highcharts Graphs

Posted: Wed 24 Feb 2016 12:27 pm
by UncleBuck
I know this thread is now over a month since the last post but thought I would chime in on Tony's problem with time zone conversions.

If the hosting providers version of MySQL does not have the Timezone tables populated then you can't use the Australia/Hobart format for time conversion. The only way I have found around this was as follows:

Check the time that MySQL is using by using a simple select statement and returning now(). (in my case it was AEST)
Then use convert_tz(LogDateTime,"SYSTEM","+10:00")

Col.

Re: Highcharts Graphs

Posted: Wed 24 Feb 2016 12:34 pm
by UncleBuck
Just thinking a little more on that and realised even that is wrong.

MX is storing the log file date as daylight time, MySQL is set to use standard time so I will have to think a little more on that.

Re: Highcharts Graphs

Posted: Wed 24 Feb 2016 11:29 pm
by UncleBuck
Hi Mark,
Just a quick question for clarification purposes.

In your scripts you use several table names that are not what CMX creates as the part of the SQL setup. Could you please provide your equivalent table names for the following CMX tables:

CMX table Your table
Dayfile
Monthly
Realtime

If you could also provide the names of other tables used for these graphs that are not part of a standard CMX setup that would fantastic.

Regards,

Re: Highcharts Graphs

Posted: Tue 01 Mar 2016 10:35 pm
by mcrossley
Hi Colin, I think they are pretty self explanatory, I try and use the standard table names in released scripts, but sometimes forget!

Dayfile=daydata
Monthly=fulldata
Realtime=realtime

I use other tables and views for various bits'n'bobs...
facts
sunbyhour
sunbymonthhour
tide
monthlytemps (view)

and some triggers (post-insert on daydata, and pre-insert on realtime) to generate various derived values (a running 10 minute average UV-I that Cumulus does not create for instance).

Re: Highcharts Graphs

Posted: Sat 12 Mar 2016 4:56 pm
by Mapantz
Hi folks.

I wonder if somebody could spare five minutes?

I've just setup the realtime Highcharts on my server, and the way I decided to create the realtime log was through TNET's php script & running a cronjob every minute. I thought I had cracked it, until I saw the first update..

The realtimelog.txt is updating fine: http://www.warehamwx.com/cu/realtime.log

When the page loads, the graphs create fine, when the update comes, the timestamp at the bottom of the graph turns in to years 2006 - 2016: http://www.warehamwx.com/cu/realtime.log

I'm a bit stumped and confused now! :oops:

Many thanks.

Re: Highcharts Graphs

Posted: Sun 13 Mar 2016 2:16 pm
by Mapantz
I solved my own problem in the end. It was the date format in TNET's script.. It produced 2016-03-13 in the realtimelog, while the realtime.txt is 13/03/16

I changed a line in the realtimelog.php to:

Code: Select all

$data="DD/MM/YY"; echo "20" . substr($data,6,2) . "-" . substr($data,0,2) . "-" . substr($data,3,2);
The dates match, and the graph now updates and executes with no issues. :)

Re: Highcharts Graphs

Posted: Mon 14 Mar 2016 5:31 pm
by Dinant
Hi Mark,

I like your historic highcharts on your website. I have copied the necessary files to my own site. But I have a small problem. If I press under the column Rainfall on the Drill Down button it keeps saying Loading...
In the javascript console it says:
Uncaught TypeError: Cannot read property 'length' of undefined historicGraphs.js:1610.
It is about this section:

Code: Select all

					for (k = 0; k < resp[i].months[j][2].length; k++) {
						options.drilldown.series[options.drilldown.series.length-1].data[k] = {
							name: resp[i].months[j][2][k][0] + '-' + resp[i].months[j][0],
							y   : resp[i].months[j][2][k][1]
						};
					}
This variable resp.months[j][2].length is undefined.
If I comment this section the graph is shown but the second drill doesn't show anything.

Do you know what is wrong?

Dinant

Re: Highcharts Graphs

Posted: Mon 14 Mar 2016 5:33 pm
by Dinant
Forgot to mention: my website: http://www.weerstation-markelo.nl/test.php

Re: Highcharts Graphs

Posted: Mon 14 Mar 2016 6:50 pm
by mcrossley
Your historicRainByYear.php script is not returning data for the first months of 2013, until August 17th...

Code: Select all

[{"year":"2013","total":371.8,"months":[["Jan",0],["Feb",0],["Mar",0],["Apr",0],["May",0],["Jun",0],["Jul",0],["Aug",12.8,[[17,0],
Try changing the PHP...

Code: Select all

from this...
		while ($m < (int)$monthRow[1]) {
			$valTot[$m - 1] = array($months[$m-1], 0);
			$m++;
		}

to this...
		while ($m < (int)$monthRow[1]) {
			$valTot[$m - 1] = array($months[$m-1], 0, array());
			$m++;
		}
I had put that code into my historicSunshineByYear.php as that starts mid-year and I obviously hit the same issue, but it looks like I forgot to go back and fix the rainfall script as my rain records happen to start in January 2010.

Re: Highcharts Graphs

Posted: Tue 15 Mar 2016 9:33 am
by Dinant
That does the job. Thanks.

Dinant

Re: Highcharts Graphs

Posted: Tue 15 Mar 2016 10:41 am
by mcrossley
Great!

PS: You don't need to copyright me for the graphs - but the acknowledgement is nice, thanks.