Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.5 (build 3282) - 23 February 2024

Cumulus MX V4 beta test release 4.0.0 (build 4017) - 17 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 Question

Discussion and support for 3rd-party (non-Sandaysoft) tools for Cumulus
Post Reply
Mapantz
Posts: 1772
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Highcharts Question

Post by Mapantz »

I've been spending some time playing around with some highcharts graphs recent, and got a little carried away.. :lol:

https://warehamwx.co.uk/graphs_monthly.php

I have plans for a few more, one of them was using windbarb.js

I did get a windbarb chart working, but I ran in to a problem with it, so I scrapped it. I wanted to try again, but thought I'd see if anyone here has used it.

I used HighWindGust and HWindGBear from the Dayfile table in SQL, and put it in to an array. I put a chart together for area, as well as the windbarbs. I noticed that the windbarbs had a lot of pennants, meaning that it was showing high winds. Sure enough, the tooltips were showing 'hurricane' and 'violent storm'. After some faffing around, I realised that the windbarb.js is using metres per second. It was interpreting a 56mph gust as 56m/s (125mph).

I then thought that perhaps I might be able to convert my readings from mph to m/s, then only show the beaufort description in the windbarb tooltip. I did just that and thought I'd solved it. However, the windbarbs on the charts were still showing too many pennants, which didn't relate to the actual wind speeds.

It now seems that coding may be needed for the barbs themselves, to properly do a conversion so that the correct pennants show up on them. It's not as simple as just converting the actual value to m/s.

I've had a look, but I cannot seem to find any information on it. I find it rather strange that they would lock it to a single unit?!

Simple question; Has anyone managed to do it?
Image
User avatar
HansR
Posts: 5832
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: Highcharts Question

Post by HansR »

@Mapantz: Yes, I used the windbarbs in my AirLink module of CumulusUtils (See here menu choose Extra=>AirLink=>Grafiek Out.

Indeed the windbarbs only use the m/s, all figures are taken as m/s. Afaik the conversion should be enough.
My code for the chart as seen can be seen here

The relevant parts are:

Code: Select all

      if (idx in resp) {
        if (idx == 'wind') {
           let convertedWindbarbData = convertToMs(resp[idx]);
          chart.addSeries({name: titles[idx], xAxis: 1, color: 'black', type: 'windbarb', visible: true, tooltip: {valueSuffix: ' m/s'}, data: convertedWindbarbData }, false);
        }
        else {
          chart.addSeries({name: titles[idx], id: titles[idx], data: resp[idx]}, false);
        }
      }
and the conversion function:

Code: Select all

function convertToMs(data){data.map(s => {s[1] = s[1] * 0.27778 }); return data}
I had help from HighCharts support on their own forum and on StackOverflow.

That should do it.
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
Mapantz
Posts: 1772
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Highcharts Question

Post by Mapantz »

Hi Hans

Thanks for the reply.

The problem is, I don't want the chart to show my speeds in m/s. It was easy enough converting mph to m/s, I did that in the php file that grabs the data from my sql table

Code: Select all

$HGustDir[] = array((float)$row[13]  * 0.44704, (float)$row[21]);
Converting the data within the highchart itself is the problem.

I can make it show the wind speed values in mph, but the windbarb icons themselves will always read the data as m/s, that's the problem I have..

Added a windbarb chart at the bottom of the page: https://warehamwx.co.uk/graphs_monthly.php
Image
User avatar
HansR
Posts: 5832
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: Highcharts Question

Post by HansR »

Search the highcharts forum/stackoverflow vor windbarbs, I know the code to modify the windbarbs pennants is in there for sure. I have seen it but did not note the link as that was not what i was looking for. But it is published by highcharts how to deal with this.
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
Mapantz
Posts: 1772
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Highcharts Question

Post by Mapantz »

I think I may have found it, Hans.
Image
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Highcharts Question

Post by beteljuice »

@ Map ...

$HGustDir[] = direction not speed ?
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
HansR
Posts: 5832
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: Highcharts Question

Post by HansR »

Mapantz wrote: Sat 21 Aug 2021 4:01 pm I think I may have found it, Hans.
Good. Any use of publishing ot here for completeness?
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
Mapantz
Posts: 1772
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: Highcharts Question

Post by Mapantz »

beteljuice wrote: Sat 21 Aug 2021 4:23 pm @ Map ...

$HGustDir[] = direction not speed ?
Row 13 is the gust speed in my script (now changed it to max wind speed) row 21 is now the dominant direction of the day.
HansR wrote: Sat 21 Aug 2021 4:43 pm Good. Any use of publishing ot here for completeness?
I'll put a zip together later if folks are interested?!
Image
User avatar
HansR
Posts: 5832
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bullseye
Location: Wagenborgen (NL)
Contact:

Re: Highcharts Question

Post by HansR »

Well, i am. Is that enough 8-)
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
Post Reply