From eb847230d59ccf5b780c3b6b864961fe98a8fb69 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Sat, 18 Apr 2015 18:25:12 +0200 Subject: [PATCH] Phi: correct wind arrows on Stuve chart Round wind speed to nearest 5kt --- Phi/topics/Environment/Weather2.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Phi/topics/Environment/Weather2.js b/Phi/topics/Environment/Weather2.js index 44f085170..9be11aa9a 100644 --- a/Phi/topics/Environment/Weather2.js +++ b/Phi/topics/Environment/Weather2.js @@ -2,6 +2,12 @@ define([ 'knockout', 'jquery', 'text!./Weather2.html', 'props', 'flot', 'flotresize' ], function(ko, jquery, htmlString, SGPropertyNode) { + if(typeof Math.roundTo === "undefined") { + Math.roundTo = function(num, step) { + return Math.floor((num / step) + .5) * step; + } + } + function ViewModel(params, componentInfo) { // componentInfo.element @@ -281,7 +287,8 @@ define([ function drawSeriesWindarrows(datapoints) { var points = datapoints.points, ps = datapoints.pointsize; for (var i = 0; i < points.length; i += ps) { - var ws = points[i], y = points[i+1], wd = points[i+2]; + var ws = Math.roundTo( points[i],5 ), + y = points[i+1], wd = points[i+2]; var x = series.xaxis.p2c(40); y = series.yaxis.p2c(y);