Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

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
HRVistaWeather
Posts: 164
Joined: Mon Apr 09, 2012 2:38 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 7 Ultimate (64bit)
Location: Franklin, Huon Valley, Tasmania
Contact:

Re: Highcharts Graphs

Postby HRVistaWeather » Sat May 07, 2016 6:43 am

Hi,
For those still using (realtimeCumulus.js).
I made a tiny change to the (realtimeCumulus.js) as when using the (Drag / over an area) the "Reset zoom" button was always placed on the Chart itself, resulting in it sitting over the top of some graph Lines (depending on selection).
if you wish to reposition "Reset zoom" button as I have (outside the Chart area);
Change this:

Code: Select all

    $(document).ready(function () {
        // define the chart options
        options = {
            chart: {
                renderTo: 'container',
                zoomType: 'x'
            },

            credits: {

To:

Code: Select all

    $(document).ready(function () {
        // define the chart options
        options = {
            chart: {
                renderTo: 'container',
                zoomType: 'x',
            resetZoomButton: {
                position: {
                    align: 'right', // by default
                    verticalAlign: 'top', // by default
                    x: -10,
                    y: 10
                },
                relativeTo: 'chart'
            }
            },

            credits: {


regards,
You do not have the required permissions to view the files attached to this post.
Tony
https://southfranklinweather.com
Image
Huon River Vista - South Franklin Weather - Tasmania
Davis Vantage Pro 2 Plus - FARS, Cumulus MX, 2 Soil Temp/Moist Solar/Rad.
Back Online : 2017-11-01

happyweather123
Posts: 8
Joined: Mon Aug 15, 2016 5:41 pm
Weather Station: WS2080
Operating System: Windows XP SP3

Re: Highcharts Graphs

Postby happyweather123 » Fri Aug 19, 2016 3:28 pm

I want to change units in realtime highcharts graphs from mph to km/h. And if i change the text and tooltips on it it only changes the text, but i want to convert the like for an example 4mph to 12km/h.
Can you help ?

User avatar
mcrossley
Posts: 4979
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 Aug 19, 2016 3:48 pm

Your data is already in km/h, so why do you need to convert it?

happyweather123
Posts: 8
Joined: Mon Aug 15, 2016 5:41 pm
Weather Station: WS2080
Operating System: Windows XP SP3

Re: Highcharts Graphs

Postby happyweather123 » Fri Aug 19, 2016 3:53 pm

Beacuse it shows the same wind data in mph and also in km/h.

User avatar
mcrossley
Posts: 4979
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 Aug 19, 2016 4:27 pm

OK, for the updates after the page loads you will have to amend the line where the new minutes data gets added to the graph. So around line 60...

Code: Select all

         chart.series[3].addPoint([tim, +getRealtimeValue('wspeed')], false, shift);


to convert from mph to km/h multiply by 1.609344...

Code: Select all

         chart.series[3].addPoint([tim, +getRealtimeValue('wspeed')*1.609344], false, shift);


To convert the historic data loaded when the graph first shows is more complex. You will have to loop through the whole array converting each value.

I'm still pretty sure this isn't what you want to do though. ;) Your data is already in km/h you just need to change the labels from mph to km/h.

Or are you saying you want to add another plot to the graph that shows mph as well as the km/h data already displayed? If so then the conversion needs to be the other way around - and divide by 1.609344.

happyweather123
Posts: 8
Joined: Mon Aug 15, 2016 5:41 pm
Weather Station: WS2080
Operating System: Windows XP SP3

Re: Highcharts Graphs

Postby happyweather123 » Fri Aug 19, 2016 4:50 pm

Well i multipled the windspeed at line 60 but it still shows data in mph. And yes. i just want to change the labels.

If i understand you want to say that the new data will accept that change. Am i right?

User avatar
Mapantz
Posts: 446
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 » Mon Aug 29, 2016 12:55 am

As i've been on a bit of a roll with getting these highcharts going with sql lately, I thought i'd have a read through of the last couple of pages, regarding adding the 'sunbyhour' table.
I'm starting with that first, until I get it working, then i'll add the 'sunbymonthhour' if all goes to plan :lol:

Firstly, I created the sunbyhour table, then executed the insert statement that Mark provided.

2016-08-29.png


I think I've done something wrong though, because if I pull it up here: http://www.warehamwx.co.uk/cumulus/util ... Hourly.php

I see that there's no hour prefix showing on each of the values..

Sorry to be a pain, i'm new to all of this, but finding it fascinating to use, as it's much more efficient to get the data and to do things, rather than relying on cronjobs and text files etc..

Best regards.

Apologies - Two minutes after writing all of that, I realised this: :oops:

$ret[] = array((int)$row['hours'], (float)$row['percent']);

Can I also clarify, does the trigger statement get added in to the Dayfile table, with the 'TIME' set to 'AFTER'? I presume it will run that statement, as soon as CMX inserts the new line after midnight?
You do not have the required permissions to view the files attached to this post.
Image
Image

User avatar
mcrossley
Posts: 4979
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 Aug 29, 2016 7:41 pm

Mapantz wrote:Can I also clarify, does the trigger statement get added in to the Dayfile table, with the 'TIME' set to 'AFTER'? I presume it will run that statement, as soon as CMX inserts the new line after midnight?

Yes, and yes :)

User avatar
Mapantz
Posts: 446
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 » Fri Sep 09, 2016 9:41 pm

This is a strange one, and i've only found it by accident (while changing colours and such, and checking by pressed F5)

http://www.warehamwx.co.uk/cumulus/trends.htm

Click the 'Wind Dir' button and look at the scatter, then click it a few more times, but keep your eye on certain points. It keeps changing the scatter for me. Is that normal, or is something going on?

2016-09-09.png
2016-09-09 (1).png
You do not have the required permissions to view the files attached to this post.
Image
Image

User avatar
mcrossley
Posts: 4979
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 » Sat Sep 10, 2016 10:24 am

Hi Tina, yes it is changing. Here's why...

[Assumption:- you are using a fairly frequent update rate for the real-time data - say 5 seconds]

You have set up the script to return every 15th record from the database (good move if you have very frequent updates, they wouldn't all fit on the graph anyway - though every 12th ~= 1 minute?).

So if you insert a new table row every 5 seconds (guess), then the 'every 15th sub-set moves on every 5 seconds.
You *may*/should see that the pattern repeats - with a new point added at the end - every 15 * 5 secs = 75 seconds or so. (I haven't tried!)

You don't see this effect of the other graphs as the data is slow changing in comparison to wind direction.

I have set the cache TTL for the data returned at 10 minutes on my server, if you did that it would save some load on the server, and a person clicking around the graphs would see consistent data within the same visit.

An alternative approach, would be to amend the database query so it only returned the first row of each new minute, rather than every 15th. Then teh data would be consistent with just the minutes rolling in and out of the 'window'.

User avatar
Mapantz
Posts: 446
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 Sep 10, 2016 12:03 pm

Ah - I didn't think about that!

So I could amend this then?

Code: Select all

realtimeLogSql.php?recordAge=1440&recordUnit=minute&nth=15&bearing&avgbearing


My realtime upload to sql is every 4 seconds.

PS: I've now moved my anemometer to the chimney, if you take a look at this graph I saved from yesterday, you'll see where it was originally, and then when it was moved. It is much more consistent! :)

chart.png
You do not have the required permissions to view the files attached to this post.
Image
Image

User avatar
mcrossley
Posts: 4979
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 » Sat Sep 10, 2016 1:56 pm

Yep, if you change the "nth=15" parameter, that controls how many data entries are skipped. So at 4 seconds per row, nth=15 should be giving you one record per minute. If you set it at 1 (or delete it) you will get back all the records for period. HighCharts may not plot them all on the default view, as it starts to filter out records to speed up the display, but you should see them when you zoom in.

The wind direction is visibly less 'waggy' afterwards :)

User avatar
Mapantz
Posts: 446
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 Sep 10, 2016 4:18 pm

That's the problem though, if I set nth to 1, or delete it, the data completely lags the highchart and it becomes unseable. I guess it'll have to be a random scatter each time then. :)
Image
Image

User avatar
Mapantz
Posts: 446
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 » Fri Sep 30, 2016 3:09 pm

All the exporting options have disappeared from my graphs today, has anyone else's gone?

I was using:

Code: Select all

  <script src="http://code.highcharts.com/modules/exporting.js"></script>


The link still works, but it looks like it was updated. I don't know what has changed for it not to work though.
Image
Image

User avatar
mcrossley
Posts: 4979
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 Sep 30, 2016 4:09 pm

Highcharts have updated to version 5.0.0 - and it's broken stuff again! I'm going to link to 4.2.7 until I can sort this out.


Return to “3rd Party Tools”

Who is online

Users browsing this forum: No registered users and 5 guests