Fix speed over attenuation graph
authorGu1 <gu1@cafai.fr>
Sat, 13 Apr 2013 21:26:21 +0000 (23:26 +0200)
committerGu1 <gu1@cafai.fr>
Sat, 13 Apr 2013 21:26:21 +0000 (23:26 +0200)
fdneligibility/static/js/eligibility.js

index c12330d..ab9213e 100644 (file)
@@ -84,12 +84,13 @@ $(document).ready(function() {
                     atn2=cur['attenuation'];
                 lerped_adsl2=speedp1+(speedp2-speedp1)/(atn2-atn1)*(line_attenuation-atn1);
                 lerped_adsl=speed1+(speed2-speed1)/(atn2-atn1)*(line_attenuation-atn1);
+                closest=line_attenuation-atn1 > atn2-line_attenuation ? closest+1 : closest;
                 break;
             } else {
                 closest = t;
             }
         }
-        adsl_speed_over_attenuation.splice(closest, 0, {
+        adsl_speed_over_attenuation.splice(closest, 1, {
             'attenuation': line_attenuation,
             'adsl': lerped_adsl,
             'adsl2+': lerped_adsl2
@@ -107,12 +108,12 @@ $(document).ready(function() {
             }
             return r;
         })(),
-        target_point: closest !== undefined ? closest+1 : undefined, // on which point should we put the marker
+        target_point: closest !== undefined ? closest : undefined, // on which point should we put the marker
         xkey: 'attenuation',
         parseTime: false,
         ykeys: ['adsl2+', 'adsl'],
         ymax: 50000,
-        yLabelFormat : function(y) { return (y/1000)+' Mb/s' },
+        yLabelFormat : function(y) { return Math.round(y/10)/100+' Mb/s' },
         labels: ['ADSL2+', 'ADSL'],
         pointSize: 0,
         hideHover:'auto',