Page 1 of 1

changing tempScaleDefMaxC causes erratic behaviour

Posted: Wed 27 Jan 2016 10:06 am
by UncleBuck
I switched from Weathercat to CumulusMX in the last few days (since I replaced the Oregon with a Davis) and was installing the SS gauges.
When I changed the tempScaleDefMaxC from its default to be 50 the temp gauges pointers starting jumping back to 0 and then climbing up to the current temps.
If I change the setting to 45 then it returns to its expected behaviour of not moving unless the temp changes.

I can put up with the setting being at 45 as we have only had about two days in the last 3 years where it has exceeded the 45 here.
Just thought you would like to know about the unexpected weirdness.

Col.

Re: changing tempScaleDefMaxC causes erratic behaviour

Posted: Wed 27 Jan 2016 10:38 am
by mcrossley
Hi, could you post a link to the page and leave it with the odd behaviour for a while so I can take a look?

The gauges will automatically rescale if a reading exceeds the defaults in a given day.

Re: changing tempScaleDefMaxC causes erratic behaviour

Posted: Thu 28 Jan 2016 5:22 am
by UncleBuck
Hi Mark,
This is the page with the basic gauges on it.
http://www.pcweather.kcsolutions.com.au ... -basic.htm
The erratic behaviour only happens if viewing in Deg C, as I have not modified the defaults for Deg F.

Colin.

Re: changing tempScaleDefMaxC causes erratic behaviour

Posted: Thu 28 Jan 2016 9:32 am
by mcrossley
OK, I see what the problem is.

The gauges by default are configured to have a 'niceScale', that means it takes your min and max scale values and rounds them numbers that create a more pleasing set of scale numbers. You can see the difference when I disable the niceScale on your temp gauge compared with the dew gauge here...
Untitled-1.png
The temp gauge ends up with a tick mark every 0.5 degree and every 2.5 degrees there is a semi-major tick mark.

You have specified the max as 50 and the min as -5, as these are not both multiples of 10, the niceScale routine rounds your min to -10.

Now the code checks if the required min scale value matches the current gauge min scale value, if they don't match the gauge is redrawn. But due to niceScale, it redraws again with a rounded min value of -10 instead of the requested -5.

With me so far? :?

So two options to fix this...

1. Change your min scale values for the temp and dew gauges to -10
2. Add an additional parameter to the temp and dew gauges to disable 'niceScale' and keep your -5
- Add

Code: Select all

                    params.niceScale = false;
at lines 720 and 957

Re: changing tempScaleDefMaxC causes erratic behaviour

Posted: Thu 28 Jan 2016 1:19 pm
by UncleBuck
Yep, got all that....
Have decided to go with option 1 even though I don't think we have ever gone below about -3 here.
It's just easier to change the DefMin as the gauges look better that way.

Now I just need to finish troubleshooting those damn popup graphs :groan:

Re: changing tempScaleDefMaxC causes erratic behaviour

Posted: Sat 19 Oct 2019 8:00 pm
by Phil23
Reviving this after a few years for some current version clarification of this Fix.
mcrossley wrote: Thu 28 Jan 2016 9:32 am OK, I see what the problem is.

The gauges by default are configured to have a 'niceScale',
So two options to fix this...

1. Change your min scale values for the temp and dew gauges to -10
2. Add an additional parameter to the temp and dew gauges to disable 'niceScale' and keep your -5
- Add

Code: Select all

                    params.niceScale = false;
at lines 720 and 957
I'm assuming line numbers may have changed over the years, so if it belongs in this block of code?
Lines 714 to 724 of Version 2.7.3.

Code: Select all

                var params = $.extend(true, {}, commonParams);

                // define temperature gauge start values
                cache.sections = createTempSections(true);
                cache.areas = [];
                cache.minValue = gaugeGlobals.tempScaleDefMinC;
                cache.maxValue = gaugeGlobals.tempScaleDefMaxC;
                cache.title = strings.temp_title_out;
                cache.value = gaugeGlobals.tempScaleDefMinC + 0.0001;
                cache.maxMinVisible = false;
                cache.selected = 'out';
Or is it meant to be in the block below?
Lines 726 to 739.

Code: Select all

                // create temperature radial gauge
                if ($('#canvas_temp').length) {
                    params.size = Math.ceil($('#canvas_temp').width() * config.gaugeScaling);
                    params.section = cache.sections;
                    params.area = cache.areas;
                    params.minValue = cache.minValue;
                    params.maxValue = cache.maxValue;
                    params.thresholdVisible = false;
                    params.minMeasuredValueVisible = cache.maxMinVisible;
                    params.maxMeasuredValueVisible = cache.maxMinVisible;
                    params.titleString = cache.title;
                    params.unitString = data.tempunit;
                    params.trendVisible = gaugeGlobals.tempTrendVisible;
                    // params.customLayer = _imgBackground;      // uncomment to add a background image - See Logo Images above
Thanks

Phil.

Edit:-

The mod at line 957 is a bit harder to work out, as that block has undoubtedly moved during updates to code.

Re: changing tempScaleDefMaxC causes erratic behaviour

Posted: Sat 19 Oct 2019 10:29 pm
by mcrossley
you need to add the niceScale = false in your second block of code.