I played around a bit with this code for wind colors in the Belchertown skin. I too had some difficulty with the colors and made a few changes. Please see snippet below. I basically had to reverse order the if/else if code to put the higher wind speed first because the else if would always stop a the first >= and not go any further. Your windSpeeds/windGusts and colors may not match mine so adjust to taste.
// Change the color of the Windspeed variable according to US-EPA standards
// (adjusted to match skin colors better)
function get_windSpeed_color(windSpeed, returnColor = false) {
windSpeed = parseFloat(windSpeed).toFixed(1); // Convert back to decimal lit
if (windSpeed <= 1.1) {
var windSpeed_color = "rgba(18,120,200,1)";
} else if (windSpeed >= 24.0) {
var windSpeed_color = "rgba(159,0,197,1)";
} else if (windSpeed >= 18.0) {
var windSpeed_color = "rgba(255,69,0,1)";
} else if (windSpeed >= 12.4) {
var windSpeed_color = "rgba(255,127,0,1)";
} else if (windSpeed >= 7.5) {
var windSpeed_color = "rgba(255,174,0,1)";
} else if (windSpeed >= 3.7) {
var windSpeed_color = "rgba(113,188,60,1)";
} else if (windSpeed >= 1.2) {
var windSpeed_color = "rgba(31,175,221,1)";
}
// Return the color value if requested, otherwise just set the div color
if (returnColor) {
return windSpeed_color;
} else {
jQuery(".curwindspeed").css("color", windSpeed_color);
}
}
// Change the color of the aqi variable according to US-EPA standards
// (adjusted to match skin colors better)
function get_windGust_color(windGust, returnColor = false) {
windGust = parseFloat(windGust).toFixed(1); // Convert back to decimal liter
if (windGust <= 1.1) {
var windGust_color = "rgba(18,120,200,1)";
} else if (windGust >= 24.0) {
var windGust_color = "rgba(159,0,197,1)";
} else if (windGust >= 18.0) {
var windGust_color = "rgba(255,69,0,1)";
} else if (windGust >= 12.4) {
var windGust_color = "rgba(255,127,0,1)";
} else if (windGust >= 7.5) {
var windGust_color = "rgba(255,174,0,1)";
} else if (windGust >= 3.7) {
var windGust_color = "rgba(113,188,60,1)";
} else if (windGust >= 1.2) {
var windGust_color = "rgba(31,175,221,1)";
}
// Return the color value if requested, otherwise just set the div color
if (returnColor) {
return windGust_color;
} else {
jQuery(".curwindgust").css("color", windGust_color);
}
}
cheers Jim