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 4019) - 03 April 2024

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

[Q] Graphs - changing Wind Dir yAxis

Topics about the Beta trials up to Build 3043, the last build by Cumulus's founder Steve Loft. It was by this time way out of Beta but Steve wanted to keep it that way until he made a decision on his and Cumulus's future.

Moderator: mcrossley

Locked
TgT
Posts: 132
Joined: Thu 26 Jun 2008 5:51 am
Weather Station: Davis VP2 + Solar
Operating System: A20 TV box + CumulusMX
Location: Slov.Konjice, Slovenia
Contact:

[Q] Graphs - changing Wind Dir yAxis

Post by TgT »

Hi

This is how my graphs for wind direction looks like...
Image
Mostly my wind direction is between W and NE, and I would like to have that part in the middle of the graph. Is it doable? Anyone with highchart skills here? ;)
Image
User avatar
steve
Cumulus Author
Posts: 26701
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: [Q] Graphs - changing Wind Dir yAxis

Post by steve »

In the code which sets the series data, you could process the array of points and modify it appropriately (add 180 modulo 360 or whatever) and then call setData() with the new array of points. You would also have to modify the array which sets the labels.

This is the existing code:

Code: Select all

$.ajax({
        url: 'api/graphdata/wdirdata.json',
        dataType: 'json',
        success: function (resp) {
            chart.hideLoading();
            chart.series[0].setData(resp.bearing);
            chart.series[1].setData(resp.avgbearing);
        }
});
Something like this might work:

Code: Select all

$.ajax({
        url: 'api/graphdata/wdirdata.json',
        dataType: 'json',
        success: function (resp) {
            chart.hideLoading();
            for (index = 0, len = resp.bearing.length; index < len; ++index) {
               resp.bearing[index][1] = (resp.bearing[index][1] + 180)%360;
            }
            chart.series[0].setData(resp.bearing);
            for (index = 0, len = resp.avgbearing.length; index < len; ++index) {
               resp.avgbearing[index][1] = (resp.avgbearing[index][1] + 180)%360;
            }
            chart.series[1].setData(resp.avgbearing);
        }
});
Completely untested and the syntax may not even be correct!

There may be a more clever way using Highcharts itself to do the processing. It would be simpler if Cumulus had it as an option, as in Cumulus 1 - I'll look into it at some point.
Steve
User avatar
laulau
Posts: 678
Joined: Tue 13 Oct 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: [Q] Graphs - changing Wind Dir yAxis

Post by laulau »

steve wrote: You would also have to modify the array which sets the labels.
Like this

Code: Select all

var compassP = function (deg) {
	var a = ['S', 'SW', 'W', 'NW', 'N', 'NE', 'E', 'SE'];
	return a[Math.floor((deg + 22.5) / 45) % 8];
};
And it works :clap:
CaptureCharts.JPG
You do not have the required permissions to view the files attached to this post.
Laurent

Image
TgT
Posts: 132
Joined: Thu 26 Jun 2008 5:51 am
Weather Station: Davis VP2 + Solar
Operating System: A20 TV box + CumulusMX
Location: Slov.Konjice, Slovenia
Contact:

Re: [Q] Graphs - changing Wind Dir yAxis

Post by TgT »

havent tried it yet, but as it seems it works, gj! :clap:
A really nice line, You got there laulau
Image
Locked