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 4018) - 28 March 2024

Legacy Cumulus 1 release v1.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

Highcharts Graphs

Discussion and support for 3rd-party (non-Sandaysoft) tools for Cumulus
User avatar
BeaumarisWX
Posts: 359
Joined: Mon 09 Apr 2012 2:38 pm
Weather Station: Davis VP2 Plus - 24hr FARS
Operating System: Windows 10 Pro Hades Canyon
Location: Beaumaris, Tasmania, AU
Contact:

Re: Highcharts Graphs

Post by BeaumarisWX »

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 Beaumaris, Tasmania (AUS)

CMX Mobile : https://beaumaris-weather.com/BWX/
CMX Default: https://beaumaris-weather.com/cumulusmx_default/
Colour Dashboard : https://beaumaris-weather.com/dashborad_color.php
Click below for Saratoga Template :
Image
happyweather123
Posts: 8
Joined: Mon 15 Aug 2016 5:41 pm
Weather Station: WS2080
Operating System: Windows XP SP3

Re: Highcharts Graphs

Post by happyweather123 »

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: 12695
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Highcharts Graphs

Post by mcrossley »

Your data is already in km/h, so why do you need to convert it?
happyweather123
Posts: 8
Joined: Mon 15 Aug 2016 5:41 pm
Weather Station: WS2080
Operating System: Windows XP SP3

Re: Highcharts Graphs

Post by happyweather123 »

Beacuse it shows the same wind data in mph and also in km/h.
User avatar
mcrossley
Posts: 12695
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Highcharts Graphs

Post by mcrossley »

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 15 Aug 2016 5:41 pm
Weather Station: WS2080
Operating System: Windows XP SP3

Re: Highcharts Graphs

Post by happyweather123 »

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?
Mapantz
Posts: 1778
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Highcharts Graphs

Post by Mapantz »

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
User avatar
mcrossley
Posts: 12695
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Highcharts Graphs

Post by mcrossley »

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 :)
Mapantz
Posts: 1778
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Highcharts Graphs

Post by Mapantz »

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
User avatar
mcrossley
Posts: 12695
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Highcharts Graphs

Post by mcrossley »

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'.
Mapantz
Posts: 1778
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Highcharts Graphs

Post by Mapantz »

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
User avatar
mcrossley
Posts: 12695
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Highcharts Graphs

Post by mcrossley »

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 :)
Mapantz
Posts: 1778
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Highcharts Graphs

Post by Mapantz »

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
Mapantz
Posts: 1778
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Highcharts Graphs

Post by Mapantz »

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
User avatar
mcrossley
Posts: 12695
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Highcharts Graphs

Post by mcrossley »

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.
Post Reply