If you use Cumulus, please donate Image

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Highcharts Graphs

Discussion and support for 3rd-party (non-Sandaysoft) tools for Cumulus
User avatar
mcrossley
Posts: 4945
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Highcharts Graphs

Postby mcrossley » Fri Jan 08, 2016 12:02 pm

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.

User avatar
HRVistaWeather
Posts: 146
Joined: Mon Apr 09, 2012 2:38 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 (64bit)
Location: Franklin, Huon Valley, Tasmania

Re: Highcharts Graphs

Postby HRVistaWeather » Fri Jan 08, 2016 1:54 pm

Hi Mark,

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

regards,
Tony

Huon River Vista Weather - South Franklin - Tasmania
Davis Vantage Pro 2 Plus - FARS, Cumulus MX, 2 Soil Temp/Moist Solar/Rad.
Weather PC Died 2016/11/21 15:25 Cannot justify replacement (Website dead)

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

Re: Highcharts Graphs

Postby mcrossley » Tue Jan 12, 2016 10:30 am

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.

User avatar
HRVistaWeather
Posts: 146
Joined: Mon Apr 09, 2012 2:38 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 (64bit)
Location: Franklin, Huon Valley, Tasmania

Re: Highcharts Graphs

Postby HRVistaWeather » Wed Jan 13, 2016 12:09 am

Hi Mark,

Brilliant thank you, think I got it all running OK, seems to be correct. http://hrvistaweather.com/weather/wxhistoricChartsAll.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,
Tony

Huon River Vista Weather - South Franklin - Tasmania
Davis Vantage Pro 2 Plus - FARS, Cumulus MX, 2 Soil Temp/Moist Solar/Rad.
Weather PC Died 2016/11/21 15:25 Cannot justify replacement (Website dead)

UncleBuck
Posts: 34
Joined: Sat Dec 29, 2012 10:27 pm
Weather Station: Davis VP2+
Operating System: MAC Mini - OSX El Capitan
Location: Victoria, Australia

Re: Highcharts Graphs

Postby UncleBuck » Wed Feb 24, 2016 12:27 pm

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.

UncleBuck
Posts: 34
Joined: Sat Dec 29, 2012 10:27 pm
Weather Station: Davis VP2+
Operating System: MAC Mini - OSX El Capitan
Location: Victoria, Australia

Re: Highcharts Graphs

Postby UncleBuck » Wed Feb 24, 2016 12:34 pm

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.

UncleBuck
Posts: 34
Joined: Sat Dec 29, 2012 10:27 pm
Weather Station: Davis VP2+
Operating System: MAC Mini - OSX El Capitan
Location: Victoria, Australia

Re: Highcharts Graphs

Postby UncleBuck » Wed Feb 24, 2016 11:29 pm

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,

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

Re: Highcharts Graphs

Postby mcrossley » Tue Mar 01, 2016 10:35 pm

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).

User avatar
Mapantz
Posts: 438
Joined: Sat Dec 17, 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64 - A beast.
Location: Wareham, Dorset - UK
Contact:

Re: Highcharts Graphs

Postby Mapantz » Sat Mar 12, 2016 4:56 pm

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.
Image
Image

User avatar
Mapantz
Posts: 438
Joined: Sat Dec 17, 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64 - A beast.
Location: Wareham, Dorset - UK
Contact:

Re: Highcharts Graphs

Postby Mapantz » Sun Mar 13, 2016 2:16 pm

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. :)
Image
Image

Dinant
Posts: 34
Joined: Sat Aug 17, 2013 9:11 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 2003
Location: Markelo
Contact:

Re: Highcharts Graphs

Postby Dinant » Mon Mar 14, 2016 5:31 pm

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[i].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

Dinant
Posts: 34
Joined: Sat Aug 17, 2013 9:11 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 2003
Location: Markelo
Contact:

Re: Highcharts Graphs

Postby Dinant » Mon Mar 14, 2016 5:33 pm

Forgot to mention: my website: http://www.weerstation-markelo.nl/test.php

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

Re: Highcharts Graphs

Postby mcrossley » Mon Mar 14, 2016 6:50 pm

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.

Dinant
Posts: 34
Joined: Sat Aug 17, 2013 9:11 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 2003
Location: Markelo
Contact:

Re: Highcharts Graphs

Postby Dinant » Tue Mar 15, 2016 9:33 am

That does the job. Thanks.

Dinant

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

Re: Highcharts Graphs

Postby mcrossley » Tue Mar 15, 2016 10:41 am

Great!

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


Return to “3rd Party Tools”

Who is online

Users browsing this forum: No registered users and 2 guests